Feature request: Add support for c++ feature test macros
I am searching for a way, to test the c++ features, before building the application. This is especially useful, when using different source and header files for different targets.
There is check_cxx_symbol_exists
, but it only tests the availability of a symbol and does not return its value.
I would propose something like check_cxx_definition(<symbol test sequence> <files> <variable>)
Used like:
check_cxx_definition("__cpp_lib_format >= 202110L" "<format>" _HAS_FORMAT_CXX20_DL)
# _HAS_FORMAT_CXX20_DL EQUALS 1
Or even better
check_cxx_definition("__cpp_lib_format" "<format>" _CPP_LIB_FORMAT_VAL)
# _CPP_LIB_FORMAT_VAL => Either empty when undefined or the value e.g. 202110
The first version is simpler to realize, since one could just insert the symbol test sequence in a source file.