Help: Add .. versionadded directives to commands documentation

This change ony concerns directives that appear in the document body.

The guidelines for inserting version directives:

 * Baseline version is CMake 3.0, i.e. directives start at 3.1.
 * Always use `.. versionadded::` directive, avoid ad-hoc version
   references. Exception: policy pages.
 * For new command signatures, put `versionadded` on a separate line
   after the signature.
 * For a group of new signatures in a new document section,
   a single version note at the beginning of the section is sufficient.
 * For new options, put `versionadded` on a separate line before
   option description.
 * If all the option descriptions in the list are short one-liners,
   it's fine to put `versionadded` on the same line as the description.
 * If multiple option descriptions in close proximity would have
   the same ..versionadded directive, consider adding a single
   directive after the list, mentioning all added options.
 * For compact value lists and sub-option lists, put a single
  `versionadded` directive after the list mentioning all additions.
 * When a change is described in a single paragraph, put
   `versionadded` into that paragraph.
 * When only part of the paragraph has changed, separate the changed
   part if it doesn't break the flow. Otherwise, write a follow-up
   clarification paragraph and apply version directive to that.
 * When multiple version directives are close by, order earlier
   additions before later additions.
 * Indent related lists and code blocks to include them in the scope
   of `versionadded` directive.

Issue: #19715
This commit is contained in:
Nikita Nemkin
2020-11-08 01:30:30 +05:00
parent 63a1917d09
commit c705279bae
58 changed files with 925 additions and 420 deletions

View File

@@ -1,11 +1,12 @@
When a device link step is involved, which is controlled by .. versionadded:: 3.18
:prop_tgt:`CUDA_SEPARABLE_COMPILATION` and When a device link step is involved, which is controlled by
:prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties and policy :policy:`CMP0105`, :prop_tgt:`CUDA_SEPARABLE_COMPILATION` and
the raw options will be delivered to the host and device link steps (wrapped in :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties and policy :policy:`CMP0105`,
``-Xcompiler`` or equivalent for device link). Options wrapped with the raw options will be delivered to the host and device link steps (wrapped in
``$<DEVICE_LINK:...>`` ``-Xcompiler`` or equivalent for device link). Options wrapped with
:manual:`generator expression <cmake-generator-expressions(7)>` will be used ``$<DEVICE_LINK:...>``
only for the device link step. Options wrapped with ``$<HOST_LINK:...>`` :manual:`generator expression <cmake-generator-expressions(7)>` will be used
:manual:`generator expression <cmake-generator-expressions(7)>` will be used only for the device link step. Options wrapped with ``$<HOST_LINK:...>``
only for the host link step. :manual:`generator expression <cmake-generator-expressions(7)>` will be used
only for the host link step.

View File

@@ -33,9 +33,6 @@ of this command.
If the |SEARCH_XXX| is found the result is stored in the variable If the |SEARCH_XXX| is found the result is stored in the variable
and the search will not be repeated unless the variable is cleared. and the search will not be repeated unless the variable is cleared.
If nothing is found, the result will be ``<VAR>-NOTFOUND``. If nothing is found, the result will be ``<VAR>-NOTFOUND``.
The ``REQUIRED`` option stops processing with an error message if nothing
is found, otherwise the search will be attempted again the
next time |FIND_XXX| is invoked with the same variable.
Options include: Options include:
@@ -60,7 +57,11 @@ Options include:
Specify the documentation string for the ``<VAR>`` cache entry. Specify the documentation string for the ``<VAR>`` cache entry.
``REQUIRED`` ``REQUIRED``
Stop processing with an error message if nothing is found. .. versionadded:: 3.18
Stop processing with an error message if nothing is found, otherwise
the search will be attempted again the next time |FIND_XXX| is invoked
with the same variable.
If ``NO_DEFAULT_PATH`` is specified, then no additional paths are If ``NO_DEFAULT_PATH`` is specified, then no additional paths are
added to the search. added to the search.
@@ -84,20 +85,21 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
|prefix_XXX_SUBDIR| for each ``<prefix>`` in |prefix_XXX_SUBDIR| for each ``<prefix>`` in
:variable:`CMAKE_SYSTEM_PREFIX_PATH` :variable:`CMAKE_SYSTEM_PREFIX_PATH`
1. If called from within a find module or any other script loaded by a call to 1. .. versionadded:: 3.12
:command:`find_package(<PackageName>)`, search prefixes unique to the If called from within a find module or any other script loaded by a call to
current package being found. Specifically, look in the :command:`find_package(<PackageName>)`, search prefixes unique to the
:variable:`<PackageName>_ROOT` CMake variable and the current package being found. Specifically, look in the
:envvar:`<PackageName>_ROOT` environment variable. :variable:`<PackageName>_ROOT` CMake variable and the
The package root variables are maintained as a stack, so if called from :envvar:`<PackageName>_ROOT` environment variable.
nested find modules or config packages, root paths from the parent's find The package root variables are maintained as a stack, so if called from
module or config package will be searched after paths from the current nested find modules or config packages, root paths from the parent's find
module or package. In other words, the search order would be module or config package will be searched after paths from the current
``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``, module or package. In other words, the search order would be
``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc. ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``. This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
See policy :policy:`CMP0074`. the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
See policy :policy:`CMP0074`.
* |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX| * |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX|
@@ -151,6 +153,10 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
or in the short-hand version of the command. or in the short-hand version of the command.
These are typically hard-coded guesses. These are typically hard-coded guesses.
.. versionadded:: 3.16
Added ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable
various search locations.
.. |FIND_ARGS_XXX| replace:: <VAR> NAMES name .. |FIND_ARGS_XXX| replace:: <VAR> NAMES name
On macOS the :variable:`CMAKE_FIND_FRAMEWORK` and On macOS the :variable:`CMAKE_FIND_FRAMEWORK` and

View File

@@ -1,9 +1,11 @@
The final set of compile or link options used for a target is constructed by The final set of compile or link options used for a target is constructed by
accumulating options from the current target and the usage requirements of accumulating options from the current target and the usage requirements of
its dependencies. The set of options is de-duplicated to avoid repetition. its dependencies. The set of options is de-duplicated to avoid repetition.
While beneficial for individual options, the de-duplication step can break
up option groups. For example, ``-D A -D B`` becomes ``-D A B``. One may .. versionadded:: 3.12
specify a group of options using shell-like quoting along with a ``SHELL:`` While beneficial for individual options, the de-duplication step can break
prefix. The ``SHELL:`` prefix is dropped, and the rest of the option string up option groups. For example, ``-D A -D B`` becomes ``-D A B``. One may
is parsed using the :command:`separate_arguments` ``UNIX_COMMAND`` mode. specify a group of options using shell-like quoting along with a ``SHELL:``
For example, ``"SHELL:-D A" "SHELL:-D B"`` becomes ``-D A -D B``. prefix. The ``SHELL:`` prefix is dropped, and the rest of the option string
is parsed using the :command:`separate_arguments` ``UNIX_COMMAND`` mode.
For example, ``"SHELL:-D A" "SHELL:-D B"`` becomes ``-D A -D B``.

View File

@@ -51,6 +51,8 @@ The options are:
used in the future. used in the future.
``BYPRODUCTS`` ``BYPRODUCTS``
.. versionadded:: 3.2
Specify the files the command is expected to produce but whose Specify the files the command is expected to produce but whose
modification time may or may not be newer than the dependencies. modification time may or may not be newer than the dependencies.
If a byproduct name is a relative path it will be interpreted If a byproduct name is a relative path it will be interpreted
@@ -88,10 +90,11 @@ The options are:
* The target is not being cross-compiled (i.e. the * The target is not being cross-compiled (i.e. the
:variable:`CMAKE_CROSSCOMPILING` variable is not set to true). :variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
* The target is being cross-compiled and an emulator is provided (i.e. * .. versionadded:: 3.6
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set). The target is being cross-compiled and an emulator is provided (i.e.
In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
prepended to the command before the location of the target executable. In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
prepended to the command before the location of the target executable.
If neither of the above conditions are met, it is assumed that the If neither of the above conditions are met, it is assumed that the
command name is a program to be found on the ``PATH`` at build time. command name is a program to be found on the ``PATH`` at build time.
@@ -153,18 +156,23 @@ The options are:
If any dependency is an ``OUTPUT`` of another custom command in the same If any dependency is an ``OUTPUT`` of another custom command in the same
directory (``CMakeLists.txt`` file), CMake automatically brings the other directory (``CMakeLists.txt`` file), CMake automatically brings the other
custom command into the target in which this command is built. custom command into the target in which this command is built.
A target-level dependency is added if any dependency is listed as
``BYPRODUCTS`` of a target or any of its build events in the same .. versionadded:: 3.16
directory to ensure the byproducts will be available. A target-level dependency is added if any dependency is listed as
``BYPRODUCTS`` of a target or any of its build events in the same
directory to ensure the byproducts will be available.
If ``DEPENDS`` is not specified, the command will run whenever If ``DEPENDS`` is not specified, the command will run whenever
the ``OUTPUT`` is missing; if the command does not actually the ``OUTPUT`` is missing; if the command does not actually
create the ``OUTPUT``, the rule will always run. create the ``OUTPUT``, the rule will always run.
Arguments to ``DEPENDS`` may use .. versionadded:: 3.1
:manual:`generator expressions <cmake-generator-expressions(7)>`. Arguments to ``DEPENDS`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
``COMMAND_EXPAND_LISTS`` ``COMMAND_EXPAND_LISTS``
.. versionadded:: 3.8
Lists in ``COMMAND`` arguments will be expanded, including those Lists in ``COMMAND`` arguments will be expanded, including those
created with created with
:manual:`generator expressions <cmake-generator-expressions(7)>`, :manual:`generator expressions <cmake-generator-expressions(7)>`,
@@ -184,6 +192,8 @@ The options are:
only for Makefile generators and will be ignored by other generators. only for Makefile generators and will be ignored by other generators.
``JOB_POOL`` ``JOB_POOL``
.. versionadded:: 3.15
Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja` Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
generator. Incompatible with ``USES_TERMINAL``, which implies generator. Incompatible with ``USES_TERMINAL``, which implies
the ``console`` pool. the ``console`` pool.
@@ -211,6 +221,8 @@ The options are:
source file property. source file property.
``USES_TERMINAL`` ``USES_TERMINAL``
.. versionadded:: 3.2
The command will be given direct access to the terminal if possible. The command will be given direct access to the terminal if possible.
With the :generator:`Ninja` generator, this places the command in With the :generator:`Ninja` generator, this places the command in
the ``console`` :prop_gbl:`pool <JOB_POOLS>`. the ``console`` :prop_gbl:`pool <JOB_POOLS>`.
@@ -230,10 +242,13 @@ The options are:
If it is a relative path it will be interpreted relative to the If it is a relative path it will be interpreted relative to the
build tree directory corresponding to the current source directory. build tree directory corresponding to the current source directory.
Arguments to ``WORKING_DIRECTORY`` may use .. versionadded:: 3.13
:manual:`generator expressions <cmake-generator-expressions(7)>`. Arguments to ``WORKING_DIRECTORY`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
``DEPFILE`` ``DEPFILE``
.. versionadded:: 3.7
Specify a ``.d`` depfile for the :generator:`Ninja` generator. Specify a ``.d`` depfile for the :generator:`Ninja` generator.
A ``.d`` file holds dependencies usually emitted by the custom A ``.d`` file holds dependencies usually emitted by the custom
command itself. command itself.

View File

@@ -32,6 +32,8 @@ The options are:
called ``ALL``). called ``ALL``).
``BYPRODUCTS`` ``BYPRODUCTS``
.. versionadded:: 3.2
Specify the files the command is expected to produce but whose Specify the files the command is expected to produce but whose
modification time may or may not be updated on subsequent builds. modification time may or may not be updated on subsequent builds.
If a byproduct name is a relative path it will be interpreted If a byproduct name is a relative path it will be interpreted
@@ -67,10 +69,11 @@ The options are:
* The target is not being cross-compiled (i.e. the * The target is not being cross-compiled (i.e. the
:variable:`CMAKE_CROSSCOMPILING` variable is not set to true). :variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
* The target is being cross-compiled and an emulator is provided (i.e. * .. versionadded:: 3.6
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set). The target is being cross-compiled and an emulator is provided (i.e.
In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
prepended to the command before the location of the target executable. In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
prepended to the command before the location of the target executable.
If neither of the above conditions are met, it is assumed that the If neither of the above conditions are met, it is assumed that the
command name is a program to be found on the ``PATH`` at build time. command name is a program to be found on the ``PATH`` at build time.
@@ -103,14 +106,18 @@ The options are:
:command:`add_custom_command` command calls in the same directory :command:`add_custom_command` command calls in the same directory
(``CMakeLists.txt`` file). They will be brought up to date when (``CMakeLists.txt`` file). They will be brought up to date when
the target is built. the target is built.
A target-level dependency is added if any dependency is a byproduct
of a target or any of its build events in the same directory to ensure .. versionadded:: 3.16
the byproducts will be available before this target is built. A target-level dependency is added if any dependency is a byproduct
of a target or any of its build events in the same directory to ensure
the byproducts will be available before this target is built.
Use the :command:`add_dependencies` command to add dependencies Use the :command:`add_dependencies` command to add dependencies
on other targets. on other targets.
``COMMAND_EXPAND_LISTS`` ``COMMAND_EXPAND_LISTS``
.. versionadded:: 3.8
Lists in ``COMMAND`` arguments will be expanded, including those Lists in ``COMMAND`` arguments will be expanded, including those
created with created with
:manual:`generator expressions <cmake-generator-expressions(7)>`, :manual:`generator expressions <cmake-generator-expressions(7)>`,
@@ -119,6 +126,8 @@ The options are:
to be properly expanded. to be properly expanded.
``JOB_POOL`` ``JOB_POOL``
.. versionadded:: 3.15
Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja` Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
generator. Incompatible with ``USES_TERMINAL``, which implies generator. Incompatible with ``USES_TERMINAL``, which implies
the ``console`` pool. the ``console`` pool.
@@ -141,6 +150,8 @@ The options are:
tool-specific special characters. tool-specific special characters.
``USES_TERMINAL`` ``USES_TERMINAL``
.. versionadded:: 3.2
The command will be given direct access to the terminal if possible. The command will be given direct access to the terminal if possible.
With the :generator:`Ninja` generator, this places the command in With the :generator:`Ninja` generator, this places the command in
the ``console`` :prop_gbl:`pool <JOB_POOLS>`. the ``console`` :prop_gbl:`pool <JOB_POOLS>`.
@@ -150,5 +161,6 @@ The options are:
If it is a relative path it will be interpreted relative to the If it is a relative path it will be interpreted relative to the
build tree directory corresponding to the current source directory. build tree directory corresponding to the current source directory.
Arguments to ``WORKING_DIRECTORY`` may use .. versionadded:: 3.13
:manual:`generator expressions <cmake-generator-expressions(7)>`. Arguments to ``WORKING_DIRECTORY`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.

View File

@@ -17,6 +17,9 @@ Dependencies added to an :ref:`imported target <Imported Targets>`
or an :ref:`interface library <Interface Libraries>` are followed or an :ref:`interface library <Interface Libraries>` are followed
transitively in its place since the target itself does not build. transitively in its place since the target itself does not build.
.. versionadded:: 3.3
Allow adding dependencies to interface libraries.
See the ``DEPENDS`` option of :command:`add_custom_target` and See the ``DEPENDS`` option of :command:`add_custom_target` and
:command:`add_custom_command` commands for adding file-level :command:`add_custom_command` commands for adding file-level
dependencies in custom rules. See the :prop_sf:`OBJECT_DEPENDS` dependencies in custom rules. See the :prop_sf:`OBJECT_DEPENDS`

View File

@@ -17,13 +17,21 @@ Normal Executables
[source1] [source2 ...]) [source1] [source2 ...])
Adds an executable target called ``<name>`` to be built from the source Adds an executable target called ``<name>`` to be built from the source
files listed in the command invocation. (The source files can be omitted files listed in the command invocation. The
here if they are added later using :command:`target_sources`.) The
``<name>`` corresponds to the logical target name and must be globally ``<name>`` corresponds to the logical target name and must be globally
unique within a project. The actual file name of the executable built is unique within a project. The actual file name of the executable built is
constructed based on conventions of the native platform (such as constructed based on conventions of the native platform (such as
``<name>.exe`` or just ``<name>``). ``<name>.exe`` or just ``<name>``).
.. versionadded:: 3.1
Source arguments to ``add_executable`` may use "generator expressions" with
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions.
.. versionadded:: 3.11
The source files can be omitted if they are added later using
:command:`target_sources`.
By default the executable file will be created in the build tree By default the executable file will be created in the build tree
directory corresponding to the source tree directory in which the directory corresponding to the source tree directory in which the
command was invoked. See documentation of the command was invoked. See documentation of the
@@ -43,10 +51,8 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on
the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL` the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
target property for details. target property for details.
Source arguments to ``add_executable`` may use "generator expressions" with See the :manual:`cmake-buildsystem(7)` manual for more on defining
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` buildsystem properties.
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are
pre-processed, and you want to have the original sources reachable from pre-processed, and you want to have the original sources reachable from
@@ -85,10 +91,14 @@ be used to refer to ``<target>`` in subsequent commands. The ``<name>``
does not appear in the generated buildsystem as a make target. The does not appear in the generated buildsystem as a make target. The
``<target>`` may not be an ``ALIAS``. ``<target>`` may not be an ``ALIAS``.
An ``ALIAS`` to a non-``GLOBAL`` :ref:`Imported Target <Imported Targets>` .. versionadded:: 3.11
has scope in the directory in which the alias is created and below. An ``ALIAS`` can target a ``GLOBAL`` :ref:`Imported Target <Imported Targets>`
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
alias is global or not. .. versionadded:: 3.18
An ``ALIAS`` can target a non-``GLOBAL`` Imported Target. Such alias is
scoped to the directory in which it is created and subdirectories.
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
alias is global or not.
``ALIAS`` targets can be used as targets to read properties ``ALIAS`` targets can be used as targets to read properties
from, executables for custom commands and custom targets. They can also be from, executables for custom commands and custom targets. They can also be

View File

@@ -17,13 +17,21 @@ Normal Libraries
[<source>...]) [<source>...])
Adds a library target called ``<name>`` to be built from the source files Adds a library target called ``<name>`` to be built from the source files
listed in the command invocation. (The source files can be omitted here listed in the command invocation. The ``<name>``
if they are added later using :command:`target_sources`.) The ``<name>``
corresponds to the logical target name and must be globally unique within corresponds to the logical target name and must be globally unique within
a project. The actual file name of the library built is constructed based a project. The actual file name of the library built is constructed based
on conventions of the native platform (such as ``lib<name>.a`` or on conventions of the native platform (such as ``lib<name>.a`` or
``<name>.lib``). ``<name>.lib``).
.. versionadded:: 3.1
Source arguments to ``add_library`` may use "generator expressions" with
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions.
.. versionadded:: 3.11
The source files can be omitted if they are added later using
:command:`target_sources`.
``STATIC``, ``SHARED``, or ``MODULE`` may be given to specify the type of ``STATIC``, ``SHARED``, or ``MODULE`` may be given to specify the type of
library to be created. ``STATIC`` libraries are archives of object files library to be created. ``STATIC`` libraries are archives of object files
for use when linking other targets. ``SHARED`` libraries are linked for use when linking other targets. ``SHARED`` libraries are linked
@@ -34,9 +42,13 @@ type is ``STATIC`` or ``SHARED`` based on whether the current value of the
variable :variable:`BUILD_SHARED_LIBS` is ``ON``. For ``SHARED`` and variable :variable:`BUILD_SHARED_LIBS` is ``ON``. For ``SHARED`` and
``MODULE`` libraries the :prop_tgt:`POSITION_INDEPENDENT_CODE` target ``MODULE`` libraries the :prop_tgt:`POSITION_INDEPENDENT_CODE` target
property is set to ``ON`` automatically. property is set to ``ON`` automatically.
A ``SHARED`` or ``STATIC`` library may be marked with the :prop_tgt:`FRAMEWORK` A ``SHARED`` library may be marked with the :prop_tgt:`FRAMEWORK`
target property to create an macOS Framework. target property to create an macOS Framework.
.. versionadded:: 3.8
A ``STATIC`` library may be marked with the :prop_tgt:`FRAMEWORK`
target property to create a static Framework.
If a library does not export any symbols, it must not be declared as a If a library does not export any symbols, it must not be declared as a
``SHARED`` library. For example, a Windows resource DLL or a managed C++/CLI ``SHARED`` library. For example, a Windows resource DLL or a managed C++/CLI
DLL that exports no unmanaged symbols would need to be a ``MODULE`` library. DLL that exports no unmanaged symbols would need to be a ``MODULE`` library.
@@ -55,10 +67,8 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on
the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL` the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
target property for details. target property for details.
Source arguments to ``add_library`` may use "generator expressions" with See the :manual:`cmake-buildsystem(7)` manual for more on defining
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` buildsystem properties.
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are
pre-processed, and you want to have the original sources reachable from pre-processed, and you want to have the original sources reachable from
@@ -93,6 +103,9 @@ systems (such as Xcode) may not like targets that have only object files, so
consider adding at least one real source file to any target that references consider adding at least one real source file to any target that references
``$<TARGET_OBJECTS:objlib>``. ``$<TARGET_OBJECTS:objlib>``.
.. versionadded:: 3.12
Object libraries can be linked to with :command:`target_link_libraries`.
Interface Libraries Interface Libraries
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
@@ -121,23 +134,28 @@ like any other target.
An interface library created with the above signature has no source files An interface library created with the above signature has no source files
itself and is not included as a target in the generated buildsystem. itself and is not included as a target in the generated buildsystem.
Since CMake 3.19, an interface library target may be created with .. versionadded:: 3.15
source files: An interface library can have :prop_tgt:`PUBLIC_HEADER` and
:prop_tgt:`PRIVATE_HEADER` properties. The headers specified by those
properties can be installed using the :command:`install(TARGETS)` command.
.. code-block:: cmake .. versionadded:: 3.19
An interface library target may be created with source files:
add_library(<name> INTERFACE [<source>...] [EXCLUDE_FROM_ALL]) .. code-block:: cmake
Source files may be listed directly in the ``add_library`` call or added add_library(<name> INTERFACE [<source>...] [EXCLUDE_FROM_ALL])
later by calls to :command:`target_sources` with the ``PRIVATE`` or
``PUBLIC`` keywords.
If an interface library has source files (i.e. the :prop_tgt:`SOURCES` Source files may be listed directly in the ``add_library`` call or added
target property is set), it will appear in the generated buildsystem later by calls to :command:`target_sources` with the ``PRIVATE`` or
as a build target much like a target defined by the ``PUBLIC`` keywords.
:command:`add_custom_target` command. It does not compile any sources,
but does contain build rules for custom commands created by the If an interface library has source files (i.e. the :prop_tgt:`SOURCES`
:command:`add_custom_command` command. target property is set), it will appear in the generated buildsystem
as a build target much like a target defined by the
:command:`add_custom_target` command. It does not compile any sources,
but does contain build rules for custom commands created by the
:command:`add_custom_command` command.
.. note:: .. note::
In most command signatures where the ``INTERFACE`` keyword appears, In most command signatures where the ``INTERFACE`` keyword appears,
@@ -211,10 +229,14 @@ used to refer to ``<target>`` in subsequent commands. The ``<name>`` does
not appear in the generated buildsystem as a make target. The ``<target>`` not appear in the generated buildsystem as a make target. The ``<target>``
may not be an ``ALIAS``. may not be an ``ALIAS``.
An ``ALIAS`` to a non-``GLOBAL`` :ref:`Imported Target <Imported Targets>` .. versionadded:: 3.11
has scope in the directory in which the alias is created and below. An ``ALIAS`` can target a ``GLOBAL`` :ref:`Imported Target <Imported Targets>`
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
alias is global or not. .. versionadded:: 3.18
An ``ALIAS`` can target a non-``GLOBAL`` Imported Target. Such alias is
scoped to the directory in which it is created and below.
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
alias is global or not.
``ALIAS`` targets can be used as linkable targets and as targets to ``ALIAS`` targets can be used as linkable targets and as targets to
read properties from. They can also be tested for existence with the read properties from. They can also be tested for existence with the

View File

@@ -31,6 +31,8 @@ if necessary. See policy :policy:`CMP0110`. The options are:
current source directory. current source directory.
``COMMAND_EXPAND_LISTS`` ``COMMAND_EXPAND_LISTS``
.. versionadded:: 3.16
Lists in ``COMMAND`` arguments will be expanded, including those Lists in ``COMMAND`` arguments will be expanded, including those
created with created with
:manual:`generator expressions <cmake-generator-expressions(7)>`. :manual:`generator expressions <cmake-generator-expressions(7)>`.
@@ -43,6 +45,9 @@ unless the :prop_test:`PASS_REGULAR_EXPRESSION`,
:prop_test:`FAIL_REGULAR_EXPRESSION` or :prop_test:`FAIL_REGULAR_EXPRESSION` or
:prop_test:`SKIP_REGULAR_EXPRESSION` test property is used. :prop_test:`SKIP_REGULAR_EXPRESSION` test property is used.
.. versionadded:: 3.16
Added :prop_test:`SKIP_REGULAR_EXPRESSION` property.
The ``COMMAND`` and ``WORKING_DIRECTORY`` options may use "generator The ``COMMAND`` and ``WORKING_DIRECTORY`` options may use "generator
expressions" with the syntax ``$<...>``. See the expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions. :manual:`cmake-generator-expressions(7)` manual for available expressions.

View File

@@ -24,6 +24,14 @@ Key Description
``AVAILABLE_VIRTUAL_MEMORY`` Available virtual memory in MiB [#mebibytes]_ ``AVAILABLE_VIRTUAL_MEMORY`` Available virtual memory in MiB [#mebibytes]_
``TOTAL_PHYSICAL_MEMORY`` Total physical memory in MiB [#mebibytes]_ ``TOTAL_PHYSICAL_MEMORY`` Total physical memory in MiB [#mebibytes]_
``AVAILABLE_PHYSICAL_MEMORY`` Available physical memory in MiB [#mebibytes]_ ``AVAILABLE_PHYSICAL_MEMORY`` Available physical memory in MiB [#mebibytes]_
============================= ================================================
.. versionadded:: 3.10
Additional ``<key>`` values are available:
============================= ================================================
Key Description
============================= ================================================
``IS_64BIT`` One if processor is 64Bit ``IS_64BIT`` One if processor is 64Bit
``HAS_FPU`` One if processor has floating point unit ``HAS_FPU`` One if processor has floating point unit
``HAS_MMX`` One if processor supports MMX instructions ``HAS_MMX`` One if processor supports MMX instructions

View File

@@ -7,6 +7,9 @@ Require a minimum version of cmake.
cmake_minimum_required(VERSION <min>[...<max>] [FATAL_ERROR]) cmake_minimum_required(VERSION <min>[...<max>] [FATAL_ERROR])
.. versionadded:: 3.12
The optional ``<max>`` version.
Sets the minimum required version of cmake for a project. Sets the minimum required version of cmake for a project.
Also updates the policy settings as explained below. Also updates the policy settings as explained below.

View File

@@ -21,11 +21,12 @@ respective options.
The first signature reads processes arguments passed in the ``<args>...``. The first signature reads processes arguments passed in the ``<args>...``.
This may be used in either a :command:`macro` or a :command:`function`. This may be used in either a :command:`macro` or a :command:`function`.
The ``PARSE_ARGV`` signature is only for use in a :command:`function` .. versionadded:: 3.7
body. In this case the arguments that are parsed come from the The ``PARSE_ARGV`` signature is only for use in a :command:`function`
``ARGV#`` variables of the calling function. The parsing starts with body. In this case the arguments that are parsed come from the
the ``<N>``-th argument, where ``<N>`` is an unsigned integer. This allows for ``ARGV#`` variables of the calling function. The parsing starts with
the values to have special characters like ``;`` in them. the ``<N>``-th argument, where ``<N>`` is an unsigned integer.
This allows for the values to have special characters like ``;`` in them.
The ``<options>`` argument contains all options for the respective macro, The ``<options>`` argument contains all options for the respective macro,
i.e. keywords which can be used when calling the macro without any value i.e. keywords which can be used when calling the macro without any value
@@ -40,12 +41,11 @@ The ``<multi_value_keywords>`` argument contains all keywords for this
macro which can be followed by more than one value, like e.g. the macro which can be followed by more than one value, like e.g. the
``TARGETS`` or ``FILES`` keywords of the :command:`install` command. ``TARGETS`` or ``FILES`` keywords of the :command:`install` command.
.. note:: .. versionadded:: 3.5
All keywords shall be unique. I.e. every keyword shall only be specified
All keywords shall be unique. I.e. every keyword shall only be specified once in either ``<options>``, ``<one_value_keywords>`` or
once in either ``<options>``, ``<one_value_keywords>`` or ``<multi_value_keywords>``. A warning will be emitted if uniqueness is
``<multi_value_keywords>``. A warning will be emitted if uniqueness is violated.
violated.
When done, ``cmake_parse_arguments`` will consider for each of the When done, ``cmake_parse_arguments`` will consider for each of the
keywords listed in ``<options>``, ``<one_value_keywords>`` and keywords listed in ``<options>``, ``<one_value_keywords>`` and
@@ -61,10 +61,12 @@ All remaining arguments are collected in a variable
were recognized. This can be checked afterwards to see were recognized. This can be checked afterwards to see
whether your macro was called with unrecognized parameters. whether your macro was called with unrecognized parameters.
``<one_value_keywords>`` and ``<multi_value_keywords>`` that were given no .. versionadded:: 3.15
values at all are collected in a variable ``<prefix>_KEYWORDS_MISSING_VALUES`` ``<one_value_keywords>`` and ``<multi_value_keywords>`` that were given no
that will be undefined if all keywords received values. This can be checked values at all are collected in a variable
to see if there were keywords without any values given. ``<prefix>_KEYWORDS_MISSING_VALUES`` that will be undefined if all keywords
received values. This can be checked to see if there were keywords without
any values given.
Consider the following example macro, ``my_install()``, which takes similar Consider the following example macro, ``my_install()``, which takes similar
arguments to the real :command:`install` command: arguments to the real :command:`install` command:

View File

@@ -28,6 +28,9 @@ encourage projects to set policies based on CMake versions:
cmake_policy(VERSION <min>[...<max>]) cmake_policy(VERSION <min>[...<max>])
.. versionadded:: 3.12
The optional ``<max>`` version.
``<min>`` and the optional ``<max>`` are each CMake versions of the form ``<min>`` and the optional ``<max>`` are each CMake versions of the form
``major.minor[.patch[.tweak]]``, and the ``...`` is literal. The ``<min>`` ``major.minor[.patch[.tweak]]``, and the ``...`` is literal. The ``<min>``
version must be at least ``2.4`` and at most the running version of CMake. version must be at least ``2.4`` and at most the running version of CMake.

View File

@@ -38,22 +38,24 @@ a false constant by the :command:`if` command. The "..." content on the
line after the variable name, if any, is processed as above. line after the variable name, if any, is processed as above.
Input file lines of the form ``#cmakedefine01 VAR`` will be replaced with Input file lines of the form ``#cmakedefine01 VAR`` will be replaced with
either ``#define VAR 1`` or ``#define VAR 0`` similarly. either ``#define VAR 1`` or ``#define VAR 0`` similarly.
The result lines (with the exception of the ``#undef`` comments) can be
indented using spaces and/or tabs between the ``#`` character
and the ``cmakedefine`` or ``cmakedefine01`` words. This whitespace
indentation will be preserved in the output lines:
.. code-block:: c .. versionadded:: 3.10
The result lines (with the exception of the ``#undef`` comments) can be
indented using spaces and/or tabs between the ``#`` character
and the ``cmakedefine`` or ``cmakedefine01`` words. This whitespace
indentation will be preserved in the output lines:
# cmakedefine VAR .. code-block:: c
# cmakedefine01 VAR
will be replaced, if ``VAR`` is defined, with # cmakedefine VAR
# cmakedefine01 VAR
.. code-block:: c will be replaced, if ``VAR`` is defined, with
# define VAR .. code-block:: c
# define VAR 1
# define VAR
# define VAR 1
If the input file is modified the build system will re-run CMake to If the input file is modified the build system will re-run CMake to
re-configure the file and generate the build system again. re-configure the file and generate the build system again.
@@ -88,11 +90,15 @@ The arguments are:
This is useful for configuring scripts that use ``${VAR}`` syntax. This is useful for configuring scripts that use ``${VAR}`` syntax.
``NO_SOURCE_PERMISSIONS`` ``NO_SOURCE_PERMISSIONS``
.. versionadded:: 3.19
Does not transfer the file permissions of the original file to the copy. Does not transfer the file permissions of the original file to the copy.
The copied file permissions default to the standard 644 value The copied file permissions default to the standard 644 value
(-rw-r--r--). (-rw-r--r--).
``USE_SOURCE_PERMISSIONS`` ``USE_SOURCE_PERMISSIONS``
.. versionadded:: 3.20
Transfer the file permissions of the original file to the output file. Transfer the file permissions of the original file to the output file.
``NEWLINE_STYLE <style>`` ``NEWLINE_STYLE <style>``

View File

@@ -50,7 +50,10 @@ The options are:
for an example. for an example.
``PROJECT_NAME <project-name>`` ``PROJECT_NAME <project-name>``
Ignored. This was once used but is no longer needed. Ignored since CMake 3.0.
.. versionadded:: 3.14
This value is no longer required.
``TARGET <target-name>`` ``TARGET <target-name>``
Specify the name of a target to build. If not specified the Specify the name of a target to build. If not specified the
@@ -68,10 +71,14 @@ The options are:
Store the return value of the native build tool in the given variable. Store the return value of the native build tool in the given variable.
``CAPTURE_CMAKE_ERROR <result-var>`` ``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
Store in the ``<result-var>`` variable -1 if there are any errors running Store in the ``<result-var>`` variable -1 if there are any errors running
the command and prevent ctest from returning non-zero if an error occurs. the command and prevent ctest from returning non-zero if an error occurs.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error output that would have been Suppress any CTest-specific non-error output that would have been
printed to the console otherwise. The summary of warnings / errors, printed to the console otherwise. The summary of warnings / errors,
as well as the output from the native build tool is unaffected by as well as the output from the native build tool is unaffected by

View File

@@ -37,10 +37,14 @@ The options are:
configuration tool. configuration tool.
``CAPTURE_CMAKE_ERROR <result-var>`` ``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
Store in the ``<result-var>`` variable -1 if there are any errors running Store in the ``<result-var>`` variable -1 if there are any errors running
the command and prevent ctest from returning non-zero if an error occurs. the command and prevent ctest from returning non-zero if an error occurs.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error messages that would have Suppress any CTest-specific non-error messages that would have
otherwise been printed to the console. Output from the underlying otherwise been printed to the console. Output from the underlying
configure command is not affected. configure command is not affected.

View File

@@ -37,10 +37,14 @@ The options are:
ran without error and non-zero otherwise. ran without error and non-zero otherwise.
``CAPTURE_CMAKE_ERROR <result-var>`` ``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
Store in the ``<result-var>`` variable -1 if there are any errors running Store in the ``<result-var>`` variable -1 if there are any errors running
the command and prevent ctest from returning non-zero if an error occurs. the command and prevent ctest from returning non-zero if an error occurs.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error output that would have been Suppress any CTest-specific non-error output that would have been
printed to the console otherwise. The summary indicating how many printed to the console otherwise. The summary indicating how many
lines of code were covered is unaffected by this option. lines of code were covered is unaffected by this option.

View File

@@ -35,4 +35,6 @@ Most options are the same as those for the :command:`ctest_test` command.
The options unique to this command are: The options unique to this command are:
``DEFECT_COUNT <defect-count-var>`` ``DEFECT_COUNT <defect-count-var>``
.. versionadded:: 3.8
Store in the ``<defect-count-var>`` the number of defects found. Store in the ``<defect-count-var>`` the number of defects found.

View File

@@ -29,8 +29,11 @@ The parameters are as follows:
``GROUP <group>`` ``GROUP <group>``
If ``GROUP`` is used, the submissions will go to the specified group on the If ``GROUP`` is used, the submissions will go to the specified group on the
CDash server. If no ``GROUP`` is specified, the name of the model is used by CDash server. If no ``GROUP`` is specified, the name of the model is used by
default. This replaces the deprecated option ``TRACK``. Despite the name default.
change its behavior is unchanged.
.. versionadded:: 3.16
This replaces the deprecated option ``TRACK``. Despite the name
change its behavior is unchanged.
``APPEND`` ``APPEND``
If ``APPEND`` is used, the existing ``TAG`` is used rather than creating a new If ``APPEND`` is used, the existing ``TAG`` is used rather than creating a new
@@ -56,6 +59,8 @@ The parameters are as follows:
new model and group will be used. new model and group will be used.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
If ``QUIET`` is used, CTest will suppress any non-error messages that it If ``QUIET`` is used, CTest will suppress any non-error messages that it
otherwise would have printed to the console. otherwise would have printed to the console.

View File

@@ -42,14 +42,20 @@ The options are:
Each individual file must exist at the time of the call. Each individual file must exist at the time of the call.
``SUBMIT_URL <url>`` ``SUBMIT_URL <url>``
.. versionadded:: 3.14
The ``http`` or ``https`` URL of the dashboard server to send the submission The ``http`` or ``https`` URL of the dashboard server to send the submission
to. If not given, the :variable:`CTEST_SUBMIT_URL` variable is used. to. If not given, the :variable:`CTEST_SUBMIT_URL` variable is used.
``BUILD_ID <result-var>`` ``BUILD_ID <result-var>``
.. versionadded:: 3.15
Store in the ``<result-var>`` variable the ID assigned to this build by Store in the ``<result-var>`` variable the ID assigned to this build by
CDash. CDash.
``HTTPHEADER <HTTP-header>`` ``HTTPHEADER <HTTP-header>``
.. versionadded:: 3.9
Specify HTTP header to be included in the request to CDash during submission. Specify HTTP header to be included in the request to CDash during submission.
For example, CDash can be configured to only accept submissions from For example, CDash can be configured to only accept submissions from
authenticated clients. In this case, you should provide a bearer token in your authenticated clients. In this case, you should provide a bearer token in your
@@ -73,20 +79,27 @@ The options are:
non-zero on failure. non-zero on failure.
``CAPTURE_CMAKE_ERROR <result-var>`` ``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.13
Store in the ``<result-var>`` variable -1 if there are any errors running Store in the ``<result-var>`` variable -1 if there are any errors running
the command and prevent ctest from returning non-zero if an error occurs. the command and prevent ctest from returning non-zero if an error occurs.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
Suppress all non-error messages that would have otherwise been Suppress all non-error messages that would have otherwise been
printed to the console. printed to the console.
Submit to CDash Upload API Submit to CDash Upload API
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.2
:: ::
ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>] ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>]
[SUBMIT_URL <url>] [SUBMIT_URL <url>]
[BUILD_ID <result-var>]
[HTTPHEADER <header>] [HTTPHEADER <header>]
[RETRY_COUNT <count>] [RETRY_COUNT <count>]
[RETRY_DELAY <delay>] [RETRY_DELAY <delay>]
@@ -99,6 +112,19 @@ with a content hash of the file. If CDash does not already have the file,
then it is uploaded. Along with the file, a CDash type string is specified then it is uploaded. Along with the file, a CDash type string is specified
to tell CDash which handler to use to process the data. to tell CDash which handler to use to process the data.
This signature accepts the ``SUBMIT_URL``, ``BUILD_ID``, ``HTTPHEADER``, This signature interprets options in the same way as the first one.
``RETRY_COUNT``, ``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options
as described above. .. versionadded:: 3.8
Added ``RETRY_COUNT``, ``RETRY_DELAY``, ``QUIET`` options.
.. versionadded:: 3.9
Added ``HTTPHEADER`` option.
.. versionadded:: 3.13
Added ``RETURN_VALUE`` option.
.. versionadded:: 3.14
Added ``SUBMIT_URL`` option.
.. versionadded:: 3.15
Added ``BUILD_ID`` option.

View File

@@ -68,6 +68,8 @@ The options are:
Tests not matching this expression are excluded. Tests not matching this expression are excluded.
``EXCLUDE_FIXTURE <regex>`` ``EXCLUDE_FIXTURE <regex>``
.. versionadded:: 3.7
If a test in the set of tests to be executed requires a particular fixture, If a test in the set of tests to be executed requires a particular fixture,
that fixture's setup and cleanup tests would normally be added to the test that fixture's setup and cleanup tests would normally be added to the test
set automatically. This option prevents adding setup or cleanup tests for set automatically. This option prevents adding setup or cleanup tests for
@@ -76,9 +78,13 @@ The options are:
setup tests that fail. setup tests that fail.
``EXCLUDE_FIXTURE_SETUP <regex>`` ``EXCLUDE_FIXTURE_SETUP <regex>``
.. versionadded:: 3.7
Same as ``EXCLUDE_FIXTURE`` except only matching setup tests are excluded. Same as ``EXCLUDE_FIXTURE`` except only matching setup tests are excluded.
``EXCLUDE_FIXTURE_CLEANUP <regex>`` ``EXCLUDE_FIXTURE_CLEANUP <regex>``
.. versionadded:: 3.7
Same as ``EXCLUDE_FIXTURE`` except only matching cleanup tests are excluded. Same as ``EXCLUDE_FIXTURE`` except only matching cleanup tests are excluded.
``PARALLEL_LEVEL <level>`` ``PARALLEL_LEVEL <level>``
@@ -86,11 +92,15 @@ The options are:
be run in parallel. be run in parallel.
``RESOURCE_SPEC_FILE <file>`` ``RESOURCE_SPEC_FILE <file>``
.. versionadded:: 3.16
Specify a Specify a
:ref:`resource specification file <ctest-resource-specification-file>`. See :ref:`resource specification file <ctest-resource-specification-file>`. See
:ref:`ctest-resource-allocation` for more information. :ref:`ctest-resource-allocation` for more information.
``TEST_LOAD <threshold>`` ``TEST_LOAD <threshold>``
.. versionadded:: 3.4
While running tests in parallel, try not to start tests when they While running tests in parallel, try not to start tests when they
may cause the CPU load to pass above a given threshold. If not may cause the CPU load to pass above a given threshold. If not
specified the :variable:`CTEST_TEST_LOAD` variable will be checked, specified the :variable:`CTEST_TEST_LOAD` variable will be checked,
@@ -98,6 +108,8 @@ The options are:
See also the ``TestLoad`` setting in the :ref:`CTest Test Step`. See also the ``TestLoad`` setting in the :ref:`CTest Test Step`.
``REPEAT <mode>:<n>`` ``REPEAT <mode>:<n>``
.. versionadded:: 3.17
Run tests repeatedly based on the given ``<mode>`` up to ``<n>`` times. Run tests repeatedly based on the given ``<mode>`` up to ``<n>`` times.
The modes are: The modes are:
@@ -121,6 +133,8 @@ The options are:
implicit test dependencies. implicit test dependencies.
``STOP_ON_FAILURE`` ``STOP_ON_FAILURE``
.. versionadded:: 3.18
Stop the execution of the tests once one has failed. Stop the execution of the tests once one has failed.
``STOP_TIME <time-of-day>`` ``STOP_TIME <time-of-day>``
@@ -131,10 +145,14 @@ The options are:
Store non-zero if anything went wrong. Store non-zero if anything went wrong.
``CAPTURE_CMAKE_ERROR <result-var>`` ``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
Store in the ``<result-var>`` variable -1 if there are any errors running Store in the ``<result-var>`` variable -1 if there are any errors running
the command and prevent ctest from returning non-zero if an error occurs. the command and prevent ctest from returning non-zero if an error occurs.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error messages that would have otherwise Suppress any CTest-specific non-error messages that would have otherwise
been printed to the console. Output from the underlying test command is not been printed to the console. Output from the underlying test command is not
affected. Summary info detailing the percentage of passing tests is also affected. Summary info detailing the percentage of passing tests is also

View File

@@ -24,10 +24,14 @@ The options are:
updated or ``-1`` on error. updated or ``-1`` on error.
``CAPTURE_CMAKE_ERROR <result-var>`` ``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.13
Store in the ``<result-var>`` variable -1 if there are any errors running Store in the ``<result-var>`` variable -1 if there are any errors running
the command and prevent ctest from returning non-zero if an error occurs. the command and prevent ctest from returning non-zero if an error occurs.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
Tell CTest to suppress most non-error messages that it would Tell CTest to suppress most non-error messages that it would
have otherwise printed to the console. CTest will still report have otherwise printed to the console. CTest will still report
the new revision of the repository and any conflicting files the new revision of the repository and any conflicting files

View File

@@ -14,9 +14,13 @@ The options are:
dashboard server. dashboard server.
``QUIET`` ``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error output that would have been Suppress any CTest-specific non-error output that would have been
printed to the console otherwise. printed to the console otherwise.
``CAPTURE_CMAKE_ERROR <result-var>`` ``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
Store in the ``<result-var>`` variable -1 if there are any errors running Store in the ``<result-var>`` variable -1 if there are any errors running
the command and prevent ctest from returning non-zero if an error occurs. the command and prevent ctest from returning non-zero if an error occurs.

View File

@@ -12,6 +12,15 @@ variables that are created by the project command. Example languages
are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``, are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``,
``ISPC``, and ``ASM``. ``ISPC``, and ``ASM``.
.. versionadded:: 3.8
Added ``CUDA`` support.
.. versionadded:: 3.16
Added ``OBJC`` and ``OBJCXX`` support.
.. versionadded:: 3.18
Added ``ISPC`` support.
If enabling ``ASM``, enable it last so that CMake can check whether If enabling ``ASM``, enable it last so that CMake can check whether
compilers for other languages like ``C`` work for assembly too. compilers for other languages like ``C`` work for assembly too.

View File

@@ -62,6 +62,8 @@ Options:
describing an error condition. describing an error condition.
``RESULTS_VARIABLE <variable>`` ``RESULTS_VARIABLE <variable>``
.. versionadded:: 3.10
The variable will be set to contain the result of all processes as a The variable will be set to contain the result of all processes as a
:ref:`semicolon-separated list <CMake Language Lists>`, in order of the :ref:`semicolon-separated list <CMake Language Lists>`, in order of the
given ``COMMAND`` arguments. Each entry will be an integer return code given ``COMMAND`` arguments. Each entry will be an integer return code
@@ -75,19 +77,26 @@ Options:
``INPUT_FILE, OUTPUT_FILE``, ``ERROR_FILE`` ``INPUT_FILE, OUTPUT_FILE``, ``ERROR_FILE``
The file named will be attached to the standard input of the first The file named will be attached to the standard input of the first
process, standard output of the last process, or standard error of process, standard output of the last process, or standard error of
all processes, respectively. If the same file is named for both all processes, respectively.
output and error then it will be used for both.
.. versionadded:: 3.3
If the same file is named for both output and error then it will be used
for both.
``OUTPUT_QUIET``, ``ERROR_QUIET`` ``OUTPUT_QUIET``, ``ERROR_QUIET``
The standard output or standard error results will be quietly ignored. The standard output or standard error results will be quietly ignored.
``COMMAND_ECHO <where>`` ``COMMAND_ECHO <where>``
.. versionadded:: 3.15
The command being run will be echo'ed to ``<where>`` with ``<where>`` The command being run will be echo'ed to ``<where>`` with ``<where>``
being set to one of ``STDERR``, ``STDOUT`` or ``NONE``. being set to one of ``STDERR``, ``STDOUT`` or ``NONE``.
See the :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ECHO` variable for a way See the :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ECHO` variable for a way
to control the default behavior when this option is not present. to control the default behavior when this option is not present.
``ENCODING <name>`` ``ENCODING <name>``
.. versionadded:: 3.8
On Windows, the encoding that is used to decode output from the process. On Windows, the encoding that is used to decode output from the process.
Ignored on other platforms. Ignored on other platforms.
Valid encoding names are: Valid encoding names are:
@@ -104,11 +113,15 @@ Options:
``OEM`` ``OEM``
Use the original equipment manufacturer (OEM) code page. Use the original equipment manufacturer (OEM) code page.
``UTF8`` or ``UTF-8`` ``UTF8`` or ``UTF-8``
Use the UTF-8 codepage. Prior to CMake 3.11.0, only ``UTF8`` was accepted Use the UTF-8 codepage.
for this encoding. In CMake 3.11.0, ``UTF-8`` was added for consistency with
the `UTF-8 RFC <https://www.ietf.org/rfc/rfc3629>`_ naming convention. .. versionadded:: 3.11
Accept ``UTF-8`` spelling for consistency with the
`UTF-8 RFC <https://www.ietf.org/rfc/rfc3629>`_ naming convention.
``ECHO_OUTPUT_VARIABLE``, ``ECHO_ERROR_VARIABLE`` ``ECHO_OUTPUT_VARIABLE``, ``ECHO_ERROR_VARIABLE``
.. versionadded:: 3.18
The standard output or standard error will not be exclusively redirected to The standard output or standard error will not be exclusively redirected to
the configured variables. the configured variables.
@@ -118,6 +131,8 @@ Options:
This is analogous to the ``tee`` Unix command. This is analogous to the ``tee`` Unix command.
``COMMAND_ERROR_IS_FATAL <ANY|LAST>`` ``COMMAND_ERROR_IS_FATAL <ANY|LAST>``
.. versionadded:: 3.19
The option following ``COMMAND_ERROR_IS_FATAL`` determines the behavior when The option following ``COMMAND_ERROR_IS_FATAL`` determines the behavior when
an error is encountered: an error is encountered:

View File

@@ -64,16 +64,23 @@ build tree. In some cases, for example for packaging and for system
wide installations, it is not desirable to write the user package wide installations, it is not desirable to write the user package
registry. registry.
By default the ``export(PACKAGE)`` command does nothing (see policy .. versionadded:: 3.1
:policy:`CMP0090`) because populating the user package registry has effects If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable
outside the source and build trees. Set the is enabled, the ``export(PACKAGE)`` command will do nothing.
:variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable to add build directories to
the CMake user package registry. .. versionadded:: 3.15
By default the ``export(PACKAGE)`` command does nothing (see policy
:policy:`CMP0090`) because populating the user package registry has effects
outside the source and build trees. Set the
:variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable to add build directories
to the CMake user package registry.
.. code-block:: cmake .. code-block:: cmake
export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>]) export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>])
.. versionadded:: 3.7
This signature exports cmake built targets to the android ndk build system This signature exports cmake built targets to the android ndk build system
by creating an Android.mk file that references the prebuilt targets. The by creating an Android.mk file that references the prebuilt targets. The
Android NDK supports the use of prebuilt libraries, both static and shared. Android NDK supports the use of prebuilt libraries, both static and shared.

View File

@@ -118,10 +118,15 @@ Parse a list of ASCII strings from ``<filename>`` and store it in
Consider only strings that match the given regular expression. Consider only strings that match the given regular expression.
``ENCODING <encoding-type>`` ``ENCODING <encoding-type>``
.. versionadded:: 3.1
Consider strings of a given encoding. Currently supported encodings are: Consider strings of a given encoding. Currently supported encodings are:
UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE. If the ENCODING option ``UTF-8``, ``UTF-16LE``, ``UTF-16BE``, ``UTF-32LE``, ``UTF-32BE``.
is not provided and the file has a Byte Order Mark, the ENCODING option If the ``ENCODING`` option is not provided and the file has a Byte Order Mark,
will be defaulted to respect the Byte Order Mark. the ``ENCODING`` option will be defaulted to respect the Byte Order Mark.
.. versionadded:: 3.2
Added ``UTF-16LE``, ``UTF-16BE``, ``UTF-32LE``, ``UTF-32BE`` encodings.
For example, the code For example, the code
@@ -175,6 +180,8 @@ the ``<format>`` and ``UTC`` options.
[POST_EXCLUDE_REGEXES [<regexes>...]] [POST_EXCLUDE_REGEXES [<regexes>...]]
) )
.. versionadded:: 3.16
Recursively get the list of libraries depended on by the given files. Recursively get the list of libraries depended on by the given files.
Please note that this sub-command is not intended to be used in project mode. Please note that this sub-command is not intended to be used in project mode.
@@ -423,6 +430,9 @@ dependency resolution:
If this variable is not specified, it is determined by the value of If this variable is not specified, it is determined by the value of
``CMAKE_OBJDUMP`` if set, else by system introspection. ``CMAKE_OBJDUMP`` if set, else by system introspection.
.. versionadded:: 3.18
Use ``CMAKE_OBJDUMP`` if set.
Writing Writing
^^^^^^^ ^^^^^^^
@@ -451,6 +461,8 @@ to update the file only when its content changes.
file(TOUCH [<files>...]) file(TOUCH [<files>...])
file(TOUCH_NOCREATE [<files>...]) file(TOUCH_NOCREATE [<files>...])
.. versionadded:: 3.12
Create a file with no content if it does not yet exist. If the file already Create a file with no content if it does not yet exist. If the file already
exists, its access and/or modification will be updated to the time when the exists, its access and/or modification will be updated to the time when the
function call is executed. function call is executed.
@@ -484,8 +496,10 @@ from the input content to produce the output content. The options are:
``INPUT <input-file>`` ``INPUT <input-file>``
Use the content from a given file as input. Use the content from a given file as input.
A relative path is treated with respect to the value of
:variable:`CMAKE_CURRENT_SOURCE_DIR`. See policy :policy:`CMP0070`. .. versionadded:: 3.10
A relative path is treated with respect to the value of
:variable:`CMAKE_CURRENT_SOURCE_DIR`. See policy :policy:`CMP0070`.
``OUTPUT <output-file>`` ``OUTPUT <output-file>``
Specify the output file name to generate. Use generator expressions Specify the output file name to generate. Use generator expressions
@@ -493,11 +507,15 @@ from the input content to produce the output content. The options are:
name. Multiple configurations may generate the same output file only name. Multiple configurations may generate the same output file only
if the generated content is identical. Otherwise, the ``<output-file>`` if the generated content is identical. Otherwise, the ``<output-file>``
must evaluate to an unique name for each configuration. must evaluate to an unique name for each configuration.
A relative path (after evaluating generator expressions) is treated
with respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`. .. versionadded:: 3.10
See policy :policy:`CMP0070`. A relative path (after evaluating generator expressions) is treated
with respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`.
See policy :policy:`CMP0070`.
``TARGET <target>`` ``TARGET <target>``
.. versionadded:: 3.19
Specify which target to use when evaluating generator expressions that Specify which target to use when evaluating generator expressions that
require a target for evaluation (e.g. ``$<COMPILE_FEATURES:...>``, require a target for evaluation (e.g. ``$<COMPILE_FEATURES:...>``,
``$<TARGET_PROPERTY:prop>``). ``$<TARGET_PROPERTY:prop>``).
@@ -521,6 +539,8 @@ of a project's ``CMakeLists.txt`` files.
[ESCAPE_QUOTES] [@ONLY] [ESCAPE_QUOTES] [@ONLY]
[NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
.. versionadded:: 3.18
Generate an output file using the input given by ``CONTENT`` and substitute Generate an output file using the input given by ``CONTENT`` and substitute
variable values referenced as ``@VAR@`` or ``${VAR}`` contained therein. The variable values referenced as ``@VAR@`` or ``${VAR}`` contained therein. The
substitution rules behave the same as the :command:`configure_file` command. substitution rules behave the same as the :command:`configure_file` command.
@@ -569,20 +589,25 @@ Generate a list of files that match the ``<globbing-expressions>`` and
store it into the ``<variable>``. Globbing expressions are similar to store it into the ``<variable>``. Globbing expressions are similar to
regular expressions, but much simpler. If ``RELATIVE`` flag is regular expressions, but much simpler. If ``RELATIVE`` flag is
specified, the results will be returned as relative paths to the given specified, the results will be returned as relative paths to the given
path. The results will be ordered lexicographically. path.
.. versionadded:: 3.6
The results will be ordered lexicographically.
On Windows and macOS, globbing is case-insensitive even if the underlying On Windows and macOS, globbing is case-insensitive even if the underlying
filesystem is case-sensitive (both filenames and globbing expressions are filesystem is case-sensitive (both filenames and globbing expressions are
converted to lowercase before matching). On other platforms, globbing is converted to lowercase before matching). On other platforms, globbing is
case-sensitive. case-sensitive.
If the ``CONFIGURE_DEPENDS`` flag is specified, CMake will add logic .. versionadded:: 3.3
to the main build system check target to rerun the flagged ``GLOB`` commands By default ``GLOB`` lists directories - directories are omitted in result if
at build time. If any of the outputs change, CMake will regenerate the build ``LIST_DIRECTORIES`` is set to false.
system.
By default ``GLOB`` lists directories - directories are omitted in result if .. versionadded:: 3.12
``LIST_DIRECTORIES`` is set to false. If the ``CONFIGURE_DEPENDS`` flag is specified, CMake will add logic
to the main build system check target to rerun the flagged ``GLOB`` commands
at build time. If any of the outputs change, CMake will regenerate the build
system.
.. note:: .. note::
We do not recommend using GLOB to collect a list of source files from We do not recommend using GLOB to collect a list of source files from
@@ -605,10 +630,11 @@ matched directory and match the files. Subdirectories that are symlinks
are only traversed if ``FOLLOW_SYMLINKS`` is given or policy are only traversed if ``FOLLOW_SYMLINKS`` is given or policy
:policy:`CMP0009` is not set to ``NEW``. :policy:`CMP0009` is not set to ``NEW``.
By default ``GLOB_RECURSE`` omits directories from result list - setting .. versionadded:: 3.3
``LIST_DIRECTORIES`` to true adds directories to result list. By default ``GLOB_RECURSE`` omits directories from result list - setting
If ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to ``LIST_DIRECTORIES`` to true adds directories to result list.
``NEW`` then ``LIST_DIRECTORIES`` treats symlinks as directories. If ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to
``NEW`` then ``LIST_DIRECTORIES`` treats symlinks as directories.
Examples of recursive globbing include:: Examples of recursive globbing include::
@@ -634,7 +660,12 @@ Move a file or directory within a filesystem from ``<oldname>`` to
Remove the given files. The ``REMOVE_RECURSE`` mode will remove the given Remove the given files. The ``REMOVE_RECURSE`` mode will remove the given
files and directories, also non-empty directories. No error is emitted if a files and directories, also non-empty directories. No error is emitted if a
given file does not exist. Relative input paths are evaluated with respect given file does not exist. Relative input paths are evaluated with respect
to the current source directory. Empty input paths are ignored with a warning. to the current source directory.
.. versionadded:: 3.15
Empty input paths are ignored with a warning. Previous versions of CMake
interpreted empty string as a relative path with respect to the current
directory and removed its contents.
.. _MAKE_DIRECTORY: .. _MAKE_DIRECTORY:
@@ -667,17 +698,18 @@ at the destination with the same timestamp. Copying preserves input
permissions unless explicit permissions or ``NO_SOURCE_PERMISSIONS`` permissions unless explicit permissions or ``NO_SOURCE_PERMISSIONS``
are given (default is ``USE_SOURCE_PERMISSIONS``). are given (default is ``USE_SOURCE_PERMISSIONS``).
If ``FOLLOW_SYMLINK_CHAIN`` is specified, ``COPY`` will recursively resolve .. versionadded:: 3.15
the symlinks at the paths given until a real file is found, and install If ``FOLLOW_SYMLINK_CHAIN`` is specified, ``COPY`` will recursively resolve
a corresponding symlink in the destination for each symlink encountered. For the symlinks at the paths given until a real file is found, and install
each symlink that is installed, the resolution is stripped of the directory, a corresponding symlink in the destination for each symlink encountered. For
leaving only the filename, meaning that the new symlink points to a file in each symlink that is installed, the resolution is stripped of the directory,
the same directory as the symlink. This feature is useful on some Unix systems, leaving only the filename, meaning that the new symlink points to a file in
where libraries are installed as a chain of symlinks with version numbers, with the same directory as the symlink. This feature is useful on some Unix systems,
less specific versions pointing to more specific versions. where libraries are installed as a chain of symlinks with version numbers, with
``FOLLOW_SYMLINK_CHAIN`` will install all of these symlinks and the library less specific versions pointing to more specific versions.
itself into the destination directory. For example, if you have the following ``FOLLOW_SYMLINK_CHAIN`` will install all of these symlinks and the library
directory structure: itself into the destination directory. For example, if you have the following
directory structure:
* ``/opt/foo/lib/libfoo.so.1.2.3`` * ``/opt/foo/lib/libfoo.so.1.2.3``
* ``/opt/foo/lib/libfoo.so.1.2 -> libfoo.so.1.2.3`` * ``/opt/foo/lib/libfoo.so.1.2 -> libfoo.so.1.2.3``
@@ -711,6 +743,8 @@ use this signature (with some undocumented options for internal use).
file(SIZE <filename> <variable>) file(SIZE <filename> <variable>)
.. versionadded:: 3.14
Determine the file size of the ``<filename>`` and put the result in Determine the file size of the ``<filename>`` and put the result in
``<variable>`` variable. Requires that ``<filename>`` is a valid path ``<variable>`` variable. Requires that ``<filename>`` is a valid path
pointing to a file and is readable. pointing to a file and is readable.
@@ -721,6 +755,8 @@ pointing to a file and is readable.
file(READ_SYMLINK <linkname> <variable>) file(READ_SYMLINK <linkname> <variable>)
.. versionadded:: 3.14
This subcommand queries the symlink ``<linkname>`` and stores the path it This subcommand queries the symlink ``<linkname>`` and stores the path it
points to in the result ``<variable>``. If ``<linkname>`` does not exist or points to in the result ``<variable>``. If ``<linkname>`` does not exist or
is not a symlink, CMake issues a fatal error. is not a symlink, CMake issues a fatal error.
@@ -745,6 +781,8 @@ absolute path is obtained:
file(CREATE_LINK <original> <linkname> file(CREATE_LINK <original> <linkname>
[RESULT <result>] [COPY_ON_ERROR] [SYMBOLIC]) [RESULT <result>] [COPY_ON_ERROR] [SYMBOLIC])
.. versionadded:: 3.14
Create a link ``<linkname>`` that points to ``<original>``. Create a link ``<linkname>`` that points to ``<original>``.
It will be a hard link by default, but providing the ``SYMBOLIC`` option It will be a hard link by default, but providing the ``SYMBOLIC`` option
results in a symbolic link instead. Hard links require that ``original`` results in a symbolic link instead. Hard links require that ``original``
@@ -769,6 +807,8 @@ which would make them unable to support a hard link.
[FILE_PERMISSIONS <permissions>...] [FILE_PERMISSIONS <permissions>...]
[DIRECTORY_PERMISSIONS <permissions>...]) [DIRECTORY_PERMISSIONS <permissions>...])
.. versionadded:: 3.19
Set the permissions for the ``<files>...`` and ``<directories>...`` specified. Set the permissions for the ``<files>...`` and ``<directories>...`` specified.
Valid permissions are ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``, Valid permissions are ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``,
``GROUP_READ``, ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``, ``GROUP_READ``, ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``,
@@ -805,6 +845,8 @@ Valid combination of keywords are:
[FILE_PERMISSIONS <permissions>...] [FILE_PERMISSIONS <permissions>...]
[DIRECTORY_PERMISSIONS <permissions>...]) [DIRECTORY_PERMISSIONS <permissions>...])
.. versionadded:: 3.19
Same as `CHMOD`_, but change the permissions of files and directories present in Same as `CHMOD`_, but change the permissions of files and directories present in
the ``<directories>...`` recursively. the ``<directories>...`` recursively.
@@ -817,6 +859,8 @@ Path Conversion
file(REAL_PATH <path> <out-var> [BASE_DIRECTORY <dir>]) file(REAL_PATH <path> <out-var> [BASE_DIRECTORY <dir>])
.. versionadded:: 3.19
Compute the absolute path to an existing file or directory with symlinks Compute the absolute path to an existing file or directory with symlinks
resolved. resolved.
@@ -864,10 +908,12 @@ Transfer
file(UPLOAD <file> <url> [<options>...]) file(UPLOAD <file> <url> [<options>...])
The ``DOWNLOAD`` subcommand downloads the given ``<url>`` to a local ``<file>``. The ``DOWNLOAD`` subcommand downloads the given ``<url>`` to a local ``<file>``.
If ``<file>`` is not specified for ``file(DOWNLOAD)``, the file is not saved. The ``UPLOAD`` mode uploads a local ``<file>`` to a given ``<url>``.
This can be useful if you want to know if a file can be downloaded (for example,
to check that it exists) without actually saving it anywhere. The ``UPLOAD`` .. versionadded:: 3.19
mode uploads a local ``<file>`` to a given ``<url>``. If ``<file>`` is not specified for ``file(DOWNLOAD)``, the file is not saved.
This can be useful if you want to know if a file can be downloaded (for example,
to check that it exists) without actually saving it anywhere.
Options to both ``DOWNLOAD`` and ``UPLOAD`` are: Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
@@ -892,12 +938,18 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
Terminate the operation after a given total time has elapsed. Terminate the operation after a given total time has elapsed.
``USERPWD <username>:<password>`` ``USERPWD <username>:<password>``
.. versionadded:: 3.7
Set username and password for operation. Set username and password for operation.
``HTTPHEADER <HTTP-header>`` ``HTTPHEADER <HTTP-header>``
.. versionadded:: 3.7
HTTP header for operation. Suboption can be repeated several times. HTTP header for operation. Suboption can be repeated several times.
``NETRC <level>`` ``NETRC <level>``
.. versionadded:: 3.11
Specify whether the .netrc file is to be used for operation. If this Specify whether the .netrc file is to be used for operation. If this
option is not specified, the value of the ``CMAKE_NETRC`` variable option is not specified, the value of the ``CMAKE_NETRC`` variable
will be used instead. will be used instead.
@@ -914,6 +966,8 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
The .netrc file is required, and information in the URL is ignored. The .netrc file is required, and information in the URL is ignored.
``NETRC_FILE <file>`` ``NETRC_FILE <file>``
.. versionadded:: 3.11
Specify an alternative .netrc file to the one in your home directory, Specify an alternative .netrc file to the one in your home directory,
if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option
is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will
@@ -926,9 +980,15 @@ If neither ``NETRC`` option is given CMake will check variables
Specify whether to verify the server certificate for ``https://`` URLs. Specify whether to verify the server certificate for ``https://`` URLs.
The default is to *not* verify. The default is to *not* verify.
.. versionadded:: 3.18
Added support to ``file(UPLOAD)``.
``TLS_CAINFO <file>`` ``TLS_CAINFO <file>``
Specify a custom Certificate Authority file for ``https://`` URLs. Specify a custom Certificate Authority file for ``https://`` URLs.
.. versionadded:: 3.18
Added support to ``file(UPLOAD)``.
For ``https://`` URLs CMake must be built with OpenSSL support. ``TLS/SSL`` For ``https://`` URLs CMake must be built with OpenSSL support. ``TLS/SSL``
certificates are not checked by default. Set ``TLS_VERIFY`` to ``ON`` to certificates are not checked by default. Set ``TLS_VERIFY`` to ``ON`` to
check certificates. If neither ``TLS`` option is given CMake will check check certificates. If neither ``TLS`` option is given CMake will check
@@ -959,6 +1019,8 @@ Locking
[RESULT_VARIABLE <variable>] [RESULT_VARIABLE <variable>]
[TIMEOUT <seconds>]) [TIMEOUT <seconds>])
.. versionadded:: 3.2
Lock a file specified by ``<path>`` if no ``DIRECTORY`` option present and file Lock a file specified by ``<path>`` if no ``DIRECTORY`` option present and file
``<path>/cmake.lock`` otherwise. File will be locked for scope defined by ``<path>/cmake.lock`` otherwise. File will be locked for scope defined by
``GUARD`` option (default value is ``PROCESS``). ``RELEASE`` option can be used ``GUARD`` option (default value is ``PROCESS``). ``RELEASE`` option can be used
@@ -994,6 +1056,8 @@ Archiving
[MTIME <mtime>] [MTIME <mtime>]
[VERBOSE]) [VERBOSE])
.. versionadded:: 3.18
Creates the specified ``<archive>`` file with the files and directories Creates the specified ``<archive>`` file with the files and directories
listed in ``<paths>``. Note that ``<paths>`` must list actual files or listed in ``<paths>``. Note that ``<paths>`` must list actual files or
directories, wildcards are not supported. directories, wildcards are not supported.
@@ -1008,9 +1072,10 @@ compression. The other formats use no compression by default, but can be
directed to do so with the ``COMPRESSION`` option. Valid values for directed to do so with the ``COMPRESSION`` option. Valid values for
``<compression>`` are ``None``, ``BZip2``, ``GZip``, ``XZ``, and ``Zstd``. ``<compression>`` are ``None``, ``BZip2``, ``GZip``, ``XZ``, and ``Zstd``.
The compression level can be specified with the ``COMPRESSION_LEVEL`` option. .. versionadded:: 3.19
The ``<compression-level>`` should be between 0-9, with the default being 0. The compression level can be specified with the ``COMPRESSION_LEVEL`` option.
The ``COMPRESSION`` option must be present when ``COMPRESSION_LEVEL`` is given. The ``<compression-level>`` should be between 0-9, with the default being 0.
The ``COMPRESSION`` option must be present when ``COMPRESSION_LEVEL`` is given.
.. note:: .. note::
With ``FORMAT`` set to ``raw`` only one file will be compressed with the With ``FORMAT`` set to ``raw`` only one file will be compressed with the
@@ -1031,6 +1096,8 @@ the ``MTIME`` option.
[LIST_ONLY] [LIST_ONLY]
[VERBOSE]) [VERBOSE])
.. versionadded:: 3.18
Extracts or lists the content of the specified ``<archive>``. Extracts or lists the content of the specified ``<archive>``.
The directory where the content of the archive will be extracted to can The directory where the content of the archive will be extracted to can

View File

@@ -351,15 +351,16 @@ The set of installation prefixes is constructed using the following
steps. If ``NO_DEFAULT_PATH`` is specified all ``NO_*`` options are steps. If ``NO_DEFAULT_PATH`` is specified all ``NO_*`` options are
enabled. enabled.
1. Search paths specified in the :variable:`<PackageName>_ROOT` CMake 1. .. versionadded:: 3.12
variable and the :envvar:`<PackageName>_ROOT` environment variable, Search paths specified in the :variable:`<PackageName>_ROOT` CMake
where ``<PackageName>`` is the package to be found. variable and the :envvar:`<PackageName>_ROOT` environment variable,
The package root variables are maintained as a stack so if where ``<PackageName>`` is the package to be found.
called from within a find module, root paths from the parent's find The package root variables are maintained as a stack so if
module will also be searched after paths for the current package. called from within a find module, root paths from the parent's find
This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting module will also be searched after paths for the current package.
the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``. This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
See policy :policy:`CMP0074`. the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
See policy :policy:`CMP0074`.
2. Search paths specified in cmake-specific cache variables. These 2. Search paths specified in cmake-specific cache variables. These
are intended to be used on the command line with a ``-DVAR=value``. are intended to be used on the command line with a ``-DVAR=value``.
@@ -430,6 +431,10 @@ enabled.
9. Search paths specified by the ``PATHS`` option. These are typically 9. Search paths specified by the ``PATHS`` option. These are typically
hard-coded guesses. hard-coded guesses.
.. versionadded:: 3.16
Added ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable
various search locations.
.. |FIND_XXX| replace:: find_package .. |FIND_XXX| replace:: find_package
.. |FIND_ARGS_XXX| replace:: <PackageName> .. |FIND_ARGS_XXX| replace:: <PackageName>
.. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace:: .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace::

View File

@@ -88,6 +88,8 @@ yields
foreach(<loop_var>... IN ZIP_LISTS <lists>) foreach(<loop_var>... IN ZIP_LISTS <lists>)
.. versionadded:: 3.17
In this variant, ``<lists>`` is a whitespace or semicolon In this variant, ``<lists>`` is a whitespace or semicolon
separated list of list-valued variables. The ``foreach`` separated list of list-valued variables. The ``foreach``
command iterates over each list simultaneously setting the command iterates over each list simultaneously setting the

View File

@@ -50,8 +50,9 @@ and so on. However, it is strongly recommended to stay with the
case chosen in the function definition. Typically functions use case chosen in the function definition. Typically functions use
all-lowercase names. all-lowercase names.
The :command:`cmake_language(CALL ...)` command can also be used to .. versionadded:: 3.18
invoke the function. The :command:`cmake_language(CALL ...)` command can also be used to
invoke the function.
Arguments Arguments
^^^^^^^^^ ^^^^^^^^^

View File

@@ -11,12 +11,14 @@ Stores a property of directory scope in the named ``<variable>``.
The ``DIRECTORY`` argument specifies another directory from which The ``DIRECTORY`` argument specifies another directory from which
to retrieve the property value instead of the current directory. to retrieve the property value instead of the current directory.
It may reference either a source directory, or since CMake 3.19, Relative paths are treated as relative to the
a binary directory. Relative paths are treated as relative to the
current source directory. CMake must already know about the directory, current source directory. CMake must already know about the directory,
either by having added it through a call to :command:`add_subdirectory` either by having added it through a call to :command:`add_subdirectory`
or being the top level directory. or being the top level directory.
.. versionadded:: 3.19
``<dir>`` may reference a binary directory.
If the property is not defined for the nominated directory scope, If the property is not defined for the nominated directory scope,
an empty string is returned. In the case of ``INHERITED`` properties, an empty string is returned. In the case of ``INHERITED`` properties,
if the property is not found for the nominated directory scope, if the property is not found for the nominated directory scope,

View File

@@ -3,6 +3,11 @@ get_filename_component
Get a specific component of a full filename. Get a specific component of a full filename.
.. versionadded:: 3.19
This command been superseded by :command:`cmake_path` command, except
``REALPATH`` now offered by :ref:`file(REAL_PATH) <REAL_PATH>` command and
``PROGRAM`` now available in :command:`separate_arguments(PROGRAM)` command.
.. code-block:: cmake .. code-block:: cmake
get_filename_component(<var> <FileName> <mode> [CACHE]) get_filename_component(<var> <FileName> <mode> [CACHE])
@@ -19,6 +24,9 @@ Sets ``<var>`` to a component of ``<FileName>``, where ``<mode>`` is one of:
NAME_WLE = File name without directory or last extension NAME_WLE = File name without directory or last extension
PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11) PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)
.. versionadded:: 3.14
Added ``LAST_EXT`` and ``NAME_WLE`` modes.
Paths are returned with forward slashes and have no trailing slashes. Paths are returned with forward slashes and have no trailing slashes.
If the optional ``CACHE`` argument is specified, the result variable is If the optional ``CACHE`` argument is specified, the result variable is
added to the cache. added to the cache.
@@ -27,6 +35,8 @@ added to the cache.
get_filename_component(<var> <FileName> <mode> [BASE_DIR <dir>] [CACHE]) get_filename_component(<var> <FileName> <mode> [BASE_DIR <dir>] [CACHE])
.. versionadded:: 3.4
Sets ``<var>`` to the absolute path of ``<FileName>``, where ``<mode>`` is one Sets ``<var>`` to the absolute path of ``<FileName>``, where ``<mode>`` is one
of: of:
@@ -53,9 +63,3 @@ left as a full path. If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then
any command-line arguments present in the ``<FileName>`` string are split any command-line arguments present in the ``<FileName>`` string are split
from the program name and stored in ``<arg_var>``. This is used to from the program name and stored in ``<arg_var>``. This is used to
separate a program name from its arguments in a command line string. separate a program name from its arguments in a command line string.
.. note::
This command been superseded by :command:`cmake_path` command, except
``REALPATH`` now offered by :ref:`file(REAL_PATH) <REAL_PATH>` command and
``PROGRAM`` now available in :command:`separate_arguments(PROGRAM)` command.

View File

@@ -30,35 +30,43 @@ It must be one of the following:
``DIRECTORY`` ``DIRECTORY``
Scope defaults to the current directory but another Scope defaults to the current directory but another
directory (already processed by CMake) may be named by the directory (already processed by CMake) may be named by the
full or relative path ``<dir>``. The ``<dir>`` may reference either a full or relative path ``<dir>``.
source directory, or since CMake 3.19, a binary directory.
Relative paths are treated as relative to the current source directory. Relative paths are treated as relative to the current source directory.
See also the :command:`get_directory_property` command. See also the :command:`get_directory_property` command.
.. versionadded:: 3.19
``<dir>`` may reference a binary directory.
``TARGET`` ``TARGET``
Scope must name one existing target. Scope must name one existing target.
See also the :command:`get_target_property` command. See also the :command:`get_target_property` command.
``SOURCE`` ``SOURCE``
Scope must name one source file. By default, the source file's property Scope must name one source file. By default, the source file's property
will be read from the current source directory's scope, but this can be will be read from the current source directory's scope.
overridden with one of the following sub-options:
``DIRECTORY <dir>`` .. versionadded:: 3.18
The source file property will be read from the ``<dir>`` directory's Directory scope can be overridden with one of the following sub-options:
scope. The ``<dir>`` may reference either a source directory, or
since CMake 3.19, a binary directory. CMake must already know about
the directory, either by having added it through a call
to :command:`add_subdirectory` or ``<dir>`` being the top level directory.
Relative paths are treated as relative to the current source directory.
``TARGET_DIRECTORY <target>`` ``DIRECTORY <dir>``
The source file property will be read from the directory scope in which The source file property will be read from the ``<dir>`` directory's
``<target>`` was created (``<target>`` must therefore already exist). scope. CMake must already know about
the directory, either by having added it through a call
to :command:`add_subdirectory` or ``<dir>`` being the top level directory.
Relative paths are treated as relative to the current source directory.
.. versionadded:: 3.19
``<dir>`` may reference a binary directory.
``TARGET_DIRECTORY <target>``
The source file property will be read from the directory scope in which
``<target>`` was created (``<target>`` must therefore already exist).
See also the :command:`get_source_file_property` command. See also the :command:`get_source_file_property` command.
``INSTALL`` ``INSTALL``
.. versionadded:: 3.1
Scope must name one installed file path. Scope must name one installed file path.
``TEST`` ``TEST``

View File

@@ -19,19 +19,21 @@ command and if still unable to find the property, ``variable`` will be set to
an empty string. an empty string.
By default, the source file's property will be read from the current source By default, the source file's property will be read from the current source
directory's scope, but this can be overridden with one of the following directory's scope.
sub-options:
``DIRECTORY <dir>`` .. versionadded:: 3.18
The source file property will be read from the ``<dir>`` directory's Directory scope can be overridden with one of the following sub-options:
scope. CMake must already know about that source directory, either by
having added it through a call to :command:`add_subdirectory` or ``<dir>``
being the top level source directory. Relative paths are treated as
relative to the current source directory.
``TARGET_DIRECTORY <target>`` ``DIRECTORY <dir>``
The source file property will be read from the directory scope in which The source file property will be read from the ``<dir>`` directory's
``<target>`` was created (``<target>`` must therefore already exist). scope. CMake must already know about that source directory, either by
having added it through a call to :command:`add_subdirectory` or ``<dir>``
being the top level source directory. Relative paths are treated as
relative to the current source directory.
``TARGET_DIRECTORY <target>``
The source file property will be read from the directory scope in which
``<target>`` was created (``<target>`` must therefore already exist).
Use :command:`set_source_files_properties` to set property values. Source Use :command:`set_source_files_properties` to set property values. Source
file properties usually control how the file is built. One property that is file properties usually control how the file is built. One property that is

View File

@@ -85,8 +85,9 @@ Possible conditions are:
(in any directory). (in any directory).
``if(TEST test-name)`` ``if(TEST test-name)``
True if the given name is an existing test name created by the .. versionadded:: 3.3
:command:`add_test` command. True if the given name is an existing test name created by the
:command:`add_test` command.
``if(EXISTS path-to-file-or-directory)`` ``if(EXISTS path-to-file-or-directory)``
True if the named file or directory exists. Behavior is well-defined True if the named file or directory exists. Behavior is well-defined
@@ -116,7 +117,9 @@ Possible conditions are:
``if(<variable|string> MATCHES regex)`` ``if(<variable|string> MATCHES regex)``
True if the given string or variable's value matches the given regular True if the given string or variable's value matches the given regular
condition. See :ref:`Regex Specification` for regex format. condition. See :ref:`Regex Specification` for regex format.
``()`` groups are captured in :variable:`CMAKE_MATCH_<n>` variables.
.. versionadded:: 3.9
``()`` groups are captured in :variable:`CMAKE_MATCH_<n>` variables.
``if(<variable|string> LESS <variable|string>)`` ``if(<variable|string> LESS <variable|string>)``
True if the given string or variable's value is a valid number and less True if the given string or variable's value is a valid number and less
@@ -131,12 +134,14 @@ Possible conditions are:
to that on the right. to that on the right.
``if(<variable|string> LESS_EQUAL <variable|string>)`` ``if(<variable|string> LESS_EQUAL <variable|string>)``
True if the given string or variable's value is a valid number and less .. versionadded:: 3.7
than or equal to that on the right. True if the given string or variable's value is a valid number and less
than or equal to that on the right.
``if(<variable|string> GREATER_EQUAL <variable|string>)`` ``if(<variable|string> GREATER_EQUAL <variable|string>)``
True if the given string or variable's value is a valid number and greater .. versionadded:: 3.7
than or equal to that on the right. True if the given string or variable's value is a valid number and greater
than or equal to that on the right.
``if(<variable|string> STRLESS <variable|string>)`` ``if(<variable|string> STRLESS <variable|string>)``
True if the given string or variable's value is lexicographically less True if the given string or variable's value is lexicographically less
@@ -151,12 +156,14 @@ Possible conditions are:
to the string or variable on the right. to the string or variable on the right.
``if(<variable|string> STRLESS_EQUAL <variable|string>)`` ``if(<variable|string> STRLESS_EQUAL <variable|string>)``
True if the given string or variable's value is lexicographically less .. versionadded:: 3.7
than or equal to the string or variable on the right. True if the given string or variable's value is lexicographically less
than or equal to the string or variable on the right.
``if(<variable|string> STRGREATER_EQUAL <variable|string>)`` ``if(<variable|string> STRGREATER_EQUAL <variable|string>)``
True if the given string or variable's value is lexicographically greater .. versionadded:: 3.7
than or equal to the string or variable on the right. True if the given string or variable's value is lexicographically greater
than or equal to the string or variable on the right.
``if(<variable|string> VERSION_LESS <variable|string>)`` ``if(<variable|string> VERSION_LESS <variable|string>)``
Component-wise integer version number comparison (version format is Component-wise integer version number comparison (version format is
@@ -177,25 +184,31 @@ Possible conditions are:
component effectively truncates the string at that point. component effectively truncates the string at that point.
``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)`` ``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is .. versionadded:: 3.7
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero). Component-wise integer version number comparison (version format is
Any non-integer version component or non-integer trailing part of a version ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
component effectively truncates the string at that point. Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)`` ``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is .. versionadded:: 3.7
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero). Component-wise integer version number comparison (version format is
Any non-integer version component or non-integer trailing part of a version ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
component effectively truncates the string at that point. Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
``if(<variable|string> IN_LIST <variable>)`` ``if(<variable|string> IN_LIST <variable>)``
True if the given element is contained in the named list variable. .. versionadded:: 3.3
True if the given element is contained in the named list variable.
``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})`` ``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
True if a variable, cache variable or environment variable True if a variable, cache variable or environment variable
with given ``<name>`` is defined. The value of the variable with given ``<name>`` is defined. The value of the variable
does not matter. Note that macro arguments are not variables. does not matter. Note that macro arguments are not variables.
.. versionadded:: 3.14
Added support for ``CACHE{<name>}`` variables.
``if((condition) AND (condition OR (condition)))`` ``if((condition) AND (condition OR (condition)))``
The conditions inside the parenthesis are evaluated first and then The conditions inside the parenthesis are evaluated first and then
the remaining condition is evaluated as in the previous examples. the remaining condition is evaluated as in the previous examples.
@@ -268,11 +281,12 @@ above-documented condition syntax accepts ``<variable|string>``:
tested to see if they are boolean constants, if so they are used as tested to see if they are boolean constants, if so they are used as
such, otherwise they are assumed to be variables and are dereferenced. such, otherwise they are assumed to be variables and are dereferenced.
To prevent ambiguity, potential variable or keyword names can be .. versionadded:: 3.1
specified in a :ref:`Quoted Argument` or a :ref:`Bracket Argument`. To prevent ambiguity, potential variable or keyword names can be
A quoted or bracketed variable or keyword will be interpreted as a specified in a :ref:`Quoted Argument` or a :ref:`Bracket Argument`.
string and not dereferenced or interpreted. A quoted or bracketed variable or keyword will be interpreted as a
See policy :policy:`CMP0054`. string and not dereferenced or interpreted.
See policy :policy:`CMP0054`.
There is no automatic evaluation for environment or cache There is no automatic evaluation for environment or cache
:ref:`Variable References`. Their values must be referenced as :ref:`Variable References`. Their values must be referenced as

View File

@@ -21,6 +21,7 @@ specify the type of project, id (``GUID``) of the project and the name of
the target platform. This is useful for projects requiring values the target platform. This is useful for projects requiring values
other than the default (e.g. WIX projects). other than the default (e.g. WIX projects).
If the imported project has different configuration names than the .. versionadded:: 3.9
current project, set the :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` If the imported project has different configuration names than the
target property to specify the mapping. current project, set the :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>`
target property to specify the mapping.

View File

@@ -20,10 +20,13 @@ Introduction
This command generates installation rules for a project. Install rules This command generates installation rules for a project. Install rules
specified by calls to the ``install()`` command within a source directory specified by calls to the ``install()`` command within a source directory
are executed in order during installation. Install rules in subdirectories are executed in order during installation.
added by calls to the :command:`add_subdirectory` command are interleaved
with those in the parent directory to run in the order declared (see .. versionadded:: 3.14
policy :policy:`CMP0082`). Install rules in subdirectories
added by calls to the :command:`add_subdirectory` command are interleaved
with those in the parent directory to run in the order declared (see
policy :policy:`CMP0082`).
There are multiple signatures for this command. Some of them define There are multiple signatures for this command. Some of them define
installation options for files and targets. Options common to installation options for files and targets. Options common to
@@ -85,6 +88,8 @@ signatures that specify them. The common options are:
:variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable. :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable.
``EXCLUDE_FROM_ALL`` ``EXCLUDE_FROM_ALL``
.. versionadded:: 3.6
Specify that the file is excluded from a full installation and only Specify that the file is excluded from a full installation and only
installed as part of a component-specific installation installed as part of a component-specific installation
@@ -97,16 +102,18 @@ signatures that specify them. The common options are:
Specify that it is not an error if the file to be installed does Specify that it is not an error if the file to be installed does
not exist. not exist.
Command signatures that install files may print messages during .. versionadded:: 3.1
installation. Use the :variable:`CMAKE_INSTALL_MESSAGE` variable Command signatures that install files may print messages during
to control which messages are printed. installation. Use the :variable:`CMAKE_INSTALL_MESSAGE` variable
to control which messages are printed.
Many of the ``install()`` variants implicitly create the directories .. versionadded:: 3.11
containing the installed files. If Many of the ``install()`` variants implicitly create the directories
:variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` is set, these containing the installed files. If
directories will be created with the permissions specified. Otherwise, :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` is set, these
they will be created according to the uname rules on Unix-like platforms. directories will be created with the permissions specified. Otherwise,
Windows platforms are unaffected. they will be created according to the uname rules on Unix-like platforms.
Windows platforms are unaffected.
Installing Targets Installing Targets
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
@@ -162,6 +169,8 @@ that may be installed:
accompanying import libraries are of kind ``ARCHIVE``). accompanying import libraries are of kind ``ARCHIVE``).
``OBJECTS`` ``OBJECTS``
.. versionadded:: 3.9
Object files associated with *object libraries*. Object files associated with *object libraries*.
``FRAMEWORK`` ``FRAMEWORK``
@@ -246,6 +255,8 @@ In addition to the common options listed above, each target can accept
the following additional arguments: the following additional arguments:
``NAMELINK_COMPONENT`` ``NAMELINK_COMPONENT``
.. versionadded:: 3.12
On some platforms a versioned shared library has a symbolic link such On some platforms a versioned shared library has a symbolic link such
as:: as::
@@ -357,17 +368,19 @@ targets that link to the object libraries in their implementation.
Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property
set to ``TRUE`` has undefined behavior. set to ``TRUE`` has undefined behavior.
`install(TARGETS)`_ can install targets that were created in .. versionadded:: 3.3
other directories. When using such cross-directory install rules, running An install destination given as a ``DESTINATION`` argument may
``make install`` (or similar) from a subdirectory will not guarantee that use "generator expressions" with the syntax ``$<...>``. See the
targets from other directories are up-to-date. You can use :manual:`cmake-generator-expressions(7)` manual for available expressions.
:command:`target_link_libraries` or :command:`add_dependencies`
to ensure that such out-of-directory targets are built before the
subdirectory-specific install rules are run.
An install destination given as a ``DESTINATION`` argument may .. versionadded:: 3.13
use "generator expressions" with the syntax ``$<...>``. See the `install(TARGETS)`_ can install targets that were created in
:manual:`cmake-generator-expressions(7)` manual for available expressions. other directories. When using such cross-directory install rules, running
``make install`` (or similar) from a subdirectory will not guarantee that
targets from other directories are up-to-date. You can use
:command:`target_link_libraries` or :command:`add_dependencies`
to ensure that such out-of-directory targets are built before the
subdirectory-specific install rules are run.
Installing Files Installing Files
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
@@ -455,9 +468,10 @@ this advice while installing headers to a project-specific subdirectory:
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
) )
An install destination given as a ``DESTINATION`` argument may .. versionadded:: 3.4
use "generator expressions" with the syntax ``$<...>``. See the An install destination given as a ``DESTINATION`` argument may
:manual:`cmake-generator-expressions(7)` manual for available expressions. use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
Installing Directories Installing Directories
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
@@ -495,7 +509,8 @@ permissions specified in the ``FILES`` form of the command, and the
directories will be given the default permissions specified in the directories will be given the default permissions specified in the
``PROGRAMS`` form of the command. ``PROGRAMS`` form of the command.
The ``MESSAGE_NEVER`` option disables file installation status output. .. versionadded:: 3.1
The ``MESSAGE_NEVER`` option disables file installation status output.
Installation of directories may be controlled with fine granularity Installation of directories may be controlled with fine granularity
using the ``PATTERN`` or ``REGEX`` options. These "match" options specify a using the ``PATTERN`` or ``REGEX`` options. These "match" options specify a
@@ -579,10 +594,14 @@ path that begins with the appropriate :module:`GNUInstallDirs` variable.
This allows package maintainers to control the install destination by setting This allows package maintainers to control the install destination by setting
the appropriate cache variables. the appropriate cache variables.
The list of ``dirs...`` given to ``DIRECTORY`` and an install destination .. versionadded:: 3.4
given as a ``DESTINATION`` argument may use "generator expressions" An install destination given as a ``DESTINATION`` argument may
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` use "generator expressions" with the syntax ``$<...>``. See the
manual for available expressions. :manual:`cmake-generator-expressions(7)` manual for available expressions.
.. versionadded:: 3.5
The list of ``dirs...`` given to ``DIRECTORY`` may use
"generator expressions" too.
Custom Installation Logic Custom Installation Logic
^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -610,10 +629,11 @@ example, the code
will print a message during installation. will print a message during installation.
``<file>`` or ``<code>`` may use "generator expressions" with the syntax .. versionadded:: 3.14
``$<...>`` (in the case of ``<file>``, this refers to their use in the file ``<file>`` or ``<code>`` may use "generator expressions" with the syntax
name, not the file's contents). See the ``$<...>`` (in the case of ``<file>``, this refers to their use in the file
:manual:`cmake-generator-expressions(7)` manual for available expressions. name, not the file's contents). See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
Installing Exports Installing Exports
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
@@ -673,13 +693,14 @@ RPM, typically handle this by listing the ``Runtime`` component as a dependency
of the ``Development`` component in the package metadata, ensuring that the of the ``Development`` component in the package metadata, ensuring that the
library is always installed if the headers and CMake export file are present. library is always installed if the headers and CMake export file are present.
In addition to cmake language files, the ``EXPORT_ANDROID_MK`` mode maybe .. versionadded:: 3.7
used to specify an export to the android ndk build system. This mode In addition to cmake language files, the ``EXPORT_ANDROID_MK`` mode maybe
accepts the same options as the normal export mode. The Android used to specify an export to the android ndk build system. This mode
NDK supports the use of prebuilt libraries, both static and shared. This accepts the same options as the normal export mode. The Android
allows cmake to build the libraries of a project and make them available NDK supports the use of prebuilt libraries, both static and shared. This
to an ndk build system complete with transitive dependencies, include flags allows cmake to build the libraries of a project and make them available
and defines required to use the libraries. to an ndk build system complete with transitive dependencies, include flags
and defines required to use the libraries.
The ``EXPORT`` form is useful to help outside projects use targets built The ``EXPORT`` form is useful to help outside projects use targets built
and installed by the current project. For example, the code and installed by the current project. For example, the code

View File

@@ -11,21 +11,25 @@ Adds the paths in which the linker should search for libraries.
Relative paths given to this command are interpreted as relative to Relative paths given to this command are interpreted as relative to
the current source directory, see :policy:`CMP0015`. the current source directory, see :policy:`CMP0015`.
The directories are added to the :prop_dir:`LINK_DIRECTORIES` directory
property for the current ``CMakeLists.txt`` file, converting relative
paths to absolute as needed.
The command will apply only to targets created after it is called. The command will apply only to targets created after it is called.
By default the directories specified are appended onto the current list of .. versionadded:: 3.13
directories. This default behavior can be changed by setting The directories are added to the :prop_dir:`LINK_DIRECTORIES` directory
:variable:`CMAKE_LINK_DIRECTORIES_BEFORE` to ``ON``. By using property for the current ``CMakeLists.txt`` file, converting relative
``AFTER`` or ``BEFORE`` explicitly, you can select between appending and paths to absolute as needed. See the :manual:`cmake-buildsystem(7)`
prepending, independent of the default. manual for more on defining buildsystem properties.
Arguments to ``link_directories`` may use "generator expressions" with .. versionadded:: 3.13
the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)` By default the directories specified are appended onto the current list of
manual for available expressions. See the :manual:`cmake-buildsystem(7)` directories. This default behavior can be changed by setting
manual for more on defining buildsystem properties. :variable:`CMAKE_LINK_DIRECTORIES_BEFORE` to ``ON``. By using
``AFTER`` or ``BEFORE`` explicitly, you can select between appending and
prepending, independent of the default.
.. versionadded:: 3.13
Arguments to ``link_directories`` may use "generator expressions" with
the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)`
manual for available expressions.
.. note:: .. note::

View File

@@ -88,6 +88,8 @@ Returns the list of elements specified by indices from the list.
list(JOIN <list> <glue> <output variable>) list(JOIN <list> <glue> <output variable>)
.. versionadded:: 3.12
Returns a string joining all list's elements using the glue string. Returns a string joining all list's elements using the glue string.
To join multiple strings, which are not part of a list, use ``JOIN`` operator To join multiple strings, which are not part of a list, use ``JOIN`` operator
from :command:`string` command. from :command:`string` command.
@@ -98,6 +100,8 @@ from :command:`string` command.
list(SUBLIST <list> <begin> <length> <output variable>) list(SUBLIST <list> <begin> <length> <output variable>)
.. versionadded:: 3.12
Returns a sublist of the given list. Returns a sublist of the given list.
If ``<length>`` is 0, an empty list will be returned. If ``<length>`` is 0, an empty list will be returned.
If ``<length>`` is -1 or the list is smaller than ``<begin>+<length>`` then If ``<length>`` is -1 or the list is smaller than ``<begin>+<length>`` then
@@ -132,6 +136,8 @@ Appends elements to the list.
list(FILTER <list> <INCLUDE|EXCLUDE> REGEX <regular_expression>) list(FILTER <list> <INCLUDE|EXCLUDE> REGEX <regular_expression>)
.. versionadded:: 3.6
Includes or removes items from the list that match the mode's pattern. Includes or removes items from the list that match the mode's pattern.
In ``REGEX`` mode, items will be matched against the given regular expression. In ``REGEX`` mode, items will be matched against the given regular expression.
@@ -152,6 +158,8 @@ Inserts elements to the list to the specified location.
list(POP_BACK <list> [<out-var>...]) list(POP_BACK <list> [<out-var>...])
.. versionadded:: 3.15
If no variable name is given, removes exactly one element. Otherwise, If no variable name is given, removes exactly one element. Otherwise,
assign the last element's value to the given variable and removes it, assign the last element's value to the given variable and removes it,
up to the last variable name given. up to the last variable name given.
@@ -162,6 +170,8 @@ up to the last variable name given.
list(POP_FRONT <list> [<out-var>...]) list(POP_FRONT <list> [<out-var>...])
.. versionadded:: 3.15
If no variable name is given, removes exactly one element. Otherwise, If no variable name is given, removes exactly one element. Otherwise,
assign the first element's value to the given variable and removes it, assign the first element's value to the given variable and removes it,
up to the last variable name given. up to the last variable name given.
@@ -172,6 +182,8 @@ up to the last variable name given.
list(PREPEND <list> [<element> ...]) list(PREPEND <list> [<element> ...])
.. versionadded:: 3.15
Insert elements to the 0th position in the list. Insert elements to the 0th position in the list.
.. _REMOVE_ITEM: .. _REMOVE_ITEM:
@@ -206,6 +218,8 @@ but if duplicates are encountered, only the first instance is preserved.
list(TRANSFORM <list> <ACTION> [<SELECTOR>] list(TRANSFORM <list> <ACTION> [<SELECTOR>]
[OUTPUT_VARIABLE <output variable>]) [OUTPUT_VARIABLE <output variable>])
.. versionadded:: 3.12
Transforms the list by applying an action to all or, by specifying a Transforms the list by applying an action to all or, by specifying a
``<SELECTOR>``, to the selected elements of the list, storing the result ``<SELECTOR>``, to the selected elements of the list, storing the result
in-place or in the specified output variable. in-place or in the specified output variable.
@@ -302,6 +316,13 @@ Reverses the contents of the list in-place.
list(SORT <list> [COMPARE <compare>] [CASE <case>] [ORDER <order>]) list(SORT <list> [COMPARE <compare>] [CASE <case>] [ORDER <order>])
Sorts the list in-place alphabetically. Sorts the list in-place alphabetically.
.. versionadded:: 3.13
Added ``COMPARE``, ``CASE``, and ``ORDER`` options.
.. versionadded:: 3.18
Added ``COMPARE NATURAL`` option.
Use the ``COMPARE`` keyword to select the comparison method for sorting. Use the ``COMPARE`` keyword to select the comparison method for sorting.
The ``<compare>`` option should be one of: The ``<compare>`` option should be one of:

View File

@@ -48,8 +48,9 @@ and so on. However, it is strongly recommended to stay with the
case chosen in the macro definition. Typically macros use case chosen in the macro definition. Typically macros use
all-lowercase names. all-lowercase names.
The :command:`cmake_language(CALL ...)` command can also be used to .. versionadded:: 3.18
invoke the macro. The :command:`cmake_language(CALL ...)` command can also be used to
invoke the macro.
Arguments Arguments
^^^^^^^^^ ^^^^^^^^^

View File

@@ -23,8 +23,6 @@ new values will be marked as advanced, but if a
variable already has an advanced/non-advanced state, variable already has an advanced/non-advanced state,
it will not be changed. it will not be changed.
.. note:: .. versionadded:: 3.17
Variables passed to this command which are not already in the cache
Policy :policy:`CMP0102` affects the behavior of the ``mark_as_advanced`` are ignored. See policy :policy:`CMP0102`.
call. When set to ``NEW``, variables passed to this command which are not
already in the cache are ignored. See policy :policy:`CMP0102`.

View File

@@ -17,17 +17,18 @@ Supported operators are ``+``, ``-``, ``*``, ``/``, ``%``, ``|``, ``&``,
``^``, ``~``, ``<<``, ``>>``, and ``(...)``; they have the same meaning ``^``, ``~``, ``<<``, ``>>``, and ``(...)``; they have the same meaning
as in C code. as in C code.
Hexadecimal numbers are recognized when prefixed with ``0x``, as in C code. .. versionadded:: 3.13
Hexadecimal numbers are recognized when prefixed with ``0x``, as in C code.
The result is formatted according to the option ``OUTPUT_FORMAT``, .. versionadded:: 3.13
where ``<format>`` is one of The result is formatted according to the option ``OUTPUT_FORMAT``,
where ``<format>`` is one of
``HEXADECIMAL``
Hexadecimal notation as in C code, i. e. starting with "0x".
``DECIMAL``
Decimal notation. Which is also used if no ``OUTPUT_FORMAT`` option
is specified.
``HEXADECIMAL``
Hexadecimal notation as in C code, i. e. starting with "0x".
``DECIMAL``
Decimal notation. Which is also used if no ``OUTPUT_FORMAT`` option
is specified.
For example For example

View File

@@ -71,6 +71,9 @@ influences the way the message is handled:
using this log level would normally only be temporary and would expect to be using this log level would normally only be temporary and would expect to be
removed before releasing the project, packaging up the files, etc. removed before releasing the project, packaging up the files, etc.
.. versionadded:: 3.15
Added ``NOTICE``, ``VERBOSE``, ``DEBUG``, and ``TRACE`` levels.
The CMake command-line tool displays ``STATUS`` to ``TRACE`` messages on stdout The CMake command-line tool displays ``STATUS`` to ``TRACE`` messages on stdout
with the message preceded by two hyphens and a space. All other message types with the message preceded by two hyphens and a space. All other message types
are sent to stderr and are not prefixed with hyphens. The are sent to stderr and are not prefixed with hyphens. The
@@ -79,25 +82,29 @@ The :manual:`curses interface <ccmake(1)>` shows ``STATUS`` to ``TRACE``
messages one at a time on a status line and other messages in an messages one at a time on a status line and other messages in an
interactive pop-up box. The ``--log-level`` command-line option to each of interactive pop-up box. The ``--log-level`` command-line option to each of
these tools can be used to control which messages will be shown. these tools can be used to control which messages will be shown.
To make a log level persist between CMake runs, the
:variable:`CMAKE_MESSAGE_LOG_LEVEL` variable can be set instead.
Note that the command line option takes precedence over the cache variable.
Messages of log levels ``NOTICE`` and below will have each line preceded .. versionadded:: 3.17
by the content of the :variable:`CMAKE_MESSAGE_INDENT` variable (converted to To make a log level persist between CMake runs, the
a single string by concatenating its list items). For ``STATUS`` to ``TRACE`` :variable:`CMAKE_MESSAGE_LOG_LEVEL` variable can be set instead.
messages, this indenting content will be inserted after the hyphens. Note that the command line option takes precedence over the cache variable.
Messages of log levels ``NOTICE`` and below can also have each line preceded .. versionadded:: 3.16
with context of the form ``[some.context.example]``. The content between the Messages of log levels ``NOTICE`` and below will have each line preceded
square brackets is obtained by converting the :variable:`CMAKE_MESSAGE_CONTEXT` by the content of the :variable:`CMAKE_MESSAGE_INDENT` variable (converted to
list variable to a dot-separated string. The message context will always a single string by concatenating its list items). For ``STATUS`` to ``TRACE``
appear before any indenting content but after any automatically added leading messages, this indenting content will be inserted after the hyphens.
hyphens. By default, message context is not shown, it has to be explicitly
enabled by giving the :manual:`cmake <cmake(1)>` ``--log-context`` .. versionadded:: 3.17
command-line option or by setting the :variable:`CMAKE_MESSAGE_CONTEXT_SHOW` Messages of log levels ``NOTICE`` and below can also have each line preceded
variable to true. See the :variable:`CMAKE_MESSAGE_CONTEXT` documentation for with context of the form ``[some.context.example]``. The content between the
usage examples. square brackets is obtained by converting the :variable:`CMAKE_MESSAGE_CONTEXT`
list variable to a dot-separated string. The message context will always
appear before any indenting content but after any automatically added leading
hyphens. By default, message context is not shown, it has to be explicitly
enabled by giving the :manual:`cmake <cmake(1)>` ``--log-context``
command-line option or by setting the :variable:`CMAKE_MESSAGE_CONTEXT_SHOW`
variable to true. See the :variable:`CMAKE_MESSAGE_CONTEXT` documentation for
usage examples.
CMake Warning and Error message text displays using a simple markup CMake Warning and Error message text displays using a simple markup
language. Non-indented text is formatted in line-wrapped paragraphs language. Non-indented text is formatted in line-wrapped paragraphs
@@ -107,6 +114,8 @@ delimited by newlines. Indented text is considered pre-formatted.
Reporting checks Reporting checks
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
.. versionadded:: 3.17
A common pattern in CMake output is a message indicating the start of some A common pattern in CMake output is a message indicating the start of some
sort of check, followed by another message reporting the result of that check. sort of check, followed by another message reporting the result of that check.
For example: For example:

View File

@@ -55,10 +55,14 @@ The options are:
* :variable:`PROJECT_VERSION_TWEAK`, * :variable:`PROJECT_VERSION_TWEAK`,
:variable:`<PROJECT-NAME>_VERSION_TWEAK`. :variable:`<PROJECT-NAME>_VERSION_TWEAK`.
When the ``project()`` command is called from the top-level ``CMakeLists.txt``, .. versionadded:: 3.12
then the version is also stored in the variable :variable:`CMAKE_PROJECT_VERSION`. When the ``project()`` command is called from the top-level
``CMakeLists.txt``, then the version is also stored in the variable
:variable:`CMAKE_PROJECT_VERSION`.
``DESCRIPTION <project-description-string>`` ``DESCRIPTION <project-description-string>``
.. versionadded:: 3.9
Optional. Optional.
Sets the variables Sets the variables
@@ -71,7 +75,12 @@ The options are:
When the ``project()`` command is called from the top-level ``CMakeLists.txt``, When the ``project()`` command is called from the top-level ``CMakeLists.txt``,
then the description is also stored in the variable :variable:`CMAKE_PROJECT_DESCRIPTION`. then the description is also stored in the variable :variable:`CMAKE_PROJECT_DESCRIPTION`.
.. versionadded:: 3.12
Added ``<PROJECT-NAME>_DESCRIPTION`` variable.
``HOMEPAGE_URL <url-string>`` ``HOMEPAGE_URL <url-string>``
.. versionadded:: 3.12
Optional. Optional.
Sets the variables Sets the variables
@@ -93,6 +102,15 @@ The options are:
Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages, Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages,
to skip enabling any languages. to skip enabling any languages.
.. versionadded:: 3.8
Added ``CUDA`` support.
.. versionadded:: 3.16
Added ``OBJC`` and ``OBJCXX`` support.
.. versionadded:: 3.18
Added ``ISPC`` support.
If enabling ``ASM``, list it last so that CMake can check whether If enabling ``ASM``, list it last so that CMake can check whether
compilers for other languages like ``C`` work for assembly too. compilers for other languages like ``C`` work for assembly too.
@@ -102,6 +120,8 @@ options are intended for use as default values in package metadata and documenta
Code Injection Code Injection
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
.. versionadded:: 3.15
If the :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` or If the :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` or
:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE` variables are set, :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE` variables are set,
the files they point to will be included as the first step of the the files they point to will be included as the first step of the
@@ -115,6 +135,9 @@ they point to will be included as the last step of the ``project()`` command.
If both are set, then :variable:`CMAKE_PROJECT_INCLUDE` will be included before If both are set, then :variable:`CMAKE_PROJECT_INCLUDE` will be included before
:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`. :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`.
.. versionadded:: 3.17
Added ``CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`` variable.
Usage Usage
^^^^^ ^^^^^

View File

@@ -32,10 +32,14 @@ be one of the following keywords:
MSDN article `Parsing C Command-Line Arguments`_ for details. MSDN article `Parsing C Command-Line Arguments`_ for details.
``NATIVE_COMMAND`` ``NATIVE_COMMAND``
.. versionadded:: 3.9
Proceeds as in ``WINDOWS_COMMAND`` mode if the host system is Windows. Proceeds as in ``WINDOWS_COMMAND`` mode if the host system is Windows.
Otherwise proceeds as in ``UNIX_COMMAND`` mode. Otherwise proceeds as in ``UNIX_COMMAND`` mode.
``PROGRAM`` ``PROGRAM``
.. versionadded:: 3.19
The first item in ``<args>`` is assumed to be an executable and will be The first item in ``<args>`` is assumed to be an executable and will be
searched in the system search path or left as a full path. If not found, searched in the system search path or left as a full path. If not found,
``<variable>`` will be empty. Otherwise, ``<variable>`` is a list of 2 ``<variable>`` will be empty. Otherwise, ``<variable>`` is a list of 2

View File

@@ -28,11 +28,12 @@ It must be one of the following:
``DIRECTORY`` ``DIRECTORY``
Scope defaults to the current directory but other directories Scope defaults to the current directory but other directories
(already processed by CMake) may be named by full or relative path. (already processed by CMake) may be named by full or relative path.
Each path may reference either a source directory, or since CMake 3.19,
a binary directory.
Relative paths are treated as relative to the current source directory. Relative paths are treated as relative to the current source directory.
See also the :command:`set_directory_properties` command. See also the :command:`set_directory_properties` command.
.. versionadded:: 3.19
``<dir>`` may reference a binary directory.
``TARGET`` ``TARGET``
Scope may name zero or more existing targets. Scope may name zero or more existing targets.
See also the :command:`set_target_properties` command. See also the :command:`set_target_properties` command.
@@ -40,25 +41,31 @@ It must be one of the following:
``SOURCE`` ``SOURCE``
Scope may name zero or more source files. By default, source file properties Scope may name zero or more source files. By default, source file properties
are only visible to targets added in the same directory (``CMakeLists.txt``). are only visible to targets added in the same directory (``CMakeLists.txt``).
Visibility can be set in other directory scopes using one or both of the
following sub-options:
``DIRECTORY <dirs>...`` .. versionadded:: 3.18
The source file property will be set in each of the ``<dirs>`` Visibility can be set in other directory scopes using one or both of the
directories' scopes. Each path may reference either a source directory, following sub-options:
or since CMake 3.19, a binary directory. CMake must already know about
each of these directories, either by having added them through a call to
:command:`add_subdirectory` or it being the top level source directory.
Relative paths are treated as relative to the current source directory.
``TARGET_DIRECTORY <targets>...`` ``DIRECTORY <dirs>...``
The source file property will be set in each of the directory scopes The source file property will be set in each of the ``<dirs>``
where any of the specified ``<targets>`` were created (the ``<targets>`` directories' scopes. CMake must already know about
must therefore already exist). each of these directories, either by having added them through a call to
:command:`add_subdirectory` or it being the top level source directory.
Relative paths are treated as relative to the current source directory.
.. versionadded:: 3.19
``<dirs>`` may reference a binary directory.
``TARGET_DIRECTORY <targets>...``
The source file property will be set in each of the directory scopes
where any of the specified ``<targets>`` were created (the ``<targets>``
must therefore already exist).
See also the :command:`set_source_files_properties` command. See also the :command:`set_source_files_properties` command.
``INSTALL`` ``INSTALL``
.. versionadded:: 3.1
Scope may name zero or more installed file paths. Scope may name zero or more installed file paths.
These are made available to CPack to influence deployment. These are made available to CPack to influence deployment.

View File

@@ -14,9 +14,10 @@ Source files can have properties that affect how they are built.
Sets properties associated with source files using a key/value paired Sets properties associated with source files using a key/value paired
list. list.
By default, source file properties are only visible to targets added in the .. versionadded:: 3.18
same directory (``CMakeLists.txt``). Visibility can be set in other directory By default, source file properties are only visible to targets added in the
scopes using one or both of the following options: same directory (``CMakeLists.txt``). Visibility can be set in other directory
scopes using one or both of the following options:
``DIRECTORY <dirs>...`` ``DIRECTORY <dirs>...``
The source file properties will be set in each of the ``<dirs>`` The source file properties will be set in each of the ``<dirs>``

View File

@@ -14,12 +14,16 @@ This is intended to set up file tabs in Visual Studio.
The options are: The options are:
``TREE`` ``TREE``
.. versionadded:: 3.8
CMake will automatically detect, from ``<src>`` files paths, source groups CMake will automatically detect, from ``<src>`` files paths, source groups
it needs to create, to keep structure of source groups analogically to the it needs to create, to keep structure of source groups analogically to the
actual files and directories structure in the project. Paths of ``<src>`` actual files and directories structure in the project. Paths of ``<src>``
files will be cut to be relative to ``<root>``. files will be cut to be relative to ``<root>``.
``PREFIX`` ``PREFIX``
.. versionadded:: 3.8
Source group and files located directly in ``<root>`` path, will be placed Source group and files located directly in ``<root>`` path, will be placed
in ``<prefix>`` source groups. in ``<prefix>`` source groups.
@@ -47,6 +51,9 @@ appropriately:
source_group(outer\\inner ...) source_group(outer\\inner ...)
source_group(TREE <root> PREFIX sources\\inc ...) source_group(TREE <root> PREFIX sources\\inc ...)
.. versionadded:: 3.18
Allow using forward slashes (``/``) to specify subgroups.
For backwards compatibility, the short-hand signature For backwards compatibility, the short-hand signature
.. code-block:: cmake .. code-block:: cmake

View File

@@ -170,10 +170,12 @@ The following characters have special meaning in regular expressions:
Matches a pattern on either side of the ``|`` Matches a pattern on either side of the ``|``
``()`` ``()``
Saves a matched subexpression, which can be referenced Saves a matched subexpression, which can be referenced
in the ``REGEX REPLACE`` operation. Additionally it is saved in the ``REGEX REPLACE`` operation.
by all regular expression-related commands, including
e.g. :command:`if(MATCHES)`, in the variables .. versionadded:: 3.9
:variable:`CMAKE_MATCH_<n>` for ``<n>`` 0..9. All regular expression-related commands, including e.g.
:command:`if(MATCHES)`, save subgroup matches in the variables
:variable:`CMAKE_MATCH_<n>` for ``<n>`` 0..9.
``*``, ``+`` and ``?`` have higher precedence than concatenation. ``|`` ``*``, ``+`` and ``?`` have higher precedence than concatenation. ``|``
has lower precedence than concatenation. This means that the regular has lower precedence than concatenation. This means that the regular
@@ -205,6 +207,8 @@ Manipulation
string(APPEND <string_variable> [<input>...]) string(APPEND <string_variable> [<input>...])
.. versionadded:: 3.4
Append all the ``<input>`` arguments to the string. Append all the ``<input>`` arguments to the string.
.. _PREPEND: .. _PREPEND:
@@ -213,6 +217,8 @@ Append all the ``<input>`` arguments to the string.
string(PREPEND <string_variable> [<input>...]) string(PREPEND <string_variable> [<input>...])
.. versionadded:: 3.10
Prepend all the ``<input>`` arguments to the string. Prepend all the ``<input>`` arguments to the string.
.. _CONCAT: .. _CONCAT:
@@ -230,6 +236,8 @@ the result in the named ``<output_variable>``.
string(JOIN <glue> <output_variable> [<input>...]) string(JOIN <glue> <output_variable> [<input>...])
.. versionadded:: 3.12
Join all the ``<input>`` arguments together using the ``<glue>`` Join all the ``<input>`` arguments together using the ``<glue>``
string and store the result in the named ``<output_variable>``. string and store the result in the named ``<output_variable>``.
@@ -271,16 +279,15 @@ result stored in ``<output_variable>`` will *not* be the number of characters.
Store in an ``<output_variable>`` a substring of a given ``<string>``. If Store in an ``<output_variable>`` a substring of a given ``<string>``. If
``<length>`` is ``-1`` the remainder of the string starting at ``<begin>`` ``<length>`` is ``-1`` the remainder of the string starting at ``<begin>``
will be returned. If ``<string>`` is shorter than ``<length>`` then the will be returned.
end of the string is used instead.
.. versionadded:: 3.2
If ``<string>`` is shorter than ``<length>`` then the end of the string
is used instead. Previous versions of CMake reported an error in this case.
Both ``<begin>`` and ``<length>`` are counted in bytes, so care must Both ``<begin>`` and ``<length>`` are counted in bytes, so care must
be exercised if ``<string>`` could contain multi-byte characters. be exercised if ``<string>`` could contain multi-byte characters.
.. note::
CMake 3.1 and below reported an error if ``<length>`` pointed past
the end of ``<string>``.
.. _STRIP: .. _STRIP:
.. code-block:: cmake .. code-block:: cmake
@@ -296,6 +303,8 @@ leading and trailing spaces removed.
string(GENEX_STRIP <string> <output_variable>) string(GENEX_STRIP <string> <output_variable>)
.. versionadded:: 3.1
Strip any :manual:`generator expressions <cmake-generator-expressions(7)>` Strip any :manual:`generator expressions <cmake-generator-expressions(7)>`
from the input ``<string>`` and store the result in the ``<output_variable>``. from the input ``<string>`` and store the result in the ``<output_variable>``.
@@ -305,6 +314,8 @@ from the input ``<string>`` and store the result in the ``<output_variable>``.
string(REPEAT <string> <count> <output_variable>) string(REPEAT <string> <count> <output_variable>)
.. versionadded:: 3.15
Produce the output string as the input ``<string>`` repeated ``<count>`` times. Produce the output string as the input ``<string>`` repeated ``<count>`` times.
Comparison Comparison
@@ -323,6 +334,9 @@ Comparison
Compare the strings and store true or false in the ``<output_variable>``. Compare the strings and store true or false in the ``<output_variable>``.
.. versionadded:: 3.7
Added ``LESS_EQUAL`` and ``GREATER_EQUAL`` options.
.. _`Supported Hash Algorithms`: .. _`Supported Hash Algorithms`:
Hashing Hashing
@@ -358,6 +372,9 @@ The supported ``<HASH>`` algorithm names are:
``SHA3_512`` ``SHA3_512``
Keccak SHA-3. Keccak SHA-3.
.. versionadded:: 3.8
Added ``SHA3`` hash algorithms.
Generation Generation
^^^^^^^^^^ ^^^^^^^^^^
@@ -375,6 +392,8 @@ Convert all numbers into corresponding ASCII characters.
string(HEX <string> <output_variable>) string(HEX <string> <output_variable>)
.. versionadded:: 3.18
Convert each byte in the input ``<string>`` to its hexadecimal representation Convert each byte in the input ``<string>`` to its hexadecimal representation
and store the concatenated hex digits in the ``<output_variable>``. Letters in and store the concatenated hex digits in the ``<output_variable>``. Letters in
the output (``a`` through ``f``) are in lowercase. the output (``a`` through ``f``) are in lowercase.
@@ -451,6 +470,18 @@ specifiers:
%y The last two digits of the current year (00-99) %y The last two digits of the current year (00-99)
%Y The current year. %Y The current year.
.. versionadded:: 3.6
``%s`` format specifier (UNIX time).
.. versionadded:: 3.7
``%a`` and ``%b`` format specifiers (abbreviated month and weekday names).
.. versionadded:: 3.8
``%%`` specifier (literal ``%``).
.. versionadded:: 3.7
``%A`` and ``%B`` format specifiers (full month and weekday names).
Unknown format specifiers will be ignored and copied to the output Unknown format specifiers will be ignored and copied to the output
as-is. as-is.
@@ -461,8 +492,7 @@ If no explicit ``<format_string>`` is given, it will default to:
%Y-%m-%dT%H:%M:%S for local time. %Y-%m-%dT%H:%M:%S for local time.
%Y-%m-%dT%H:%M:%SZ for UTC. %Y-%m-%dT%H:%M:%SZ for UTC.
.. note:: .. versionadded:: 3.8
If the ``SOURCE_DATE_EPOCH`` environment variable is set, If the ``SOURCE_DATE_EPOCH`` environment variable is set,
its value will be used instead of the current time. its value will be used instead of the current time.
See https://reproducible-builds.org/specs/source-date-epoch/ for details. See https://reproducible-builds.org/specs/source-date-epoch/ for details.
@@ -474,6 +504,8 @@ If no explicit ``<format_string>`` is given, it will default to:
string(UUID <output_variable> NAMESPACE <namespace> NAME <name> string(UUID <output_variable> NAMESPACE <namespace> NAME <name>
TYPE <MD5|SHA1> [UPPER]) TYPE <MD5|SHA1> [UPPER])
.. versionadded:: 3.1
Create a universally unique identifier (aka GUID) as per RFC4122 Create a universally unique identifier (aka GUID) as per RFC4122
based on the hash of the combined values of ``<namespace>`` based on the hash of the combined values of ``<namespace>``
(which itself has to be a valid UUID) and ``<name>``. (which itself has to be a valid UUID) and ``<name>``.
@@ -489,6 +521,8 @@ with the optional ``UPPER`` flag.
JSON JSON
^^^^ ^^^^
.. versionadded:: 3.19
Functionality for querying a JSON string. Functionality for querying a JSON string.
.. note:: .. note::

View File

@@ -19,10 +19,12 @@ specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`COMPILE_DEFINITIONS` property of items will populate the :prop_tgt:`COMPILE_DEFINITIONS` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the ``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` property of ``<target>``. :prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
The following arguments specify compile definitions. Repeated calls for the The following arguments specify compile definitions. Repeated calls for the
same ``<target>`` append items in the order called. same ``<target>`` append items in the order called.
.. versionadded:: 3.11
Allow setting ``INTERFACE`` items on :ref:`IMPORTED targets <Imported Targets>`.
Arguments to ``target_compile_definitions`` may use "generator expressions" Arguments to ``target_compile_definitions`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)`

View File

@@ -21,9 +21,11 @@ specify the scope of the features. ``PRIVATE`` and ``PUBLIC`` items will
populate the :prop_tgt:`COMPILE_FEATURES` property of ``<target>``. populate the :prop_tgt:`COMPILE_FEATURES` property of ``<target>``.
``PUBLIC`` and ``INTERFACE`` items will populate the ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ``<target>``. :prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
Repeated calls for the same ``<target>`` append items. Repeated calls for the same ``<target>`` append items.
.. versionadded:: 3.11
Allow setting ``INTERFACE`` items on :ref:`IMPORTED targets <Imported Targets>`.
The named ``<target>`` must have been created by a command such as The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an :command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`. :ref:`ALIAS target <Alias Targets>`.

View File

@@ -26,10 +26,12 @@ specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`COMPILE_OPTIONS` property of items will populate the :prop_tgt:`COMPILE_OPTIONS` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the ``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_COMPILE_OPTIONS` property of ``<target>``. :prop_tgt:`INTERFACE_COMPILE_OPTIONS` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
The following arguments specify compile options. Repeated calls for the same The following arguments specify compile options. Repeated calls for the same
``<target>`` append items in the order called. ``<target>`` append items in the order called.
.. versionadded:: 3.11
Allow setting ``INTERFACE`` items on :ref:`IMPORTED targets <Imported Targets>`.
Arguments to ``target_compile_options`` may use "generator expressions" Arguments to ``target_compile_options`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)`

View File

@@ -22,9 +22,11 @@ the scope of the following arguments. ``PRIVATE`` and ``PUBLIC`` items will
populate the :prop_tgt:`INCLUDE_DIRECTORIES` property of ``<target>``. populate the :prop_tgt:`INCLUDE_DIRECTORIES` property of ``<target>``.
``PUBLIC`` and ``INTERFACE`` items will populate the ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` property of ``<target>``. :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
The following arguments specify include directories. The following arguments specify include directories.
.. versionadded:: 3.11
Allow setting ``INTERFACE`` items on :ref:`IMPORTED targets <Imported Targets>`.
Specified include directories may be absolute paths or relative paths. Specified include directories may be absolute paths or relative paths.
Repeated calls for the same <target> append items in the order called. If Repeated calls for the same <target> append items in the order called. If
``SYSTEM`` is specified, the compiler will be told the ``SYSTEM`` is specified, the compiler will be told the

View File

@@ -27,6 +27,10 @@ set to ``NEW`` then the target must have been created in the current
directory. Repeated calls for the same ``<target>`` append items in directory. Repeated calls for the same ``<target>`` append items in
the order called. the order called.
.. versionadded:: 3.13
The ``<target>`` doesn't have to be defined in the same directory as the
``target_link_libraries`` call.
Each ``<item>`` may be: Each ``<item>`` may be:
* **A library target name**: The generated link line will have the * **A library target name**: The generated link line will have the
@@ -62,10 +66,11 @@ Each ``<item>`` may be:
:ref:`usage requirement <Target Usage Requirements>`. This has the same :ref:`usage requirement <Target Usage Requirements>`. This has the same
effect as passing the framework directory as an include directory. effect as passing the framework directory as an include directory.
On :ref:`Visual Studio Generators` for VS 2010 and above, library files .. versionadded:: 3.8
ending in ``.targets`` will be treated as MSBuild targets files and On :ref:`Visual Studio Generators` for VS 2010 and above, library files
imported into generated project files. This is not supported by other ending in ``.targets`` will be treated as MSBuild targets files and
generators. imported into generated project files. This is not supported by other
generators.
The full path to the library file will be quoted/escaped for The full path to the library file will be quoted/escaped for
the shell automatically. the shell automatically.
@@ -89,6 +94,11 @@ Each ``<item>`` may be:
flags explicitly. The flags will then be placed at the toolchain-defined flags explicitly. The flags will then be placed at the toolchain-defined
flag position in the link command. flag position in the link command.
.. versionadded:: 3.13
:prop_tgt:`LINK_OPTIONS` target property and :command:`target_link_options`
command. For earlier versions of CMake, use :prop_tgt:`LINK_FLAGS`
property instead.
The link flag is treated as a command-line string fragment and The link flag is treated as a command-line string fragment and
will be used with no extra quoting or escaping. will be used with no extra quoting or escaping.
@@ -216,6 +226,8 @@ is not ``NEW``, they are also appended to the
Linking Object Libraries Linking Object Libraries
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.12
:ref:`Object Libraries` may be used as the ``<target>`` (first) argument :ref:`Object Libraries` may be used as the ``<target>`` (first) argument
of ``target_link_libraries`` to specify dependencies of their sources of ``target_link_libraries`` to specify dependencies of their sources
on other libraries. For example, the code on other libraries. For example, the code

View File

@@ -36,10 +36,12 @@ specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`LINK_OPTIONS` property of items will populate the :prop_tgt:`LINK_OPTIONS` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the ``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_LINK_OPTIONS` property of ``<target>``. :prop_tgt:`INTERFACE_LINK_OPTIONS` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
The following arguments specify link options. Repeated calls for the same The following arguments specify link options. Repeated calls for the same
``<target>`` append items in the order called. ``<target>`` append items in the order called.
.. note::
:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.
Arguments to ``target_link_options`` may use "generator expressions" Arguments to ``target_link_options`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)`

View File

@@ -12,29 +12,37 @@ Add sources to a target.
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
Specifies sources to use when building a target and/or its dependents. Specifies sources to use when building a target and/or its dependents.
Relative source file paths are interpreted as being relative to the current The named ``<target>`` must have been created by a command such as
source directory (i.e. :variable:`CMAKE_CURRENT_SOURCE_DIR`). The
named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` or :command:`add_executable` or :command:`add_library` or
:command:`add_custom_target` and must not be an :command:`add_custom_target` and must not be an
:ref:`ALIAS target <Alias Targets>`. :ref:`ALIAS target <Alias Targets>`.
.. versionadded:: 3.13
Relative source file paths are interpreted as being relative to the current
source directory (i.e. :variable:`CMAKE_CURRENT_SOURCE_DIR`).
See policy :policy:`CMP0076`.
.. versionadded:: 3.20
``<target>`` can be a custom target.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the scope of the items following them. ``PRIVATE`` and ``PUBLIC`` specify the scope of the items following them. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`SOURCES` property of items will populate the :prop_tgt:`SOURCES` property of
``<target>``, which are used when building the target itself. ``<target>``, which are used when building the target itself.
``PUBLIC`` and ``INTERFACE`` items will populate the ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``, which are used :prop_tgt:`INTERFACE_SOURCES` property of ``<target>``, which are used
when building dependents. (:ref:`IMPORTED targets <Imported Targets>` when building dependents.
only support ``INTERFACE`` items because they are not build targets.)
The following arguments specify sources. Repeated calls for the same The following arguments specify sources. Repeated calls for the same
``<target>`` append items in the order called. The targets created by ``<target>`` append items in the order called. The targets created by
:command:`add_custom_target` can only have ``PRIVATE`` scope. :command:`add_custom_target` can only have ``PRIVATE`` scope.
.. versionadded:: 3.3
Allow exporting targets with :prop_tgt:`INTERFACE_SOURCES`.
.. versionadded:: 3.11
Allow setting ``INTERFACE`` items on :ref:`IMPORTED targets <Imported Targets>`.
Arguments to ``target_sources`` may use "generator expressions" Arguments to ``target_sources`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties. manual for more on defining buildsystem properties.
See also the :policy:`CMP0076` policy for older behavior related to the
handling of relative source file paths.

View File

@@ -19,6 +19,10 @@ Try Compiling Whole Projects
Try building a project. The success or failure of the ``try_compile``, Try building a project. The success or failure of the ``try_compile``,
i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``. i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``.
.. versionadded:: 3.14
The name of the ``<resultVar>`` is defined by the user. Previously, it had
a fixed name ``RESULT_VAR``.
In this form, ``<srcdir>`` should contain a complete CMake project with a In this form, ``<srcdir>`` should contain a complete CMake project with a
``CMakeLists.txt`` file and all sources. The ``<bindir>`` and ``<srcdir>`` ``CMakeLists.txt`` file and all sources. The ``<bindir>`` and ``<srcdir>``
will not be deleted after this command is run. Specify ``<targetName>`` to will not be deleted after this command is run. Specify ``<targetName>`` to
@@ -47,6 +51,10 @@ Try building an executable or static library from one or more source files
variable). The success or failure of the ``try_compile``, i.e. ``TRUE`` or variable). The success or failure of the ``try_compile``, i.e. ``TRUE`` or
``FALSE`` respectively, is returned in ``<resultVar>``. ``FALSE`` respectively, is returned in ``<resultVar>``.
.. versionadded:: 3.14
The name of the ``<resultVar>`` is defined by the user. Previously, it had
a fixed name ``RESULT_VAR``.
In this form, one or more source files must be provided. If In this form, one or more source files must be provided. If
:variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is unset or is set to ``EXECUTABLE``, :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is unset or is set to ``EXECUTABLE``,
the sources must include a definition for ``main`` and CMake will create a the sources must include a definition for ``main`` and CMake will create a
@@ -94,6 +102,8 @@ The options are:
given to the ``CMAKE_FLAGS`` option will be ignored. given to the ``CMAKE_FLAGS`` option will be ignored.
``LINK_OPTIONS <options>...`` ``LINK_OPTIONS <options>...``
.. versionadded:: 3.14
Specify link step options to pass to :command:`target_link_options` or to Specify link step options to pass to :command:`target_link_options` or to
set the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property in the generated set the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property in the generated
project, depending on the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable. project, depending on the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable.
@@ -102,17 +112,23 @@ The options are:
Store the output from the build process in the given variable. Store the output from the build process in the given variable.
``<LANG>_STANDARD <std>`` ``<LANG>_STANDARD <std>``
.. versionadded:: 3.8
Specify the :prop_tgt:`C_STANDARD`, :prop_tgt:`CXX_STANDARD`, Specify the :prop_tgt:`C_STANDARD`, :prop_tgt:`CXX_STANDARD`,
:prop_tgt:`OBJC_STANDARD`, :prop_tgt:`OBJCXX_STANDARD`, :prop_tgt:`OBJC_STANDARD`, :prop_tgt:`OBJCXX_STANDARD`,
or :prop_tgt:`CUDA_STANDARD` target property of the generated project. or :prop_tgt:`CUDA_STANDARD` target property of the generated project.
``<LANG>_STANDARD_REQUIRED <bool>`` ``<LANG>_STANDARD_REQUIRED <bool>``
.. versionadded:: 3.8
Specify the :prop_tgt:`C_STANDARD_REQUIRED`, Specify the :prop_tgt:`C_STANDARD_REQUIRED`,
:prop_tgt:`CXX_STANDARD_REQUIRED`, :prop_tgt:`OBJC_STANDARD_REQUIRED`, :prop_tgt:`CXX_STANDARD_REQUIRED`, :prop_tgt:`OBJC_STANDARD_REQUIRED`,
:prop_tgt:`OBJCXX_STANDARD_REQUIRED`,or :prop_tgt:`CUDA_STANDARD_REQUIRED` :prop_tgt:`OBJCXX_STANDARD_REQUIRED`,or :prop_tgt:`CUDA_STANDARD_REQUIRED`
target property of the generated project. target property of the generated project.
``<LANG>_EXTENSIONS <bool>`` ``<LANG>_EXTENSIONS <bool>``
.. versionadded:: 3.8
Specify the :prop_tgt:`C_EXTENSIONS`, :prop_tgt:`CXX_EXTENSIONS`, Specify the :prop_tgt:`C_EXTENSIONS`, :prop_tgt:`CXX_EXTENSIONS`,
:prop_tgt:`OBJC_EXTENSIONS`, :prop_tgt:`OBJCXX_EXTENSIONS`, :prop_tgt:`OBJC_EXTENSIONS`, :prop_tgt:`OBJCXX_EXTENSIONS`,
or :prop_tgt:`CUDA_EXTENSIONS` target property of the generated project. or :prop_tgt:`CUDA_EXTENSIONS` target property of the generated project.
@@ -131,24 +147,26 @@ the try_compile call of interest, and then re-run cmake again with
Other Behavior Settings Other Behavior Settings
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
If set, the following variables are passed in to the generated .. versionadded:: 3.4
try_compile CMakeLists.txt to initialize compile target properties with If set, the following variables are passed in to the generated
default values: try_compile CMakeLists.txt to initialize compile target properties with
default values:
* :variable:`CMAKE_CUDA_RUNTIME_LIBRARY` * :variable:`CMAKE_CUDA_RUNTIME_LIBRARY`
* :variable:`CMAKE_ENABLE_EXPORTS` * :variable:`CMAKE_ENABLE_EXPORTS`
* :variable:`CMAKE_LINK_SEARCH_START_STATIC` * :variable:`CMAKE_LINK_SEARCH_START_STATIC`
* :variable:`CMAKE_LINK_SEARCH_END_STATIC` * :variable:`CMAKE_LINK_SEARCH_END_STATIC`
* :variable:`CMAKE_MSVC_RUNTIME_LIBRARY` * :variable:`CMAKE_MSVC_RUNTIME_LIBRARY`
* :variable:`CMAKE_POSITION_INDEPENDENT_CODE` * :variable:`CMAKE_POSITION_INDEPENDENT_CODE`
If :policy:`CMP0056` is set to ``NEW``, then If :policy:`CMP0056` is set to ``NEW``, then
:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well. :variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well.
If :policy:`CMP0083` is set to ``NEW``, then in order to obtain correct .. versionadded:: 3.14
behavior at link time, the ``check_pie_supported()`` command from the If :policy:`CMP0083` is set to ``NEW``, then in order to obtain correct
:module:`CheckPIESupported` module must be called before using the behavior at link time, the ``check_pie_supported()`` command from the
:command:`try_compile` command. :module:`CheckPIESupported` module must be called before using the
:command:`try_compile` command.
The current settings of :policy:`CMP0065` and :policy:`CMP0083` are propagated The current settings of :policy:`CMP0065` and :policy:`CMP0083` are propagated
through to the generated test project. through to the generated test project.
@@ -156,37 +174,41 @@ through to the generated test project.
Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose
a build configuration. a build configuration.
Set the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to specify .. versionadded:: 3.6
the type of target used for the source file signature. Set the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to specify
the type of target used for the source file signature.
Set the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify .. versionadded:: 3.6
variables that must be propagated into the test project. This variable is Set the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify
meant for use only in toolchain files and is only honored by the variables that must be propagated into the test project. This variable is
``try_compile()`` command for the source files form, not when given a whole meant for use only in toolchain files and is only honored by the
project. ``try_compile()`` command for the source files form, not when given a whole
project.
If :policy:`CMP0067` is set to ``NEW``, or any of the ``<LANG>_STANDARD``, .. versionadded:: 3.8
``<LANG>_STANDARD_REQUIRED``, or ``<LANG>_EXTENSIONS`` options are used, If :policy:`CMP0067` is set to ``NEW``, or any of the ``<LANG>_STANDARD``,
then the language standard variables are honored: ``<LANG>_STANDARD_REQUIRED``, or ``<LANG>_EXTENSIONS`` options are used,
then the language standard variables are honored:
* :variable:`CMAKE_C_STANDARD` * :variable:`CMAKE_C_STANDARD`
* :variable:`CMAKE_C_STANDARD_REQUIRED` * :variable:`CMAKE_C_STANDARD_REQUIRED`
* :variable:`CMAKE_C_EXTENSIONS` * :variable:`CMAKE_C_EXTENSIONS`
* :variable:`CMAKE_CXX_STANDARD` * :variable:`CMAKE_CXX_STANDARD`
* :variable:`CMAKE_CXX_STANDARD_REQUIRED` * :variable:`CMAKE_CXX_STANDARD_REQUIRED`
* :variable:`CMAKE_CXX_EXTENSIONS` * :variable:`CMAKE_CXX_EXTENSIONS`
* :variable:`CMAKE_OBJC_STANDARD` * :variable:`CMAKE_OBJC_STANDARD`
* :variable:`CMAKE_OBJC_STANDARD_REQUIRED` * :variable:`CMAKE_OBJC_STANDARD_REQUIRED`
* :variable:`CMAKE_OBJC_EXTENSIONS` * :variable:`CMAKE_OBJC_EXTENSIONS`
* :variable:`CMAKE_OBJCXX_STANDARD` * :variable:`CMAKE_OBJCXX_STANDARD`
* :variable:`CMAKE_OBJCXX_STANDARD_REQUIRED` * :variable:`CMAKE_OBJCXX_STANDARD_REQUIRED`
* :variable:`CMAKE_OBJCXX_EXTENSIONS` * :variable:`CMAKE_OBJCXX_EXTENSIONS`
* :variable:`CMAKE_CUDA_STANDARD` * :variable:`CMAKE_CUDA_STANDARD`
* :variable:`CMAKE_CUDA_STANDARD_REQUIRED` * :variable:`CMAKE_CUDA_STANDARD_REQUIRED`
* :variable:`CMAKE_CUDA_EXTENSIONS` * :variable:`CMAKE_CUDA_EXTENSIONS`
Their values are used to set the corresponding target properties in Their values are used to set the corresponding target properties in
the generated project (unless overridden by an explicit option). the generated project (unless overridden by an explicit option).
For the :generator:`Green Hills MULTI` generator the GHS toolset and target .. versionadded:: 3.14
system customization cache variables are also propagated into the test project. For the :generator:`Green Hills MULTI` generator the GHS toolset and target
system customization cache variables are also propagated into the test project.

View File

@@ -29,6 +29,11 @@ executable was built, but failed to run, then ``<runResultVar>`` will be
set to ``FAILED_TO_RUN``. See the :command:`try_compile` command for set to ``FAILED_TO_RUN``. See the :command:`try_compile` command for
information on how the test project is constructed to build the source file. information on how the test project is constructed to build the source file.
.. versionadded:: 3.14
The names of the result variables ``<runResultVar>`` and
``<compileResultVar>`` are defined by the user. Previously, they had
fixed names ``RUN_RESULT_VAR`` and ``COMPILE_RESULT_VAR``.
The options are: The options are:
``CMAKE_FLAGS <flags>...`` ``CMAKE_FLAGS <flags>...``
@@ -46,6 +51,8 @@ The options are:
Report the compile step build output in a given variable. Report the compile step build output in a given variable.
``LINK_LIBRARIES <libs>...`` ``LINK_LIBRARIES <libs>...``
.. versionadded:: 3.2
Specify libraries to be linked in the generated project. Specify libraries to be linked in the generated project.
The list of libraries may refer to system libraries and to The list of libraries may refer to system libraries and to
:ref:`Imported Targets <Imported Targets>` from the calling project. :ref:`Imported Targets <Imported Targets>` from the calling project.
@@ -54,6 +61,8 @@ The options are:
given to the ``CMAKE_FLAGS`` option will be ignored. given to the ``CMAKE_FLAGS`` option will be ignored.
``LINK_OPTIONS <options>...`` ``LINK_OPTIONS <options>...``
.. versionadded:: 3.14
Specify link step options to pass to :command:`target_link_options` in the Specify link step options to pass to :command:`target_link_options` in the
generated project. generated project.
@@ -74,6 +83,10 @@ a build configuration.
Behavior when Cross Compiling Behavior when Cross Compiling
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.3
Use ``CMAKE_CROSSCOMPILING_EMULATOR`` when running cross-compiled
binaries.
When cross compiling, the executable compiled in the first step When cross compiling, the executable compiled in the first step
usually cannot be run on the build host. The ``try_run`` command checks usually cannot be run on the build host. The ``try_run`` command checks
the :variable:`CMAKE_CROSSCOMPILING` variable to detect whether CMake is in the :variable:`CMAKE_CROSSCOMPILING` variable to detect whether CMake is in