1target_compile_features 2----------------------- 3 4.. versionadded:: 3.1 5 6Add expected compiler features to a target. 7 8.. code-block:: cmake 9 10 target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...]) 11 12Specifies compiler features required when compiling a given target. If the 13feature is not listed in the :variable:`CMAKE_C_COMPILE_FEATURES`, 14:variable:`CMAKE_CUDA_COMPILE_FEATURES`, or :variable:`CMAKE_CXX_COMPILE_FEATURES` 15variables, then an error will be reported by CMake. If the use of the feature requires 16an additional compiler flag, such as ``-std=gnu++11``, the flag will be added 17automatically. 18 19The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to 20specify the scope of the features. ``PRIVATE`` and ``PUBLIC`` items will 21populate the :prop_tgt:`COMPILE_FEATURES` property of ``<target>``. 22``PUBLIC`` and ``INTERFACE`` items will populate the 23:prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ``<target>``. 24Repeated calls for the same ``<target>`` append items. 25 26.. versionadded:: 3.11 27 Allow setting ``INTERFACE`` items on :ref:`IMPORTED targets <Imported Targets>`. 28 29The named ``<target>`` must have been created by a command such as 30:command:`add_executable` or :command:`add_library` and must not be an 31:ref:`ALIAS target <Alias Targets>`. 32 33Arguments to ``target_compile_features`` may use "generator expressions" 34with the syntax ``$<...>``. 35See the :manual:`cmake-generator-expressions(7)` manual for available 36expressions. See the :manual:`cmake-compile-features(7)` manual for 37information on compile features and a list of supported compilers. 38