From 774d455dc720dc0d90d4d0bbdc57bde0ccb9f51d Mon Sep 17 00:00:00 2001 From: Kevin Brightwell Date: Fri, 5 Feb 2016 15:23:17 -0500 Subject: [PATCH] Update CMakeLists to be more configurable --- .gitignore | 1 + CMakeLists.txt | 2 ++ src/CMakeLists.txt | 11 ++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1377554..4e15aee 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +build* diff --git a/CMakeLists.txt b/CMakeLists.txt index 219a714..82dcc2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,8 @@ project(cxxopts) set(VERSION "0.0.1") +option(CXXOPTS_BUILD_EXAMPLES "Set to ON to build examples" ON) + set(CXXOPTS_LINKER_LIBRARIES "") set(CXXOPTS_USE_UNICODE_HELP FALSE CACHE BOOL "Use ICU Unicode library") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 625abe9..b750ef5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,9 +18,14 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -add_executable(example example.cpp) +if(CXXOPTS_BUILD_EXAMPLES) + add_executable(example example.cpp cxxopts.hpp) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") -target_link_libraries(example ${CXXOPTS_LINKER_LIBRARIES}) + if (MSVC) + target_compile_options(example PUBLIC /W2) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_options(example PUBLIC -std=c++11 -Wall) + endif() +endif() install(FILES cxxopts.hpp DESTINATION include) -- libgit2 0.21.4