From 9075e9624d4b67462311904be9bd3a99a7babdd5 Mon Sep 17 00:00:00 2001 From: Peter M. Groen Date: Wed, 23 Mar 2022 10:42:30 +0100 Subject: [PATCH] Check the c++ standard --- compiler.cmake | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/compiler.cmake b/compiler.cmake index 79198c3..a0ac042 100644 --- a/compiler.cmake +++ b/compiler.cmake @@ -127,13 +127,24 @@ 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") + # Check which version of c++ we can use. We drill down from c++17 to c98 + CHECK_CXX_COMPILER_FLAG( -stdc++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. -- libgit2 0.21.4