Merged
Merge Request #1
·
created by
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.
-
This message prints all cxx flags, not just the c++ version.
Compiling for -Wall -Wextra -pedantic -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Winit-self -Wuninitialized -Wunused -Wcast-qual -Wno-long-long -Wold-style-cast -Werror=return-type -Wno-noexcept-type -Werror -fPIC -fstack-protector-all -fthreadsafe-statics -mfpmath=sse -std=c++17
Do we want this behavior or should we limit the message to only show the c++ version in use?
-
I really would like have the whole flag status printed for debugging purposes.
-
should we go ahead and extend to a c++20 / c++23 check or keep this for a later moment due to unexpected results?
-
I'm afraid for the fall-out if we challenge our current code against c++20+ :D
-
mentioned in commit eddb62435e5b03243df6c5220d023eca4d780fee
-
Status changed to merged
| 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 | 147 | endif() |
| 136 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
| 148 | + MESSAGE(STATUS "Compiling for ${CMAKE_CXX_FLAGS}") | |
| 2 |
|
|
| 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 | + 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 | |
| 2 |
|
|
| @@ -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 | ||
| 2 |
|
||
| 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}") |
| 2 |
|
||
| 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. |