diff --git a/compiler.cmake b/compiler.cmake index 79198c3..b68d2ed 100644 --- a/compiler.cmake +++ b/compiler.cmake @@ -127,13 +127,25 @@ if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse" ) endif() - # -std=c++11 will be supported starting GCC 4.7, older versions need c++0x - CHECK_CXX_COMPILER_FLAG( -std=c++11 cxxresult ) - - if( NOT cxxresult) - message(FATAL_ERROR, "Compiler does not support c++11") + MESSAGE(STATUS "Checking the c++ Standard supported by the compiler" ) + # Check which version of c++ we can use. We drill down from c++17 to c96 + CHECK_CXX_COMPILER_FLAG( -std=c++17 cxxresult ) + if( NOT cxxresult ) + CHECK_CXX_COMPILER_FLAG( -std=c++14 cxxresult ) + if( NOT cxxresult ) + CHECK_CXX_COMPILER_FLAG( -std=c++11 cxxresult ) + if( NOT cxxresult ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif() + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + endif() + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + MESSAGE(STATUS "Compiling for ${CMAKE_CXX_FLAGS}") # -Wzero-as-null-pointer-constant is disabled for now, since the Qt 4.8.4 # macro's produce a bucketload of these warnings. Might be useful later on.