Make use of more modern CMake features (cmake-compile-features e.g.)
Compile feature requirements may be specified with the target_compile_features() command. For example, if a target must be compiled with compiler support for the cxx_constexpr feature:
add_library(mylib requires_constexpr.cpp)
target_compile_features(mylib PRIVATE cxx_constexpr)
In processing the requirement for the cxx_constexpr feature, cmake(1) will ensure that the in-use C++ compiler is capable of the feature, and will add any necessary flags such as -std=gnu++11 to the compile lines of C++ files in the mylib target. A FATAL_ERROR is issued if the compiler is not capable of the feature.
The exact compile flags and language standard are deliberately not part of the user interface for this use-case. CMake will compute the appropriate compile flags to use by considering the features specified for each target.
I our case we could use that to replace our buildsystem/CheckCompilerFeatures.cmake that is giving me some headache to get running with MingW ld.gold on Msys2 right now (was chosing lld now though).
I feel these compile features could make it much easier for us to let CMake decide if a compiler is able to compile our stuff if we name the features we need and let it chose the appropriate compile flags. Because this check that we do right now is not only testing if the compiler can compile something but also if the linker has the right flags (implicitly).
Which is good somehow, don't get me wrong. But we should be sure, before we compile that, that we have all the options figured out/have CMake figured it out for us.
https://cmake.org/cmake/help/v3.12/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html https://cmake.org/cmake/help/v3.12/manual/cmake-compile-features.7.html
Same for target_compile_definitions() if needed.
For example:
target_compile_features(libopenage
PUBLIC
cxx_variadic_templates
cxx_nullptr
PRIVATE
cxx_lambdas
)