From 3314aa43c215b1543a8d0330af4954f0c29792ae Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 30 Apr 2015 14:40:37 +0100 Subject: [PATCH] Allow the user to set the C++ standard to use This is useful to test the library at different standard levels. Currently doesn't search for C++14 in 'auto' mode. Can enable in the future --- CMakeLists.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd9c6354..4f09ceae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,18 +18,16 @@ message("-- Version: ${VERSION}") set(GENERIC_LIB_VERSION ${VERSION}) string(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION) -# Try and enable C++11. Don't use C++14 because it doesn't work in some -# configurations. +# Import our CMake modules include(CheckCXXCompilerFlag) include(AddCXXCompilerFlag) include(CXXFeatureCheck) -check_cxx_compiler_flag(-std=c++11 HAVE_FLAG_CXX_11) -check_cxx_compiler_flag(-std=c++0x HAVE_FLAG_CXX_0X) -if (HAVE_FLAG_CXX_11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -elseif (HAVE_FLAG_CXX_0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +# Try and enable C++11. Don't use C++14 because it doesn't work in some +# configurations. +add_cxx_compiler_flag(-std=c++11) +if (NOT HAVE_CXX_FLAG_STD_CXX11) + add_cxx_compiler_flag(-std=c++0x) endif() # Turn compiler warnings up to 11