![]() Optional Compile Features ¶Ĭompile features may be preferred if available, without creating a hard In user code or in the headers of third-party dependencies. ![]() Most compilers enable extensions by default, this may expose portability bugs The _EXTENSIONS target property defaults to the compiler'sĭefault (see CMAKE_EXTENSIONS_DEFAULT). Or if the _STANDARD target property is set. The flag may still be added if the compiler's default extensions modeĭoes not match the _EXTENSIONS target property, ![]() Of the requested feature, CMake may omit the -std= flag. If the compiler's default standard level is at least that Header files, then clients must use a compiler mode that is no less Not guarantee the existence of any particular feature.ĭiagnosis of use of unsupported features will be delayed until compile time.įor example, if C++ 11 features are used extensively in a project's This is simpler than specifying all the features individually, but does That is at minimum aware of that standard, but could be greater. cxx_std_11) that requires use of a compiler mode In projects that use a large number of commonly available features fromĪ particular language standard (e.g. Transitive behavior of build properties and usage requirements. add_executable( myexe main.cpp ) target_link_libraries( myexe mylib )įeature requirements are evaluated transitively by consuming the link INTERFACE signatures of target_compile_features():Īdd_library( mylib requires_constexpr.cpp ) # cxx_constexpr is a usage-requirement target_compile_features( mylib PUBLIC cxx_constexpr ) # main.cpp will be compiled with -std=gnu++11 on GNU for cxx_constexpr. 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
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |