Commit 9075e9624d4b67462311904be9bd3a99a7babdd5

Authored by Peter M. Groen
1 parent 89c657f5

Check the c++ standard

Showing 1 changed file with 17 additions and 6 deletions
compiler.cmake
... ... @@ -127,13 +127,24 @@ if(CMAKE_COMPILER_IS_GNUCXX)
127 127 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse" )
128 128 endif()
129 129  
130   - # -std=c++11 will be supported starting GCC 4.7, older versions need c++0x
131   - CHECK_CXX_COMPILER_FLAG( -std=c++11 cxxresult )
132   -
133   - if( NOT cxxresult)
134   - message(FATAL_ERROR, "Compiler does not support c++11")
  130 + # Check which version of c++ we can use. We drill down from c++17 to c98
  131 + CHECK_CXX_COMPILER_FLAG( -stdc++17 cxxresult )
  132 + if( NOT cxxresult )
  133 + CHECK_CXX_COMPILER_FLAG( -std=c++14 cxxresult )
  134 + if( NOT cxxresult )
  135 + CHECK_CXX_COMPILER_FLAG( -std=c++11 cxxresult )
  136 + if( NOT cxxresult )
  137 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  138 + else()
  139 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  140 + endif()
  141 + else()
  142 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  143 + endif()
  144 + else()
  145 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
135 146 endif()
136   - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  147 + MESSAGE(STATUS "Compiling for ${CMAKE_CXX_FLAGS}")
137 148  
138 149 # -Wzero-as-null-pointer-constant is disabled for now, since the Qt 4.8.4
139 150 # macro's produce a bucketload of these warnings. Might be useful later on.
... ...