From 4b1054e1aaa97d7e7da62bb0e96c49d1736a9c9e Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Tue, 27 Feb 2018 10:42:48 +0500 Subject: [PATCH] Added CMake's checks for C++11 standards Raised minimal version of CMake to 3.1, since on old systems there no decent compilers that supports c++11. Closes #377. --- CMakeLists.txt | 9 ++++++--- test/CMakeLists.txt | 6 ------ util/CMakeLists.txt | 4 +--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f821a91..059ce9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,8 @@ ### ### CMake settings ### -## Due to Mac OSX we need to keep compatibility with CMake 2.6 # see http://www.cmake.org/Wiki/CMake_Policies -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.1) # see http://www.cmake.org/cmake/help/cmake-2-8-docs.html#policy:CMP0012 if(POLICY CMP0012) cmake_policy(SET CMP0012 OLD) @@ -46,6 +45,10 @@ option(YAML_CPP_BUILD_CONTRIB "Enable contrib stuff in library" ON) # http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF) +# Set minimum C++ to 2011 standards +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + # --> Apple option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF) @@ -185,7 +188,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR set(GCC_EXTRA_OPTIONS "${GCC_EXTRA_OPTIONS} ${FLAG_TESTED}") endif() # - set(yaml_cxx_flags "-Wall ${GCC_EXTRA_OPTIONS} -pedantic -Wno-long-long -std=c++11 ${yaml_cxx_flags}") + set(yaml_cxx_flags "-Wall ${GCC_EXTRA_OPTIONS} -pedantic -Wno-long-long ${yaml_cxx_flags}") ### Make specific if(${CMAKE_BUILD_TOOL} MATCHES make OR ${CMAKE_BUILD_TOOL} MATCHES gmake) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3633da5..d24a05f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,12 +15,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(yaml_test_flags "${yaml_test_flags} -Wno-c99-extensions") endif() - - if(CMAKE_COMPILER_IS_GNUCXX) - set(yaml_test_flags "${yaml_test_flags} -std=gnu++11") - else() - set(yaml_test_flags "${yaml_test_flags} -std=c++11") - endif() endif() file(GLOB test_headers [a-z_]*.h) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 2286627..6777686 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -1,14 +1,12 @@ add_sources(parse.cpp) add_executable(parse parse.cpp) target_link_libraries(parse yaml-cpp) -set_target_properties(parse PROPERTIES COMPILE_FLAGS "-std=c++11") add_sources(sandbox.cpp) add_executable(sandbox sandbox.cpp) target_link_libraries(sandbox yaml-cpp) -set_target_properties(sandbox PROPERTIES COMPILE_FLAGS "-std=c++11") add_sources(read.cpp) add_executable(read read.cpp) target_link_libraries(read yaml-cpp) -set_target_properties(read PROPERTIES COMPILE_FLAGS "-std=c++11") +