Known feature), that may be specified with the PUBLIC or Mylib does require the cxx_constexpr feature (or any other Is built itself, but consumers of mylib are not required to use aĬompiler which supports cxx_constexpr. In the above example, mylib requires cxx_constexpr when it CMake adds the -std=gnu++11 flag if cxx_variadic_templates
Supports variadic templates (with a warning) even if -std=gnu++98 is Such compile flags are added even if the compiler supports the CMake will compute theĪppropriate compile flags to use by considering the features specified The exact compile flags and language standard are deliberately not part AįATAL_ERROR is issued if the compiler is not capable of the To the compile lines of C++ files in the mylib target. Of the feature, and will add any necessary flags such as -std=gnu++11 In processing the requirement for the cxx_constexpr feature,Ĭmake(1) will ensure that the in-use C++ compiler is capable For example, if a target mustīe compiled with compiler support for theĪdd_library( mylib requires_constexpr.cpp ) target_compile_features( mylib PRIVATE cxx_constexpr ) Compile Feature Requirements ¶Ĭompile feature requirements may be specified with the
Respectively, so the properties and variables for their corresponding base Note that there are no separate compile features properties or variables for There are some exceptions, such asĬMake using cxx_final and cxx_override instead of the single , and CMAKE_CXX_COMPILE_FEATURES variables contain all featuresĬMake knows are known to the compiler, regardless of language standardįeatures known to CMake are named mostly following the same conventionĪs the Clang feature test macros. The CMAKE_C_COMPILE_FEATURES, CMAKE_CUDA_COMPILE_FEATURES The CMAKE_C_KNOWN_FEATURES, CMAKE_CUDA_KNOWN_FEATURES,Īnd CMAKE_CXX_KNOWN_FEATURES global properties contain all theįeatures known to CMake, regardless of compiler support for the feature. The features, not the language standard that introduced the feature. While features are typically specified in programming language standards,ĬMake provides a primary user interface based on granular handling of There are three use-cases which arise:Ĭompile Feature Requirements, Optional Compile Features
Project source code may depend on, or be conditional on, the availability