-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The top level CMakeLists sets CMAKE_GXX_STANDARD and CMAKE_GXX_STANDARD_REQUIRED variables but as far as I can see these don't do anything.
The "standard" cmake variables introduced in 3.1 are CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED (see, for example https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_STANDARD.html). Setting those variables automatically handles all the "-std=c++17" command line flags that we also for some reason do manually in some places at the moment.
I think we are currently getting lucky that this works since e.g. on ubuntu 24.04 the default gcc 13 will be at least in c++17 mode by default.
In addition, manually setting CMAKE_CXX_COMPILER from a meta-build directly is very much discouraged. If it's needed, it should be done from a toolchain file. As far as I can see it's just there to provide an error message if the compiler isn't installed, which is redundant anyway. Modern cmake supplies what is (IMO) a sufficiently clear error message in this case. (see https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html). If the error message is really wanted it is sufficient to check the variable and emit the error, and not override CMAKE_CXX_COMPILER.
Cheers,
Dan W