Commit eddb62435e5b03243df6c5220d023eca4d780fee
Merge branch 'feat/pgroen/detect-cpp-standard' into 'master'
Feat/pgroen/detect cpp standard Om de hoogst mogelijke C++ standaard mogelijk te detecteren, wordt de compiler afgevraagd wat er wordt ondersteund. Deze standaard wordt dan gevolgd. In de toekomst moet dit gedrag aan / uit gezet kunnen worden met een switch waarin een standaard hard kan worden gezet. See merge request !1
Showing
1 changed file
with
18 additions
and
6 deletions
compiler.cmake
@@ -127,13 +127,25 @@ if(CMAKE_COMPILER_IS_GNUCXX) | @@ -127,13 +127,25 @@ if(CMAKE_COMPILER_IS_GNUCXX) | ||
127 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse" ) | 127 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse" ) |
128 | endif() | 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 | + MESSAGE(STATUS "Checking the c++ Standard supported by the compiler" ) |
131 | + # Check which version of c++ we can use. We drill down from c++17 to c96 | ||
132 | + CHECK_CXX_COMPILER_FLAG( -std=c++17 cxxresult ) | ||
133 | + if( NOT cxxresult ) | ||
134 | + CHECK_CXX_COMPILER_FLAG( -std=c++14 cxxresult ) | ||
135 | + if( NOT cxxresult ) | ||
136 | + CHECK_CXX_COMPILER_FLAG( -std=c++11 cxxresult ) | ||
137 | + if( NOT cxxresult ) | ||
138 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||
139 | + else() | ||
140 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
141 | + endif() | ||
142 | + else() | ||
143 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") | ||
144 | + endif() | ||
145 | + else() | ||
146 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") | ||
135 | endif() | 147 | endif() |
136 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | 148 | + MESSAGE(STATUS "Compiling for ${CMAKE_CXX_FLAGS}") |
137 | 149 | ||
138 | # -Wzero-as-null-pointer-constant is disabled for now, since the Qt 4.8.4 | 150 | # -Wzero-as-null-pointer-constant is disabled for now, since the Qt 4.8.4 |
139 | # macro's produce a bucketload of these warnings. Might be useful later on. | 151 | # macro's produce a bucketload of these warnings. Might be useful later on. |