Merge branch 'master' into llvm-rc-preprocess-as-c

This commit is contained in:
Brad King
2020-12-02 08:21:12 -05:00
801 changed files with 16040 additions and 8337 deletions

View File

@@ -52,7 +52,7 @@ prep:doc-package:
- .cmake_doc_artifacts
- .run_only_for_package
.upload:source-package:
upload:source-package:
extends:
- .rsync_upload
- .run_only_for_package
@@ -175,7 +175,7 @@ build:linux-x86_64-package:
needs:
- prep:doc-package
.upload:linux-x86_64-package:
upload:linux-x86_64-package:
extends:
- .rsync_upload
- .run_only_for_package
@@ -250,7 +250,7 @@ build:macos-package:
needs:
- prep:doc-package
.upload:macos-package:
upload:macos-package:
extends:
- .rsync_upload
- .run_only_for_package

View File

@@ -19,6 +19,7 @@ set(CMake_TEST_FindGSL "ON" CACHE BOOL "")
set(CMake_TEST_FindGTest "ON" CACHE BOOL "")
set(CMake_TEST_FindGTK2 "ON" CACHE BOOL "")
set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "")
set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "")

View File

@@ -19,6 +19,7 @@ set(CMake_TEST_FindGSL "ON" CACHE BOOL "")
set(CMake_TEST_FindGTest "ON" CACHE BOOL "")
set(CMake_TEST_FindGTK2 "ON" CACHE BOOL "")
set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindIntl "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "")
set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "")

View File

@@ -52,7 +52,7 @@
image: "kitware/cmake:ci-fedora33-x86_64-2020-11-13"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes"
#### Lint builds

View File

@@ -258,7 +258,8 @@ optional argument topic will be appended to the argument list."
(save-selected-window
(select-window (display-buffer buffer 'not-this-window))
(cmake-mode)
(read-only-mode 1))
(read-only-mode 1)
(view-mode 1))
)
)

View File

@@ -3,6 +3,8 @@
use strict;
use warnings;
use POSIX qw(strftime);
use JSON;
use File::Basename;
#my $cmake = "/home/pboettch/devel/upstream/cmake/build/bin/cmake";
my $cmake = "cmake";
@@ -96,6 +98,28 @@ close(CMAKE);
# transform all properties in a hash
my %properties = map { $_ => 1 } @properties;
# read in manually written files
my $modules_dir = dirname(__FILE__) . "/modules";
opendir(DIR, $modules_dir) || die "can't opendir $modules_dir: $!";
my @json_files = grep { /\.json$/ && -f "$modules_dir/$_" } readdir(DIR);
closedir DIR;
foreach my $file (@json_files) {
local $/; # Enable 'slurp' mode
open my $fh, "<", $modules_dir."/".$file;
my $json = <$fh>;
close $fh;
my $mod = decode_json($json);
foreach my $var (@{$mod->{variables}}) {
$variables{$var} = 1;
}
while (my ($cmd, $keywords) = each %{$mod->{commands}}) {
$keywords{$cmd} = [ sort @{$keywords} ];
}
}
# version
open(CMAKE, "$cmake --version|");
my $version = 'unknown';

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.1...3.15 FATAL_ERROR)
cmake_minimum_required(VERSION 3.1...3.18 FATAL_ERROR)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake)
project(CMake)

View File

@@ -1,11 +1,12 @@
When a device link step is involved, which is controlled by
:prop_tgt:`CUDA_SEPARABLE_COMPILATION` and
:prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties and policy :policy:`CMP0105`,
the raw options will be delivered to the host and device link steps (wrapped in
``-Xcompiler`` or equivalent for device link). Options wrapped with
``$<DEVICE_LINK:...>``
:manual:`generator expression <cmake-generator-expressions(7)>` will be used
only for the device link step. Options wrapped with ``$<HOST_LINK:...>``
:manual:`generator expression <cmake-generator-expressions(7)>` will be used
only for the host link step.
.. versionadded:: 3.18
When a device link step is involved, which is controlled by
:prop_tgt:`CUDA_SEPARABLE_COMPILATION` and
:prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties and policy :policy:`CMP0105`,
the raw options will be delivered to the host and device link steps (wrapped in
``-Xcompiler`` or equivalent for device link). Options wrapped with
``$<DEVICE_LINK:...>``
:manual:`generator expression <cmake-generator-expressions(7)>` will be used
only for the device link step. Options wrapped with ``$<HOST_LINK:...>``
: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
and the search will not be repeated unless the variable is cleared.
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:
@@ -60,7 +57,11 @@ Options include:
Specify the documentation string for the ``<VAR>`` cache entry.
``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
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
:variable:`CMAKE_SYSTEM_PREFIX_PATH`
1. If called from within a find module or any other script loaded by a call to
:command:`find_package(<PackageName>)`, search prefixes unique to the
current package being found. Specifically, look in the
:variable:`<PackageName>_ROOT` CMake variable and the
:envvar:`<PackageName>_ROOT` environment variable.
The package root variables are maintained as a stack, so if called from
nested find modules or config packages, root paths from the parent's find
module or config package will be searched after paths from the current
module or package. In other words, the search order would be
``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
See policy :policy:`CMP0074`.
1. .. versionadded:: 3.12
If called from within a find module or any other script loaded by a call to
:command:`find_package(<PackageName>)`, search prefixes unique to the
current package being found. Specifically, look in the
:variable:`<PackageName>_ROOT` CMake variable and the
:envvar:`<PackageName>_ROOT` environment variable.
The package root variables are maintained as a stack, so if called from
nested find modules or config packages, root paths from the parent's find
module or config package will be searched after paths from the current
module or package. In other words, the search order would be
``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
See policy :policy:`CMP0074`.
* |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.
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
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
accumulating options from the current target and the usage requirements of
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
specify a group of options using shell-like quoting along with a ``SHELL:``
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``.
.. versionadded:: 3.12
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
specify a group of options using shell-like quoting along with a ``SHELL:``
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.
``BYPRODUCTS``
.. versionadded:: 3.2
Specify the files the command is expected to produce but whose
modification time may or may not be newer than the dependencies.
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
:variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
* The target is being cross-compiled and an emulator is provided (i.e.
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
prepended to the command before the location of the target executable.
* .. versionadded:: 3.6
The target is being cross-compiled and an emulator is provided (i.e.
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
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
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
directory (``CMakeLists.txt`` file), CMake automatically brings the other
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
directory to ensure the byproducts will be available.
.. versionadded:: 3.16
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
the ``OUTPUT`` is missing; if the command does not actually
create the ``OUTPUT``, the rule will always run.
Arguments to ``DEPENDS`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
.. versionadded:: 3.1
Arguments to ``DEPENDS`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
``COMMAND_EXPAND_LISTS``
.. versionadded:: 3.8
Lists in ``COMMAND`` arguments will be expanded, including those
created with
: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.
``JOB_POOL``
.. versionadded:: 3.15
Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
generator. Incompatible with ``USES_TERMINAL``, which implies
the ``console`` pool.
@@ -211,6 +221,8 @@ The options are:
source file property.
``USES_TERMINAL``
.. versionadded:: 3.2
The command will be given direct access to the terminal if possible.
With the :generator:`Ninja` generator, this places the command in
the ``console`` :prop_gbl:`pool <JOB_POOLS>`.
@@ -230,15 +242,23 @@ The options are:
If it is a relative path it will be interpreted relative to the
build tree directory corresponding to the current source directory.
Arguments to ``WORKING_DIRECTORY`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
.. versionadded:: 3.13
Arguments to ``WORKING_DIRECTORY`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
``DEPFILE``
.. versionadded:: 3.7
Specify a ``.d`` depfile for the :generator:`Ninja` generator.
A ``.d`` file holds dependencies usually emitted by the custom
command itself.
Using ``DEPFILE`` with other generators than Ninja is an error.
If the ``DEPFILE`` argument is relative, it should be relative to
:variable:`CMAKE_CURRENT_BINARY_DIR`, and any relative paths inside the
``DEPFILE`` should also be relative to :variable:`CMAKE_CURRENT_BINARY_DIR`
(see policy :policy:`CMP0116`.)
Build Events
^^^^^^^^^^^^

View File

@@ -32,6 +32,8 @@ The options are:
called ``ALL``).
``BYPRODUCTS``
.. versionadded:: 3.2
Specify the files the command is expected to produce but whose
modification time may or may not be updated on subsequent builds.
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
:variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
* The target is being cross-compiled and an emulator is provided (i.e.
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
prepended to the command before the location of the target executable.
* .. versionadded:: 3.6
The target is being cross-compiled and an emulator is provided (i.e.
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
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
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
(``CMakeLists.txt`` file). They will be brought up to date when
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
the byproducts will be available before this target is built.
.. versionchanged:: 3.16
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
on other targets.
``COMMAND_EXPAND_LISTS``
.. versionadded:: 3.8
Lists in ``COMMAND`` arguments will be expanded, including those
created with
:manual:`generator expressions <cmake-generator-expressions(7)>`,
@@ -119,6 +126,8 @@ The options are:
to be properly expanded.
``JOB_POOL``
.. versionadded:: 3.15
Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
generator. Incompatible with ``USES_TERMINAL``, which implies
the ``console`` pool.
@@ -141,6 +150,8 @@ The options are:
tool-specific special characters.
``USES_TERMINAL``
.. versionadded:: 3.2
The command will be given direct access to the terminal if possible.
With the :generator:`Ninja` generator, this places the command in
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
build tree directory corresponding to the current source directory.
Arguments to ``WORKING_DIRECTORY`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
.. versionadded:: 3.13
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
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
:command:`add_custom_command` commands for adding file-level
dependencies in custom rules. See the :prop_sf:`OBJECT_DEPENDS`

View File

@@ -17,13 +17,21 @@ Normal Executables
[source1] [source2 ...])
Adds an executable target called ``<name>`` to be built from the source
files listed in the command invocation. (The source files can be omitted
here if they are added later using :command:`target_sources`.) The
files listed in the command invocation. The
``<name>`` corresponds to the logical target name and must be globally
unique within a project. The actual file name of the executable built is
constructed based on conventions of the native platform (such as
``<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
directory corresponding to the source tree directory in which 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`
target property for details.
Source arguments to ``add_executable`` may use "generator expressions" with
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
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
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
``<target>`` may not be an ``ALIAS``.
An ``ALIAS`` to a non-``GLOBAL`` :ref:`Imported Target <Imported Targets>`
has scope in the directory in which the alias is created and below.
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
alias is global or not.
.. versionadded:: 3.11
An ``ALIAS`` can target a ``GLOBAL`` :ref:`Imported Target <Imported Targets>`
.. 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
from, executables for custom commands and custom targets. They can also be

View File

@@ -17,13 +17,21 @@ Normal Libraries
[<source>...])
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
if they are added later using :command:`target_sources`.) The ``<name>``
listed in the command invocation. The ``<name>``
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
on conventions of the native platform (such as ``lib<name>.a`` or
``<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
library to be created. ``STATIC`` libraries are archives of object files
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
``MODULE`` libraries the :prop_tgt:`POSITION_INDEPENDENT_CODE` target
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.
.. 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
``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.
@@ -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`
target property for details.
Source arguments to ``add_library`` may use "generator expressions" with
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
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
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
``$<TARGET_OBJECTS:objlib>``.
.. versionadded:: 3.12
Object libraries can be linked to with :command:`target_link_libraries`.
Interface Libraries
^^^^^^^^^^^^^^^^^^^
@@ -121,23 +134,28 @@ like any other target.
An interface library created with the above signature has no source files
itself and is not included as a target in the generated buildsystem.
Since CMake 3.19, an interface library target may be created with
source files:
.. versionadded:: 3.15
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
later by calls to :command:`target_sources` with the ``PRIVATE`` or
``PUBLIC`` keywords.
add_library(<name> INTERFACE [<source>...] [EXCLUDE_FROM_ALL])
If an interface library has source files (i.e. the :prop_tgt:`SOURCES`
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.
Source files may be listed directly in the ``add_library`` call or added
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`
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::
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>``
may not be an ``ALIAS``.
An ``ALIAS`` to a non-``GLOBAL`` :ref:`Imported Target <Imported Targets>`
has scope in the directory in which the alias is created and below.
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
alias is global or not.
.. versionadded:: 3.11
An ``ALIAS`` can target a ``GLOBAL`` :ref:`Imported Target <Imported Targets>`
.. 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
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.
``COMMAND_EXPAND_LISTS``
.. versionadded:: 3.16
Lists in ``COMMAND`` arguments will be expanded, including those
created with
: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:`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
expressions" with the syntax ``$<...>``. See the
: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]_
``TOTAL_PHYSICAL_MEMORY`` Total 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
``HAS_FPU`` One if processor has floating point unit
``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])
.. versionadded:: 3.12
The optional ``<max>`` version.
Sets the minimum required version of cmake for a project.
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>...``.
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`
body. In this case the arguments that are parsed come from the
``ARGV#`` variables of the calling function. The parsing starts with
the ``<N>``-th argument, where ``<N>`` is an unsigned integer. This allows for
the values to have special characters like ``;`` in them.
.. versionadded:: 3.7
The ``PARSE_ARGV`` signature is only for use in a :command:`function`
body. In this case the arguments that are parsed come from the
``ARGV#`` variables of the calling function. The parsing starts with
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,
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
``TARGETS`` or ``FILES`` keywords of the :command:`install` command.
.. note::
All keywords shall be unique. I.e. every keyword shall only be specified
once in either ``<options>``, ``<one_value_keywords>`` or
``<multi_value_keywords>``. A warning will be emitted if uniqueness is
violated.
.. versionchanged:: 3.5
All keywords shall be unique. I.e. every keyword shall only be specified
once in either ``<options>``, ``<one_value_keywords>`` or
``<multi_value_keywords>``. A warning will be emitted if uniqueness is
violated.
When done, ``cmake_parse_arguments`` will consider for each of the
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
whether your macro was called with unrecognized parameters.
``<one_value_keywords>`` and ``<multi_value_keywords>`` that were given no
values at all are collected in a variable ``<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.
.. versionadded:: 3.15
``<one_value_keywords>`` and ``<multi_value_keywords>`` that were given no
values at all are collected in a variable
``<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
arguments to the real :command:`install` command:

817
Help/command/cmake_path.rst Normal file
View File

@@ -0,0 +1,817 @@
cmake_path
----------
.. versionadded:: 3.20
Filesystem path manipulation command.
This command is dedicated to the manipulation of objects of type path which
represent paths on a filesystem. Only syntactic aspects of paths are handled:
the pathname may represent a non-existing path or even one that is not allowed
to exist on the current file system or OS.
For operations involving the filesystem, have a look at the :command:`file`
command.
The path name has the following syntax:
1. ``root-name`` (optional): identifies the root on a filesystem with multiple
roots (such as ``"C:"`` or ``"//myserver"``).
2. ``root-directory`` (optional): a directory separator that, if present, marks
this path as absolute. If it is missing (and the first element other than
the ``root-name`` is a ``item-name``), then the path is relative.
Zero or more of the following:
3. ``item-name``: sequence of characters that aren't directory separators. This
name may identify a file, a hard link, a symbolic link, or a directory. Two
special ``item-names`` are recognized:
* ``dot``: the item name consisting of a single dot character ``.`` is a
directory name that refers to the current directory.
* ``dot-dot``: the item name consisting of two dot characters ``..`` is a
directory name that refers to the parent directory.
4. ``directory-separator``: the forward slash character ``/``. If this
character is repeated, it is treated as a single directory separator:
``/usr///////lib`` is the same as ``/usr/lib``.
.. _FILENAME_DEF:
A path has a filename if it does not ends with a ``directory-separator``. The
filename is the last ``item-name`` of the path.
.. _EXTENSION_DEF:
A :ref:`filename <FILENAME_DEF>` can have an extension. By default, the
extension is defined as the sub-string beginning at the leftmost period
(including the period) and until the end of the pathname. When the option
``LAST_ONLY`` is specified, the extension is the sub-string beginning at the
rightmost period.
The following exceptions apply:
* If the first character in the :ref:`filename <FILENAME_DEF>` is a period,
that period is ignored (a filename like ``".profile"`` is not treated as an
extension).
* If the pathname is either ``.`` or ``..``.
.. note::
``cmake_path`` command handles paths in the format of the build system, not
the target system. So this is not generally applicable to the target system
in cross-compiling environment.
For all commands, ``<path-var>`` placeholder expect a variable name. An error
will be raised if the variable does not exist, except for `SET`_ and `APPEND`_
sub-commands. ``<input>`` placeholder expect a string literal.
``[<input>...]`` placeholder expect zero or more arguments. ``<out-var>``
placeholder expect a variable name.
.. note::
``cmake_path`` command does not support list of paths. The ``<path-var>``
placeholder must store only one path name.
To initialize a path variable, three possibilities can be used:
1. :command:`set` command.
2. :ref:`cmake_path(SET) <SET>` command. Mainly used to build a
path variable from a native path.
3. :ref:`cmake_path(APPEND) <APPEND>` command. Can be used to build a path from
already available path fragments.
.. code-block:: cmake
# To build the path "${CMAKE_CURRENT_SOURCE_DIR}/data"
set (path1 "${CMAKE_CURRENT_SOURCE_DIR}/data")
cmake_path(SET path2 "${CMAKE_CURRENT_SOURCE_DIR}/data")
cmake_path(APPEND path3 "${CMAKE_CURRENT_SOURCE_DIR}" "data")
`Modification`_ and `Generation`_ sub-commands store the result in-place or in
the variable specified by ``OUTPUT_VARIABLE`` option. All other sub-commands
store the result in the required ``<out-var>`` variable.
Sub-commands supporting ``NORMALIZE`` option will :ref:`normalize <NORMAL_PATH>`
the path.
Synopsis
^^^^^^^^
.. parsed-literal::
`Decomposition`_
cmake_path(`GET`_ <path-var> :ref:`ROOT_NAME <GET_ROOT_NAME>` <out-var>)
cmake_path(`GET`_ <path-var> :ref:`ROOT_DIRECTORY <GET_ROOT_DIRECTORY>` <out-var>)
cmake_path(`GET`_ <path-var> :ref:`ROOT_PATH <GET_ROOT_PATH>` <out-var>)
cmake_path(`GET`_ <path-var> :ref:`FILENAME <GET_FILENAME>` <out-var>)
cmake_path(`GET`_ <path-var> :ref:`EXTENSION <GET_EXTENSION>` [LAST_ONLY] <out-var>)
cmake_path(`GET`_ <path-var> :ref:`STEM <GET_STEM>` [LAST_ONLY] <out-var>)
cmake_path(`GET`_ <path-var> :ref:`RELATIVE_PATH <GET_RELATIVE_PATH>` <out-var>)
cmake_path(`GET`_ <path-var> :ref:`PARENT_PATH <GET_PARENT_PATH>` <out-var>)
`Modification`_
cmake_path(`SET`_ <path-var> [NORMALIZE] <input>)
cmake_path(`APPEND`_ <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
cmake_path(`APPEND_STRING`_ <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
cmake_path(`REMOVE_FILENAME`_ <path-var> [OUTPUT_VARIABLE <out-var>])
cmake_path(`REPLACE_FILENAME`_ <path-var> <input> [OUTPUT_VARIABLE <out-var>])
cmake_path(`REMOVE_EXTENSION`_ <path-var> [LAST_ONLY]
[OUTPUT_VARIABLE <out-var>])
cmake_path(`REPLACE_EXTENSION`_ <path-var> [LAST_ONLY] <input>
[OUTPUT_VARIABLE <out-var>])
`Generation`_
cmake_path(`NORMAL_PATH`_ <path-var> [OUTPUT_VARIABLE <out-var>])
cmake_path(`RELATIVE_PATH`_ <path-var> [BASE_DIRECTORY <input>]
[OUTPUT_VARIABLE <out-var>])
cmake_path(`ABSOLUTE_PATH`_ <path-var> [BASE_DIRECTORY <input>] [NORMALIZE]
[OUTPUT_VARIABLE <out-var>])
`Conversion`_
cmake_path(`NATIVE_PATH`_ <path-var> [NORMALIZE] <out-var>)
cmake_path(`CONVERT`_ <input> `TO_CMAKE_PATH_LIST`_ <out-var>)
cmake_path(`CONVERT`_ <input> `TO_NATIVE_PATH_LIST`_ <out-var>)
`Comparison`_
cmake_path(`COMPARE`_ <input1> <OP> <input2> <out-var>)
`Query`_
cmake_path(`HAS_ROOT_NAME`_ <path-var> <out-var>)
cmake_path(`HAS_ROOT_DIRECTORY`_ <path-var> <out-var>)
cmake_path(`HAS_ROOT_PATH`_ <path-var> <out-var>)
cmake_path(`HAS_FILENAME`_ <path-var> <out-var>)
cmake_path(`HAS_EXTENSION`_ <path-var> <out-var>)
cmake_path(`HAS_STEM`_ <path-var> <out-var>)
cmake_path(`HAS_RELATIVE_PATH`_ <path-var> <out-var>)
cmake_path(`HAS_PARENT_PATH`_ <path-var> <out-var>)
cmake_path(`IS_ABSOLUTE`_ <path-var> <out-var>)
cmake_path(`IS_RELATIVE`_ <path-var> <out-var>)
cmake_path(`IS_PREFIX`_ <path-var> <input> [NORMALIZE] <out-var>)
`Hashing`_
cmake_path(`HASH`_ <path-var> [NORMALIZE] <out-var>)
Decomposition
^^^^^^^^^^^^^
.. _GET:
.. _GET_ROOT_NAME:
.. code-block:: cmake
cmake_path(GET <path-var> ROOT_NAME <out-var>)
Returns the root name of the path. If the path does not include a root name,
returns an empty path.
.. note::
Only ``Windows`` system has the concept of ``root-name``, so on all other
systems, it is always an empty path.
For example:
.. code-block:: cmake
set (path "c:/a")
cmake_path (GET path ROOT_NAME output)
message ("Root name is \"${output}\"")
Will display::
Root name is "c:"
.. _GET_ROOT_DIRECTORY:
.. code-block:: cmake
cmake_path(GET <path-var> ROOT_DIRECTORY <out-var>)
Returns the root directory of the path. If the path does not include a root
directory, returns an empty path.
For example:
.. code-block:: cmake
set (path "c:/a")
cmake_path (GET path ROOT_DIRECTORY output)
message ("Root directory is \"${output}\"")
Will display::
Root directory is "/"
.. _GET_ROOT_PATH:
.. code-block:: cmake
cmake_path(GET <path-var> ROOT_PATH <out-var>)
Returns the root path of the path. If the path does not include a root path,
returns an empty path.
Effectively, returns the following: ``root-name root-directory``.
For example:
.. code-block:: cmake
set (path "c:/a")
cmake_path (GET path ROOT_PATH output)
message ("Root path is \"${output}\"")
Will display::
Root path is "c:/"
.. _GET_FILENAME:
.. code-block:: cmake
cmake_path(GET <path-var> FILENAME <out-var>)
Returns the :ref:`filename <FILENAME_DEF>` component of the path. If the path
ends with a ``directory-separator``, there is no filename, so returns an empty
path.
For example:
.. code-block:: cmake
set (path "/a")
cmake_path (GET path FILENAME output)
message ("First filename is \"${output}\"")
set (path "/a/")
cmake_path (GET path FILENAME output)
message ("Second filename is \"${output}\"")
Will display::
First filename is "a"
Second filename is ""
.. _GET_EXTENSION:
.. code-block:: cmake
cmake_path(GET <path-var> EXTENSION [LAST_ONLY] <out-var>)
Returns the :ref:`extension <EXTENSION_DEF>` of the filename component.
If the :ref:`filename <FILENAME_DEF>` component of the path contains a period
(``.``), and is not one of the special filesystem elements ``dot`` or
``dot-dot``, then the :ref:`extension <EXTENSION_DEF>` is returned.
For example:
.. code-block:: cmake
set (path "name.ext1.ext2")
cmake_path (GET path EXTENSION result)
message ("Full extension is \"${result}\"")
cmake_path (GET path EXTENSION LAST_ONLY result)
message ("Last extension is \"${result}\"")
Will display::
Full extension is ".ext1.ext2"
Last extension is ".ext2"
The following exceptions apply:
* If the first character in the filename is a period, that period is ignored
(a filename like ``".profile"`` is not treated as an extension).
* If the pathname is either ``.`` or ``..``, or if
:ref:`filename <FILENAME_DEF>` component does not contain the ``.``
character, then an empty path is returned.
.. _GET_STEM:
.. code-block:: cmake
cmake_path(GET <path-var> STEM [LAST_ONLY] <out-var>)
Returns the :ref:`filename <FILENAME_DEF>` component of the path stripped of
its :ref:`extension <EXTENSION_DEF>`.
For Example:
.. code-block:: cmake
set (path "name.ext1.ext2")
cmake_path (GET path STEM result)
message ("Filename without the extension is \"${result}\"")
cmake_path (GET path STEM LAST_ONLY result)
message ("Filename whiteout the last extension is \"${result}\"")
Will display::
Filename without the extension is "name"
Filename without the last extension is "name.ext1"
The following exceptions apply:
* If the first character in the filename is a period, that period is ignored
(a filename like ``".profile"`` is not treated as an extension).
* If the filename is one of the special filesystem components ``dot`` or
``dot-dot``, or if it has no periods, the function returns the entire
:ref:`filename <FILENAME_DEF>` component.
.. _GET_RELATIVE_PATH:
.. code-block:: cmake
cmake_path(GET <path-var> RELATIVE_PATH <out-var>)
Returns path relative to ``root-path``, that is, a pathname composed of
every component of ``<path-var>`` after ``root-path``. If ``<path-var>`` is
an empty path, returns an empty path.
For Example:
.. code-block:: cmake
set (path "/a/b")
cmake_path (GET path RELATIVE_PATH result)
message ("Relative path is \"${result}\"")
set (path "/")
cmake_path (GET path RELATIVE_PATH result)
message ("Relative path is \"${result}\"")
Will display::
Relative path is "a/b"
Relative path is ""
.. _GET_PARENT_PATH:
.. code-block:: cmake
cmake_path(GET <path-var> PARENT_PATH <out-var>)
Returns the path to the parent directory.
If `HAS_RELATIVE_PATH`_ sub-command returns false, the result is a copy of
``<path-var>``. Otherwise, the result is ``<path-var>`` with one fewer element.
For Example:
.. code-block:: cmake
set (path "c:/a/b")
cmake_path (GET path PARENT_PATH result)
message ("Parent path is \"${result}\"")
set (path "c:/")
cmake_path (GET path PARENT_PATH result)
message ("Parent path is \"${result}\"")
Will display::
Parent path is "c:/a"
Relative path is "c:/"
Modification
^^^^^^^^^^^^
.. _cmake_path-SET:
.. _SET:
.. code-block:: cmake
cmake_path(SET <path-var> [NORMALIZE] <input>)
Assign the ``<input>`` path to ``<path-var>``. Moreover, if ``<input>`` is a
native path, it is converted into cmake-style path with forward-slashes
(``/``). On Windows, the long filename marker is taken into account.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
For Example:
.. code-block:: cmake
set (native_path "c:\\a\\b/..\\c")
cmake_path (SET path "${native_path}")
message ("CMake path is \"${path}\"")
cmake_path (SET path NORMALIZE "${native_path}")
message ("Normalized CMake path is \"${path}\"")
Will display::
CMake path is "c:/a/b/../c"
Normalized CMake path is "c:/a/c"
.. _APPEND:
.. code-block:: cmake
cmake_path(APPEND <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
Append all the ``<input>`` arguments to the ``<path-var>`` using ``/`` as
``directory-separator``.
For each ``<input>`` argument, the following algorithm (pseudo-code) applies:
.. code-block:: cmake
# <path> is the contents of <path-var>
IF (<input>.is_absolute() OR
(<input>.has_root_name() AND
NOT <input>.root_name() STREQUAL <path>.root_name()))
replaces <path> with <input>
RETURN()
ENDIF()
IF (<input>.has_root_directory())
remove any root-directory and the entire relative path from <path>
ELSEIF (<path>.has_filename() OR
(NOT <path-var>.has_root_directory() OR <path>.is_absolute()))
appends directory-separator to <path>
ENDIF()
appends <input> omitting any root-name to <path>
.. _APPEND_STRING:
.. code-block:: cmake
cmake_path(APPEND_STRING <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
Append all the ``<input>`` arguments to the ``<path-var>`` without
``directory-separator``.
.. _REMOVE_FILENAME:
.. code-block:: cmake
cmake_path(REMOVE_FILENAME <path-var> [OUTPUT_VARIABLE <out-var>])
Removes the :ref:`filename <FILENAME_DEF>` component (as returned by
:ref:`GET ... FILENAME <GET_FILENAME>`) from ``<path-var>``.
After this function returns, if change is done in-place, `HAS_FILENAME`_
returns false for ``<path-var>``.
For Example:
.. code-block:: cmake
set (path "/a/b")
cmake_path (REMOVE_FILENAME path)
message ("First path is \"${path}\"")
cmake_path (REMOVE_FILENAME path)
message ("Second path is \"${result}\"")
Will display::
First path is "/a/"
Second path is "/a/"
.. _REPLACE_FILENAME:
.. code-block:: cmake
cmake_path(REPLACE_FILENAME <path-var> <input> [OUTPUT_VARIABLE <out-var>])
Replaces the :ref:`filename <FILENAME_DEF>` component from ``<path-var>`` with
``<input>``.
If ``<path-var>`` has no filename component (`HAS_FILENAME`_ returns false),
the path is unchanged.
Equivalent to the following:
.. code-block:: cmake
cmake_path(HAS_FILENAME path has_filename)
if (has_filename)
cmake_path(REMOVE_FILENAME path)
cmake_path(APPEND path "replacement");
endif()
.. _REMOVE_EXTENSION:
.. code-block:: cmake
cmake_path(REMOVE_EXTENSION <path-var> [LAST_ONLY]
[OUTPUT_VARIABLE <out-var>])
Removes the :ref:`extension <EXTENSION_DEF>`, if any, from ``<path-var>``.
.. _REPLACE_EXTENSION:
.. code-block:: cmake
cmake_path(REPLACE_EXTENSION <path-var> [LAST_ONLY] <input>
[OUTPUT_VARIABLE <out-var>])
Replaces the :ref:`extension <EXTENSION_DEF>` with ``<input>``.
1. If ``<path-var>`` has an :ref:`extension <EXTENSION_DEF>`
(`HAS_EXTENSION`_ is true), it is removed.
2. A ``dot`` character is appended to ``<path-var>``, if ``<input>`` is not
empty or does not begin with a ``dot`` character.
3. ``<input>`` is appended as if `APPEND_STRING`_ was used.
Equivalent to the following:
.. code-block:: cmake
cmake_path(REMOVE_EXTENSION path)
if (NOT "input" MATCHES "^\\.")
cmake_path(APPEND_STRING path ".")
endif()
cmake_path(APPEND_STRING path "input");
Generation
^^^^^^^^^^
.. _NORMAL_PATH:
.. code-block:: cmake
cmake_path(NORMAL_PATH <path-var> [OUTPUT_VARIABLE <out-var>])
Normalize ``<path-var>``.
A path can be normalized by following this algorithm:
1. If the path is empty, stop (normal form of an empty path is an empty
path).
2. Replace each ``directory-separator`` (which may consist of multiple
separators) with a single ``/``.
3. Replace each ``directory-separator`` character in the ``root-name`` with
``/``.
4. Remove each ``dot`` and any immediately following ``directory-separator``.
5. Remove each non-dot-dot filename immediately followed by a
``directory-separator`` and a ``dot-dot``, along with any immediately
following ``directory-separator``.
6. If there is ``root-directory``, remove all ``dot-dots`` and any
``directory-separators`` immediately following them.
7. If the last filename is ``dot-dot``, remove any trailing
``directory-separator``.
8. If the path is empty, add a ``dot`` (normal form of ``./`` is ``.``).
.. _cmake_path-RELATIVE_PATH:
.. _RELATIVE_PATH:
.. code-block:: cmake
cmake_path(RELATIVE_PATH <path-var> [BASE_DIRECTORY <input>]
[OUTPUT_VARIABLE <out-var>])
Returns ``<path-var>`` made relative to ``BASE_DIRECTORY`` argument. If
``BASE_DIRECTORY`` is not specified, the default base directory will be
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
For reference, the algorithm used to compute the relative path is described
`here <https://en.cppreference.com/w/cpp/filesystem/path/lexically_normal>`_.
.. _ABSOLUTE_PATH:
.. code-block:: cmake
cmake_path(ABSOLUTE_PATH <path-var> [BASE_DIRECTORY <input>] [NORMALIZE]
[OUTPUT_VARIABLE <out-var>])
If ``<path-var>`` is a relative path (`IS_RELATIVE`_ is true), it is evaluated
relative to the given base directory specified by ``BASE_DIRECTORY`` option.
If ``BASE_DIRECTORY`` is not specifired, the default base directory will be
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` after the path computation.
Because ``cmake_path`` does not access to the filesystem, symbolic links are
not resolved. To compute a real path, use :command:`file(REAL_PATH)`
command.
Conversion
^^^^^^^^^^
.. _cmake_path-NATIVE_PATH:
.. _NATIVE_PATH:
.. code-block:: cmake
cmake_path(NATIVE_PATH <path-var> [NORMALIZE] <out-var>)
Converts a cmake-style ``<path-var>`` into a native
path with platform-specific slashes (``\`` on Windows and ``/`` elsewhere).
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
.. _CONVERT:
.. _cmake_path-TO_CMAKE_PATH_LIST:
.. _TO_CMAKE_PATH_LIST:
.. code-block:: cmake
cmake_path(CONVERT <input> TO_CMAKE_PATH_LIST <out-var> [NORMALIZE])
Converts a native ``<input>`` path into cmake-style path with forward-slashes
(``/``). On Windows, the long filename marker is taken into account. The input
can be a single path or a system search path like ``$ENV{PATH}``. A search
path will be converted to a cmake-style list separated by ``;`` characters. The
result of the conversion is stored in the ``<out-var>`` variable.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
.. _cmake_path-TO_NATIVE_PATH_LIST:
.. _TO_NATIVE_PATH_LIST:
.. code-block:: cmake
cmake_path(CONVERT <input> TO_NATIVE_PATH_LIST <out-var> [NORMALIZE])
Converts a cmake-style ``<input>`` path into a native path with
platform-specific slashes (``\`` on Windows and ``/`` elsewhere). The input can
be a single path or a cmake-style list. A list will be converted into a native
search path. The result of the conversion is stored in the ``<out-var>``
variable.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
For Example:
.. code-block:: cmake
set (paths "/a/b/c" "/x/y/z")
cmake_path (CONVERT "${paths}" TO_NATIVE_PATH_LIST native_paths)
message ("Native path list is \"${native_paths}\"")
Will display, on Windows::
Native path list is "\a\b\c;\x\y\z"
And on the all other systems::
Native path list is "/a/b/c:/x/y/z"
Comparison
^^^^^^^^^^
.. _COMPARE:
.. code-block:: cmake
cmake_path(COMPARE <input1> EQUAL <input2> <out-var>)
cmake_path(COMPARE <input1> NOT_EQUAL <input2> <out-var>)
Compares the lexical representations of the path and another path.
For testing equality, the following algorithm (pseudo-code) apply:
.. code-block:: cmake
IF (NOT <input1>.root_name() STREQUAL <input2>.root_name())
returns FALSE
ELSEIF (<input1>.has_root_directory() XOR <input2>.has_root_directory())
returns FALSE
ENDIF()
returns TRUE or FALSE if the relative portion of <input1> is
lexicographically equal or not to the relative portion of <input2>.
Comparison is performed path component-wise
Query
^^^^^
.. _HAS_ROOT_NAME:
.. code-block:: cmake
cmake_path(HAS_ROOT_NAME <path-var> <out-var>)
Checks if ``<path-var>`` has ``root-name``.
.. _HAS_ROOT_DIRECTORY:
.. code-block:: cmake
cmake_path(HAS_ROOT_DIRECTORY <path-var> <out-var>)
Checks if ``<path-var>`` has ``root-directory``.
.. _HAS_ROOT_PATH:
.. code-block:: cmake
cmake_path(HAS_ROOT_PATH <path-var> <out-var>)
Checks if ``<path-var>`` has root path.
Effectively, checks if ``<path-var>`` has ``root-name`` and ``root-directory``.
.. _HAS_FILENAME:
.. code-block:: cmake
cmake_path(HAS_FILENAME <path-var> <out-var>)
Checks if ``<path-var>`` has a :ref:`filename <FILENAME_DEF>`.
.. _HAS_EXTENSION:
.. code-block:: cmake
cmake_path(HAS_EXTENSION <path-var> <out-var>)
Checks if ``<path-var>`` has an :ref:`extension <EXTENSION_DEF>`. If the first
character in the filename is a period, it is not treated as an extension (for
example ".profile").
.. _HAS_STEM:
.. code-block:: cmake
cmake_path(HAS_STEM <path-var> <out-var>)
Checks if ``<path-var>`` has stem (:ref:`GET ... STEM <GET_STEM>` returns a non
empty path).
.. _HAS_RELATIVE_PATH:
.. code-block:: cmake
cmake_path(HAS_RELATIVE_PATH <path-var> <out-var>)
Checks if ``<path-var>`` has relative path (`GET_RELATIVE_PATH`_ returns a
non-empty path).
.. _HAS_PARENT_PATH:
.. code-block:: cmake
cmake_path(HAS_PARENT_PATH <path-var> <out-var>)
Checks if ``<path-var>`` has parent path. The result is true except if the path
is only composed of a :ref:`filename <FILENAME_DEF>`.
.. _IS_ABSOLUTE:
.. code-block:: cmake
cmake_path(IS_ABSOLUTE <path-var> <out-var>)
Checks if ``<path-var>`` is absolute.
An absolute path is a path that unambiguously identifies the location of a file
without reference to an additional starting location.
.. _IS_RELATIVE:
.. code-block:: cmake
cmake_path(IS_RELATIVE <path-var> <out-var>)
Checks if path is relative (i.e. not :ref:`absolute <IS_ABSOLUTE>`).
.. _IS_PREFIX:
.. code-block:: cmake
cmake_path(IS_PREFIX <path-var> <input> [NORMALIZE] <out-var>)
Checks if ``<path-var>`` is the prefix of ``<input>``.
When ``NORMALIZE`` option is specified, the paths are :ref:`normalized
<NORMAL_PATH>` before the check.
Hashing
^^^^^^^
.. _HASH:
.. code-block:: cmake
cmake_path(HASH <path-var> [NORMALIZE] <out-var>)
Compute hash value of ``<path-var>`` such that if for two paths (``p1`` and
``p2``) are equal (:ref:`COMPARE ... EQUAL <COMPARE>`) then hash value of p1 is
equal to hash value of p2.
When ``NORMALIZE`` option is specified, the paths are :ref:`normalized
<NORMAL_PATH>` before the check.

View File

@@ -28,6 +28,9 @@ encourage projects to set policies based on CMake versions:
cmake_policy(VERSION <min>[...<max>])
.. versionadded:: 3.12
The optional ``<max>`` version.
``<min>`` and the optional ``<max>`` are each CMake versions of the form
``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.

View File

@@ -6,8 +6,9 @@ Copy a file to another location and modify its contents.
.. code-block:: cmake
configure_file(<input> <output>
[FILE_PERMISSIONS <permissions>...]
[COPYONLY] [ESCAPE_QUOTES] [@ONLY]
[NO_SOURCE_PERMISSIONS]
[NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]
[NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
Copies an ``<input>`` file to an ``<output>`` file and substitutes
@@ -37,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.
Input file lines of the form ``#cmakedefine01 VAR`` will be replaced with
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
# cmakedefine01 VAR
.. code-block:: c
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
# define VAR 1
.. code-block:: c
# define VAR
# define VAR 1
If the input file is modified the build system will re-run CMake to
re-configure the file and generate the build system again.
@@ -72,6 +75,9 @@ The arguments are:
If the path names an existing directory the output file is placed
in that directory with the same file name as the input file.
``FILE_PERMISSIONS <permissions>...``
Use user provided permissions for the output file.
``COPYONLY``
Copy the file without replacing any variable references or other
content. This option may not be used with ``NEWLINE_STYLE``.
@@ -84,10 +90,17 @@ The arguments are:
This is useful for configuring scripts that use ``${VAR}`` syntax.
``NO_SOURCE_PERMISSIONS``
.. versionadded:: 3.19
Does not transfer the file permissions of the original file to the copy.
The copied file permissions default to the standard 644 value
(-rw-r--r--).
``USE_SOURCE_PERMISSIONS``
.. versionadded:: 3.20
Transfer the file permissions of the original file to the output file.
``NEWLINE_STYLE <style>``
Specify the newline style for the output file. Specify
``UNIX`` or ``LF`` for ``\n`` newlines, or specify

View File

@@ -50,7 +50,10 @@ The options are:
for an example.
``PROJECT_NAME <project-name>``
Ignored. This was once used but is no longer needed.
Ignored since CMake 3.0.
.. versionchanged:: 3.14
This value is no longer required.
``TARGET <target-name>``
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.
``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
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.
``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error output that would have been
printed to the console otherwise. The summary of warnings / errors,
as well as the output from the native build tool is unaffected by

View File

@@ -37,10 +37,14 @@ The options are:
configuration tool.
``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
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.
``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error messages that would have
otherwise been printed to the console. Output from the underlying
configure command is not affected.

View File

@@ -37,10 +37,14 @@ The options are:
ran without error and non-zero otherwise.
``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
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.
``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error output that would have been
printed to the console otherwise. The summary indicating how many
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:
``DEFECT_COUNT <defect-count-var>``
.. versionadded:: 3.8
Store in the ``<defect-count-var>`` the number of defects found.

View File

@@ -29,8 +29,11 @@ The parameters are as follows:
``GROUP <group>``
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
default. This replaces the deprecated option ``TRACK``. Despite the name
change its behavior is unchanged.
default.
.. versionchanged:: 3.16
This replaces the deprecated option ``TRACK``. Despite the name
change its behavior is unchanged.
``APPEND``
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.
``QUIET``
.. versionadded:: 3.3
If ``QUIET`` is used, CTest will suppress any non-error messages that it
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.
``SUBMIT_URL <url>``
.. versionadded:: 3.14
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.
``BUILD_ID <result-var>``
.. versionadded:: 3.15
Store in the ``<result-var>`` variable the ID assigned to this build by
CDash.
``HTTPHEADER <HTTP-header>``
.. versionadded:: 3.9
Specify HTTP header to be included in the request to CDash during submission.
For example, CDash can be configured to only accept submissions from
authenticated clients. In this case, you should provide a bearer token in your
@@ -73,20 +79,27 @@ The options are:
non-zero on failure.
``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.13
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.
``QUIET``
.. versionadded:: 3.3
Suppress all non-error messages that would have otherwise been
printed to the console.
Submit to CDash Upload API
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.2
::
ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>]
[SUBMIT_URL <url>]
[BUILD_ID <result-var>]
[HTTPHEADER <header>]
[RETRY_COUNT <count>]
[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
to tell CDash which handler to use to process the data.
This signature accepts the ``SUBMIT_URL``, ``BUILD_ID``, ``HTTPHEADER``,
``RETRY_COUNT``, ``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options
as described above.
This signature interprets options in the same way as the first one.
.. 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.
``EXCLUDE_FIXTURE <regex>``
.. versionadded:: 3.7
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
set automatically. This option prevents adding setup or cleanup tests for
@@ -76,9 +78,13 @@ The options are:
setup tests that fail.
``EXCLUDE_FIXTURE_SETUP <regex>``
.. versionadded:: 3.7
Same as ``EXCLUDE_FIXTURE`` except only matching setup tests are excluded.
``EXCLUDE_FIXTURE_CLEANUP <regex>``
.. versionadded:: 3.7
Same as ``EXCLUDE_FIXTURE`` except only matching cleanup tests are excluded.
``PARALLEL_LEVEL <level>``
@@ -86,11 +92,15 @@ The options are:
be run in parallel.
``RESOURCE_SPEC_FILE <file>``
.. versionadded:: 3.16
Specify a
:ref:`resource specification file <ctest-resource-specification-file>`. See
:ref:`ctest-resource-allocation` for more information.
``TEST_LOAD <threshold>``
.. versionadded:: 3.4
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
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`.
``REPEAT <mode>:<n>``
.. versionadded:: 3.17
Run tests repeatedly based on the given ``<mode>`` up to ``<n>`` times.
The modes are:
@@ -121,6 +133,8 @@ The options are:
implicit test dependencies.
``STOP_ON_FAILURE``
.. versionadded:: 3.18
Stop the execution of the tests once one has failed.
``STOP_TIME <time-of-day>``
@@ -131,10 +145,14 @@ The options are:
Store non-zero if anything went wrong.
``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
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.
``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error messages that would have otherwise
been printed to the console. Output from the underlying test command is not
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.
``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.13
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.
``QUIET``
.. versionadded:: 3.3
Tell CTest to suppress most non-error messages that it would
have otherwise printed to the console. CTest will still report
the new revision of the repository and any conflicting files

View File

@@ -14,9 +14,13 @@ The options are:
dashboard server.
``QUIET``
.. versionadded:: 3.3
Suppress any CTest-specific non-error output that would have been
printed to the console otherwise.
``CAPTURE_CMAKE_ERROR <result-var>``
.. versionadded:: 3.7
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.

View File

@@ -12,6 +12,15 @@ variables that are created by the project command. Example languages
are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``,
``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
compilers for other languages like ``C`` work for assembly too.

View File

@@ -62,6 +62,8 @@ Options:
describing an error condition.
``RESULTS_VARIABLE <variable>``
.. versionadded:: 3.10
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
given ``COMMAND`` arguments. Each entry will be an integer return code
@@ -75,19 +77,26 @@ Options:
``INPUT_FILE, OUTPUT_FILE``, ``ERROR_FILE``
The file named will be attached to the standard input of the first
process, standard output of the last process, or standard error of
all processes, respectively. If the same file is named for both
output and error then it will be used for both.
all processes, respectively.
.. 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``
The standard output or standard error results will be quietly ignored.
``COMMAND_ECHO <where>``
.. versionadded:: 3.15
The command being run will be echo'ed to ``<where>`` with ``<where>``
being set to one of ``STDERR``, ``STDOUT`` or ``NONE``.
See the :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ECHO` variable for a way
to control the default behavior when this option is not present.
``ENCODING <name>``
.. versionadded:: 3.8
On Windows, the encoding that is used to decode output from the process.
Ignored on other platforms.
Valid encoding names are:
@@ -104,11 +113,15 @@ Options:
``OEM``
Use the original equipment manufacturer (OEM) code page.
``UTF8`` or ``UTF-8``
Use the UTF-8 codepage. Prior to CMake 3.11.0, only ``UTF8`` was accepted
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.
Use the UTF-8 codepage.
.. 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``
.. versionadded:: 3.18
The standard output or standard error will not be exclusively redirected to
the configured variables.
@@ -118,6 +131,8 @@ Options:
This is analogous to the ``tee`` Unix command.
``COMMAND_ERROR_IS_FATAL <ANY|LAST>``
.. versionadded:: 3.19
The option following ``COMMAND_ERROR_IS_FATAL`` determines the behavior when
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
registry.
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.
.. versionchanged:: 3.1
If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable
is enabled, the ``export(PACKAGE)`` command will do nothing.
.. versionchanged:: 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
export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>])
.. versionadded:: 3.7
This signature exports cmake built targets to the android ndk build system
by creating an Android.mk file that references the prebuilt targets. The
Android NDK supports the use of prebuilt libraries, both static and shared.

View File

@@ -3,6 +3,21 @@ file
File manipulation command.
This command is dedicated to file and path manipulation requiring access to the
filesystem.
For other path manipulation, handling only syntactic aspects, have a look at
:command:`cmake_path` command.
.. note::
The sub-commands `RELATIVE_PATH`_, `TO_CMAKE_PATH`_ and `TO_NATIVE_PATH`_ has
been superseded, respectively, by sub-commands
:ref:`RELATIVE_PATH <cmake_path-RELATIVE_PATH>`,
:ref:`CONVERT ... TO_CMAKE_PATH_LIST <cmake_path-TO_CMAKE_PATH_LIST>` and
:ref:`CONVERT ... TO_NATIVE_PATH_LIST <cmake_path-TO_NATIVE_PATH_LIST>` of
:command:`cmake_path` command.
Synopsis
^^^^^^^^
@@ -103,10 +118,15 @@ Parse a list of ASCII strings from ``<filename>`` and store it in
Consider only strings that match the given regular expression.
``ENCODING <encoding-type>``
.. versionadded:: 3.1
Consider strings of a given encoding. Currently supported encodings are:
UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE. If the ENCODING option
is not provided and the file has a Byte Order Mark, the ENCODING option
will be defaulted to respect the Byte Order Mark.
``UTF-8``, ``UTF-16LE``, ``UTF-16BE``, ``UTF-32LE``, ``UTF-32BE``.
If the ``ENCODING`` option is not provided and the file has a 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
@@ -160,6 +180,8 @@ the ``<format>`` and ``UTC`` options.
[POST_EXCLUDE_REGEXES [<regexes>...]]
)
.. versionadded:: 3.16
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.
@@ -408,6 +430,9 @@ dependency resolution:
If this variable is not specified, it is determined by the value of
``CMAKE_OBJDUMP`` if set, else by system introspection.
.. versionadded:: 3.18
Use ``CMAKE_OBJDUMP`` if set.
Writing
^^^^^^^
@@ -436,6 +461,8 @@ to update the file only when its content changes.
file(TOUCH [<files>...])
file(TOUCH_NOCREATE [<files>...])
.. versionadded:: 3.12
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
function call is executed.
@@ -469,8 +496,10 @@ from the input content to produce the output content. The options are:
``INPUT <input-file>``
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`.
.. versionchanged:: 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>``
Specify the output file name to generate. Use generator expressions
@@ -478,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
if the generated content is identical. Otherwise, the ``<output-file>``
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`.
See policy :policy:`CMP0070`.
.. versionchanged:: 3.10
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>``
.. versionadded:: 3.19
Specify which target to use when evaluating generator expressions that
require a target for evaluation (e.g. ``$<COMPILE_FEATURES:...>``,
``$<TARGET_PROPERTY:prop>``).
@@ -506,6 +539,8 @@ of a project's ``CMakeLists.txt`` files.
[ESCAPE_QUOTES] [@ONLY]
[NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
.. versionadded:: 3.18
Generate an output file using the input given by ``CONTENT`` and substitute
variable values referenced as ``@VAR@`` or ``${VAR}`` contained therein. The
substitution rules behave the same as the :command:`configure_file` command.
@@ -554,20 +589,25 @@ Generate a list of files that match the ``<globbing-expressions>`` and
store it into the ``<variable>``. Globbing expressions are similar to
regular expressions, but much simpler. If ``RELATIVE`` flag is
specified, the results will be returned as relative paths to the given
path. The results will be ordered lexicographically.
path.
.. versionchanged:: 3.6
The results will be ordered lexicographically.
On Windows and macOS, globbing is case-insensitive even if the underlying
filesystem is case-sensitive (both filenames and globbing expressions are
converted to lowercase before matching). On other platforms, globbing is
case-sensitive.
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.
.. versionadded:: 3.3
By default ``GLOB`` lists directories - directories are omitted in result if
``LIST_DIRECTORIES`` is set to false.
By default ``GLOB`` lists directories - directories are omitted in result if
``LIST_DIRECTORIES`` is set to false.
.. versionadded:: 3.12
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::
We do not recommend using GLOB to collect a list of source files from
@@ -590,10 +630,11 @@ matched directory and match the files. Subdirectories that are symlinks
are only traversed if ``FOLLOW_SYMLINKS`` is given or policy
:policy:`CMP0009` is not set to ``NEW``.
By default ``GLOB_RECURSE`` omits directories from result list - setting
``LIST_DIRECTORIES`` to true adds directories to result list.
If ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to
``NEW`` then ``LIST_DIRECTORIES`` treats symlinks as directories.
.. versionadded:: 3.3
By default ``GLOB_RECURSE`` omits directories from result list - setting
``LIST_DIRECTORIES`` to true adds directories to result list.
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::
@@ -619,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
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
to the current source directory. Empty input paths are ignored with a warning.
to the current source directory.
.. versionchanged:: 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:
@@ -652,17 +698,18 @@ at the destination with the same timestamp. Copying preserves input
permissions unless explicit permissions or ``NO_SOURCE_PERMISSIONS``
are given (default is ``USE_SOURCE_PERMISSIONS``).
If ``FOLLOW_SYMLINK_CHAIN`` is specified, ``COPY`` will recursively resolve
the symlinks at the paths given until a real file is found, and install
a corresponding symlink in the destination for each symlink encountered. For
each symlink that is installed, the resolution is stripped of the directory,
leaving only the filename, meaning that the new symlink points to a file in
the same directory as the symlink. This feature is useful on some Unix systems,
where libraries are installed as a chain of symlinks with version numbers, with
less specific versions pointing to more specific versions.
``FOLLOW_SYMLINK_CHAIN`` will install all of these symlinks and the library
itself into the destination directory. For example, if you have the following
directory structure:
.. versionadded:: 3.15
If ``FOLLOW_SYMLINK_CHAIN`` is specified, ``COPY`` will recursively resolve
the symlinks at the paths given until a real file is found, and install
a corresponding symlink in the destination for each symlink encountered. For
each symlink that is installed, the resolution is stripped of the directory,
leaving only the filename, meaning that the new symlink points to a file in
the same directory as the symlink. This feature is useful on some Unix systems,
where libraries are installed as a chain of symlinks with version numbers, with
less specific versions pointing to more specific versions.
``FOLLOW_SYMLINK_CHAIN`` will install all of these symlinks and the library
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 -> libfoo.so.1.2.3``
@@ -696,6 +743,8 @@ use this signature (with some undocumented options for internal use).
file(SIZE <filename> <variable>)
.. versionadded:: 3.14
Determine the file size of the ``<filename>`` and put the result in
``<variable>`` variable. Requires that ``<filename>`` is a valid path
pointing to a file and is readable.
@@ -706,6 +755,8 @@ pointing to a file and is readable.
file(READ_SYMLINK <linkname> <variable>)
.. versionadded:: 3.14
This subcommand queries the symlink ``<linkname>`` and stores the path it
points to in the result ``<variable>``. If ``<linkname>`` does not exist or
is not a symlink, CMake issues a fatal error.
@@ -730,6 +781,8 @@ absolute path is obtained:
file(CREATE_LINK <original> <linkname>
[RESULT <result>] [COPY_ON_ERROR] [SYMBOLIC])
.. versionadded:: 3.14
Create a link ``<linkname>`` that points to ``<original>``.
It will be a hard link by default, but providing the ``SYMBOLIC`` option
results in a symbolic link instead. Hard links require that ``original``
@@ -754,6 +807,8 @@ which would make them unable to support a hard link.
[FILE_PERMISSIONS <permissions>...]
[DIRECTORY_PERMISSIONS <permissions>...])
.. versionadded:: 3.19
Set the permissions for the ``<files>...`` and ``<directories>...`` specified.
Valid permissions are ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``,
``GROUP_READ``, ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``,
@@ -790,6 +845,8 @@ Valid combination of keywords are:
[FILE_PERMISSIONS <permissions>...]
[DIRECTORY_PERMISSIONS <permissions>...])
.. versionadded:: 3.19
Same as `CHMOD`_, but change the permissions of files and directories present in
the ``<directories>...`` recursively.
@@ -802,6 +859,8 @@ Path Conversion
file(REAL_PATH <path> <out-var> [BASE_DIRECTORY <dir>])
.. versionadded:: 3.19
Compute the absolute path to an existing file or directory with symlinks
resolved.
@@ -849,10 +908,12 @@ Transfer
file(UPLOAD <file> <url> [<options>...])
The ``DOWNLOAD`` subcommand downloads the given ``<url>`` to a local ``<file>``.
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. The ``UPLOAD``
mode uploads a local ``<file>`` to a given ``<url>``.
The ``UPLOAD`` mode uploads a local ``<file>`` to a given ``<url>``.
.. versionadded:: 3.19
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:
@@ -877,12 +938,18 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
Terminate the operation after a given total time has elapsed.
``USERPWD <username>:<password>``
.. versionadded:: 3.7
Set username and password for operation.
``HTTPHEADER <HTTP-header>``
.. versionadded:: 3.7
HTTP header for operation. Suboption can be repeated several times.
``NETRC <level>``
.. versionadded:: 3.11
Specify whether the .netrc file is to be used for operation. If this
option is not specified, the value of the ``CMAKE_NETRC`` variable
will be used instead.
@@ -899,6 +966,8 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
The .netrc file is required, and information in the URL is ignored.
``NETRC_FILE <file>``
.. versionadded:: 3.11
Specify an alternative .netrc file to the one in your home directory,
if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option
is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will
@@ -911,9 +980,15 @@ If neither ``NETRC`` option is given CMake will check variables
Specify whether to verify the server certificate for ``https://`` URLs.
The default is to *not* verify.
.. versionadded:: 3.18
Added support to ``file(UPLOAD)``.
``TLS_CAINFO <file>``
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``
certificates are not checked by default. Set ``TLS_VERIFY`` to ``ON`` to
check certificates. If neither ``TLS`` option is given CMake will check
@@ -944,6 +1019,8 @@ Locking
[RESULT_VARIABLE <variable>]
[TIMEOUT <seconds>])
.. versionadded:: 3.2
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
``GUARD`` option (default value is ``PROCESS``). ``RELEASE`` option can be used
@@ -979,6 +1056,8 @@ Archiving
[MTIME <mtime>]
[VERBOSE])
.. versionadded:: 3.18
Creates the specified ``<archive>`` file with the files and directories
listed in ``<paths>``. Note that ``<paths>`` must list actual files or
directories, wildcards are not supported.
@@ -993,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
``<compression>`` are ``None``, ``BZip2``, ``GZip``, ``XZ``, and ``Zstd``.
The compression level can be specified with the ``COMPRESSION_LEVEL`` option.
The ``<compression-level>`` should be between 0-9, with the default being 0.
The ``COMPRESSION`` option must be present when ``COMPRESSION_LEVEL`` is given.
.. versionadded:: 3.19
The compression level can be specified with the ``COMPRESSION_LEVEL`` option.
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::
With ``FORMAT`` set to ``raw`` only one file will be compressed with the
@@ -1016,6 +1096,8 @@ the ``MTIME`` option.
[LIST_ONLY]
[VERBOSE])
.. versionadded:: 3.18
Extracts or lists the content of the specified ``<archive>``.
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
enabled.
1. Search paths specified in the :variable:`<PackageName>_ROOT` CMake
variable and the :envvar:`<PackageName>_ROOT` environment variable,
where ``<PackageName>`` is the package to be found.
The package root variables are maintained as a stack so if
called from within a find module, root paths from the parent's find
module will also be searched after paths for the current package.
This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
See policy :policy:`CMP0074`.
1. .. versionadded:: 3.12
Search paths specified in the :variable:`<PackageName>_ROOT` CMake
variable and the :envvar:`<PackageName>_ROOT` environment variable,
where ``<PackageName>`` is the package to be found.
The package root variables are maintained as a stack so if
called from within a find module, root paths from the parent's find
module will also be searched after paths for the current package.
This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
See policy :policy:`CMP0074`.
2. Search paths specified in cmake-specific cache variables. These
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
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_ARGS_XXX| replace:: <PackageName>
.. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace::

View File

@@ -88,6 +88,8 @@ yields
foreach(<loop_var>... IN ZIP_LISTS <lists>)
.. versionadded:: 3.17
In this variant, ``<lists>`` is a whitespace or semicolon
separated list of list-valued variables. The ``foreach``
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
all-lowercase names.
The :command:`cmake_language(CALL ...)` command can also be used to
invoke the function.
.. versionadded:: 3.18
The :command:`cmake_language(CALL ...)` command can also be used to
invoke the function.
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
to retrieve the property value instead of the current directory.
It may reference either a source directory, or since CMake 3.19,
a binary directory. Relative paths are treated as relative to the
Relative paths are treated as relative to the
current source directory. CMake must already know about the directory,
either by having added it through a call to :command:`add_subdirectory`
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,
an empty string is returned. In the case of ``INHERITED`` properties,
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.
.. versionchanged:: 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
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 with neither the directory nor the last extension
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.
If the optional ``CACHE`` argument is specified, the result variable is
added to the cache.
@@ -27,6 +35,8 @@ added to the 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
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
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.
.. note::
The ``REALPATH`` and ``PROGRAM`` subcommands had been superseded,
respectively, by :ref:`file(REAL_PATH) <REAL_PATH>` and
:command:`separate_arguments(PROGRAM)` commands.

View File

@@ -30,35 +30,43 @@ It must be one of the following:
``DIRECTORY``
Scope defaults to the current directory but another
directory (already processed by CMake) may be named by the
full or relative path ``<dir>``. The ``<dir>`` may reference either a
source directory, or since CMake 3.19, a binary directory.
full or relative path ``<dir>``.
Relative paths are treated as relative to the current source directory.
See also the :command:`get_directory_property` command.
.. versionadded:: 3.19
``<dir>`` may reference a binary directory.
``TARGET``
Scope must name one existing target.
See also the :command:`get_target_property` command.
``SOURCE``
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
overridden with one of the following sub-options:
will be read from the current source directory's scope.
``DIRECTORY <dir>``
The source file property will be read from the ``<dir>`` directory's
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.
.. versionadded:: 3.18
Directory scope can be overridden with one of the following sub-options:
``TARGET_DIRECTORY <target>``
The source file property will be read from the directory scope in which
``<target>`` was created (``<target>`` must therefore already exist).
``DIRECTORY <dir>``
The source file property will be read from the ``<dir>`` directory's
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.
``INSTALL``
.. versionadded:: 3.1
Scope must name one installed file path.
``TEST``
@@ -86,3 +94,8 @@ If ``BRIEF_DOCS`` or ``FULL_DOCS`` is given then the variable is set to a
string containing documentation for the requested property. If
documentation is requested for a property that has not been defined
``NOTFOUND`` is returned.
.. note::
The :prop_sf:`GENERATED` source file property may be globally visible.
See its documentation for details.

View File

@@ -19,22 +19,29 @@ command and if still unable to find the property, ``variable`` will be set to
an empty string.
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
sub-options:
directory's scope.
``DIRECTORY <dir>``
The source file property will be read from the ``<dir>`` directory's
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.
.. versionadded:: 3.18
Directory scope can be overridden with one of the following sub-options:
``TARGET_DIRECTORY <target>``
The source file property will be read from the directory scope in which
``<target>`` was created (``<target>`` must therefore already exist).
``DIRECTORY <dir>``
The source file property will be read from the ``<dir>`` directory's
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
file properties usually control how the file is built. One property that is
always there is :prop_sf:`LOCATION`.
See also the more general :command:`get_property` command.
.. note::
The :prop_sf:`GENERATED` source file property may be globally visible.
See its documentation for details.

View File

@@ -85,8 +85,9 @@ Possible conditions are:
(in any directory).
``if(TEST test-name)``
True if the given name is an existing test name created by the
:command:`add_test` command.
.. versionadded:: 3.3
True if the given name is an existing test name created by the
:command:`add_test` command.
``if(EXISTS path-to-file-or-directory)``
True if the named file or directory exists. Behavior is well-defined
@@ -116,7 +117,9 @@ Possible conditions are:
``if(<variable|string> MATCHES regex)``
True if the given string or variable's value matches the given regular
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>)``
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.
``if(<variable|string> LESS_EQUAL <variable|string>)``
True if the given string or variable's value is a valid number and less
than or equal to that on the right.
.. versionadded:: 3.7
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>)``
True if the given string or variable's value is a valid number and greater
than or equal to that on the right.
.. versionadded:: 3.7
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>)``
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.
``if(<variable|string> STRLESS_EQUAL <variable|string>)``
True if the given string or variable's value is lexicographically less
than or equal to the string or variable on the right.
.. versionadded:: 3.7
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>)``
True if the given string or variable's value is lexicographically greater
than or equal to the string or variable on the right.
.. versionadded:: 3.7
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>)``
Component-wise integer version number comparison (version format is
@@ -177,25 +184,31 @@ Possible conditions are:
component effectively truncates the string at that point.
``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
.. versionadded:: 3.7
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
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>)``
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
.. versionadded:: 3.7
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
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>)``
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>})``
True if a variable, cache variable or environment variable
with given ``<name>`` is defined. The value of the variable
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)))``
The conditions inside the parenthesis are evaluated first and then
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
such, otherwise they are assumed to be variables and are dereferenced.
To prevent ambiguity, potential variable or keyword names can be
specified in a :ref:`Quoted Argument` or a :ref:`Bracket Argument`.
A quoted or bracketed variable or keyword will be interpreted as a
string and not dereferenced or interpreted.
See policy :policy:`CMP0054`.
.. versionchanged:: 3.1
To prevent ambiguity, potential variable or keyword names can be
specified in a :ref:`Quoted Argument` or a :ref:`Bracket Argument`.
A quoted or bracketed variable or keyword will be interpreted as a
string and not dereferenced or interpreted.
See policy :policy:`CMP0054`.
There is no automatic evaluation for environment or cache
: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
other than the default (e.g. WIX projects).
If the imported project has different configuration names than the
current project, set the :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>`
target property to specify the mapping.
.. versionadded:: 3.9
If the imported project has different configuration names than the
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
specified by calls to the ``install()`` command within a source directory
are executed in order during installation. 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`).
are executed in order during installation.
.. versionchanged:: 3.14
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
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.
``EXCLUDE_FROM_ALL``
.. versionadded:: 3.6
Specify that the file is excluded from a full installation and only
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
not exist.
Command signatures that install files may print messages during
installation. Use the :variable:`CMAKE_INSTALL_MESSAGE` variable
to control which messages are printed.
.. versionadded:: 3.1
Command signatures that install files may print messages during
installation. Use the :variable:`CMAKE_INSTALL_MESSAGE` variable
to control which messages are printed.
Many of the ``install()`` variants implicitly create the directories
containing the installed files. If
:variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` is set, these
directories will be created with the permissions specified. Otherwise,
they will be created according to the uname rules on Unix-like platforms.
Windows platforms are unaffected.
.. versionadded:: 3.11
Many of the ``install()`` variants implicitly create the directories
containing the installed files. If
:variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` is set, these
directories will be created with the permissions specified. Otherwise,
they will be created according to the uname rules on Unix-like platforms.
Windows platforms are unaffected.
Installing Targets
^^^^^^^^^^^^^^^^^^
@@ -162,6 +169,8 @@ that may be installed:
accompanying import libraries are of kind ``ARCHIVE``).
``OBJECTS``
.. versionadded:: 3.9
Object files associated with *object libraries*.
``FRAMEWORK``
@@ -246,6 +255,8 @@ In addition to the common options listed above, each target can accept
the following additional arguments:
``NAMELINK_COMPONENT``
.. versionadded:: 3.12
On some platforms a versioned shared library has a symbolic link such
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
set to ``TRUE`` has undefined behavior.
`install(TARGETS)`_ can install targets that were created in
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.
.. versionadded:: 3.3
An install destination given as a ``DESTINATION`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
An install destination given as a ``DESTINATION`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
.. versionadded:: 3.13
`install(TARGETS)`_ can install targets that were created in
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
^^^^^^^^^^^^^^^^
@@ -455,9 +468,10 @@ this advice while installing headers to a project-specific subdirectory:
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
)
An install destination given as a ``DESTINATION`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
.. versionadded:: 3.4
An install destination given as a ``DESTINATION`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
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
``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
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
the appropriate cache variables.
The list of ``dirs...`` given to ``DIRECTORY`` and an install destination
given as a ``DESTINATION`` argument may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions.
.. versionadded:: 3.4
An install destination given as a ``DESTINATION`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
: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
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -610,10 +629,11 @@ example, the code
will print a message during installation.
``<file>`` or ``<code>`` may use "generator expressions" with the syntax
``$<...>`` (in the case of ``<file>``, this refers to their use in the file
name, not the file's contents). See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
.. versionadded:: 3.14
``<file>`` or ``<code>`` may use "generator expressions" with the syntax
``$<...>`` (in the case of ``<file>``, this refers to their use in the file
name, not the file's contents). See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
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
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
used to specify an export to the android ndk build system. This mode
accepts the same options as the normal export mode. The Android
NDK supports the use of prebuilt libraries, both static and shared. This
allows cmake to build the libraries of a project and make them available
to an ndk build system complete with transitive dependencies, include flags
and defines required to use the libraries.
.. versionadded:: 3.7
In addition to cmake language files, the ``EXPORT_ANDROID_MK`` mode maybe
used to specify an export to the android ndk build system. This mode
accepts the same options as the normal export mode. The Android
NDK supports the use of prebuilt libraries, both static and shared. This
allows cmake to build the libraries of a project and make them available
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
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
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.
By default the directories specified are appended onto the current list of
directories. This default behavior can be changed by setting
: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
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. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
Arguments to ``link_directories`` may use "generator expressions" with
the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
.. versionadded:: 3.13
By default the directories specified are appended onto the current list of
directories. This default behavior can be changed by setting
: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::

View File

@@ -88,6 +88,8 @@ Returns the list of elements specified by indices from the list.
list(JOIN <list> <glue> <output variable>)
.. versionadded:: 3.12
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
from :command:`string` command.
@@ -98,6 +100,8 @@ from :command:`string` command.
list(SUBLIST <list> <begin> <length> <output variable>)
.. versionadded:: 3.12
Returns a sublist of the given list.
If ``<length>`` is 0, an empty list will be returned.
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>)
.. versionadded:: 3.6
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.
@@ -152,6 +158,8 @@ Inserts elements to the list to the specified location.
list(POP_BACK <list> [<out-var>...])
.. versionadded:: 3.15
If no variable name is given, removes exactly one element. Otherwise,
assign the last element's value to the given variable and removes it,
up to the last variable name given.
@@ -162,6 +170,8 @@ up to the last variable name given.
list(POP_FRONT <list> [<out-var>...])
.. versionadded:: 3.15
If no variable name is given, removes exactly one element. Otherwise,
assign the first element's value to the given variable and removes it,
up to the last variable name given.
@@ -172,6 +182,8 @@ up to the last variable name given.
list(PREPEND <list> [<element> ...])
.. versionadded:: 3.15
Insert elements to the 0th position in the list.
.. _REMOVE_ITEM:
@@ -206,6 +218,8 @@ but if duplicates are encountered, only the first instance is preserved.
list(TRANSFORM <list> <ACTION> [<SELECTOR>]
[OUTPUT_VARIABLE <output variable>])
.. versionadded:: 3.12
Transforms the list by applying an action to all or, by specifying a
``<SELECTOR>``, to the selected elements of the list, storing the result
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>])
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.
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
all-lowercase names.
The :command:`cmake_language(CALL ...)` command can also be used to
invoke the macro.
.. versionadded:: 3.18
The :command:`cmake_language(CALL ...)` command can also be used to
invoke the macro.
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,
it will not be changed.
.. note::
Policy :policy:`CMP0102` affects the behavior of the ``mark_as_advanced``
call. When set to ``NEW``, variables passed to this command which are not
already in the cache are ignored. See policy :policy:`CMP0102`.
.. versionchanged:: 3.17
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
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``,
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.
.. versionadded:: 3.13
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.
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
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
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
@@ -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
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.
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
by the content of the :variable:`CMAKE_MESSAGE_INDENT` variable (converted to
a single string by concatenating its list items). For ``STATUS`` to ``TRACE``
messages, this indenting content will be inserted after the hyphens.
.. versionadded:: 3.17
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 can also have each line preceded
with context of the form ``[some.context.example]``. The content between the
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.
.. versionadded:: 3.16
Messages of log levels ``NOTICE`` and below will have each line preceded
by the content of the :variable:`CMAKE_MESSAGE_INDENT` variable (converted to
a single string by concatenating its list items). For ``STATUS`` to ``TRACE``
messages, this indenting content will be inserted after the hyphens.
.. versionadded:: 3.17
Messages of log levels ``NOTICE`` and below can also have each line preceded
with context of the form ``[some.context.example]``. The content between the
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
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
^^^^^^^^^^^^^^^^
.. versionadded:: 3.17
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.
For example:

View File

@@ -55,10 +55,14 @@ The options are:
* :variable:`PROJECT_VERSION_TWEAK`,
:variable:`<PROJECT-NAME>_VERSION_TWEAK`.
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`.
.. versionadded:: 3.12
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>``
.. versionadded:: 3.9
Optional.
Sets the variables
@@ -71,7 +75,12 @@ The options are:
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`.
.. versionadded:: 3.12
Added ``<PROJECT-NAME>_DESCRIPTION`` variable.
``HOMEPAGE_URL <url-string>``
.. versionadded:: 3.12
Optional.
Sets the variables
@@ -93,6 +102,15 @@ The options are:
Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no 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
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
^^^^^^^^^^^^^^
.. versionadded:: 3.15
If the :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` or
:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE` variables are set,
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
:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`.
.. versionadded:: 3.17
Added ``CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE_BEFORE`` variable.
Usage
^^^^^

View File

@@ -32,10 +32,14 @@ be one of the following keywords:
MSDN article `Parsing C Command-Line Arguments`_ for details.
``NATIVE_COMMAND``
.. versionadded:: 3.9
Proceeds as in ``WINDOWS_COMMAND`` mode if the host system is Windows.
Otherwise proceeds as in ``UNIX_COMMAND`` mode.
``PROGRAM``
.. versionadded:: 3.19
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,
``<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``
Scope defaults to the current directory but other directories
(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.
See also the :command:`set_directory_properties` command.
.. versionadded:: 3.19
``<dir>`` may reference a binary directory.
``TARGET``
Scope may name zero or more existing targets.
See also the :command:`set_target_properties` command.
@@ -40,25 +41,31 @@ It must be one of the following:
``SOURCE``
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``).
Visibility can be set in other directory scopes using one or both of the
following sub-options:
``DIRECTORY <dirs>...``
The source file property will be set in each of the ``<dirs>``
directories' scopes. Each path may reference either a source directory,
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.
.. versionadded:: 3.18
Visibility can be set in other directory scopes using one or both of the
following sub-options:
``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).
``DIRECTORY <dirs>...``
The source file property will be set in each of the ``<dirs>``
directories' scopes. 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.
.. 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.
``INSTALL``
.. versionadded:: 3.1
Scope may name zero or more installed file paths.
These are made available to CPack to influence deployment.
@@ -98,3 +105,8 @@ directly set in the nominated scope, the command will behave as though
See the :manual:`cmake-properties(7)` manual for a list of properties
in each scope.
.. note::
The :prop_sf:`GENERATED` source file property may be globally visible.
See its documentation for details.

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
list.
By default, source file properties 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 options:
.. versionadded:: 3.18
By default, source file properties 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 options:
``DIRECTORY <dirs>...``
The source file properties will be set in each of the ``<dirs>``
@@ -35,3 +36,8 @@ See also the :command:`set_property(SOURCE)` command.
See :ref:`Source File Properties` for the list of properties known
to CMake.
.. note::
The :prop_sf:`GENERATED` source file property may be globally visible.
See its documentation for details.

View File

@@ -6,3 +6,7 @@ Set the given variable to the name of the computer.
.. code-block:: cmake
site_name(variable)
On UNIX-like platforms, if the variable ``HOSTNAME`` is set, its value
will be executed as a command expected to print out the host name,
much like the ``hostname`` command-line tool.

View File

@@ -14,12 +14,16 @@ This is intended to set up file tabs in Visual Studio.
The options are:
``TREE``
.. versionadded:: 3.8
CMake will automatically detect, from ``<src>`` files paths, source groups
it needs to create, to keep structure of source groups analogically to the
actual files and directories structure in the project. Paths of ``<src>``
files will be cut to be relative to ``<root>``.
``PREFIX``
.. versionadded:: 3.8
Source group and files located directly in ``<root>`` path, will be placed
in ``<prefix>`` source groups.
@@ -47,6 +51,9 @@ appropriately:
source_group(outer\\inner ...)
source_group(TREE <root> PREFIX sources\\inc ...)
.. versionadded:: 3.18
Allow using forward slashes (``/``) to specify subgroups.
For backwards compatibility, the short-hand signature
.. 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 ``|``
``()``
Saves a matched subexpression, which can be referenced
in the ``REGEX REPLACE`` operation. Additionally it is saved
by all regular expression-related commands, including
e.g. :command:`if(MATCHES)`, in the variables
:variable:`CMAKE_MATCH_<n>` for ``<n>`` 0..9.
in the ``REGEX REPLACE`` operation.
.. versionadded:: 3.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. ``|``
has lower precedence than concatenation. This means that the regular
@@ -205,6 +207,8 @@ Manipulation
string(APPEND <string_variable> [<input>...])
.. versionadded:: 3.4
Append all the ``<input>`` arguments to the string.
.. _PREPEND:
@@ -213,6 +217,8 @@ Append all the ``<input>`` arguments to the string.
string(PREPEND <string_variable> [<input>...])
.. versionadded:: 3.10
Prepend all the ``<input>`` arguments to the string.
.. _CONCAT:
@@ -230,6 +236,8 @@ the result in the named ``<output_variable>``.
string(JOIN <glue> <output_variable> [<input>...])
.. versionadded:: 3.12
Join all the ``<input>`` arguments together using the ``<glue>``
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
``<length>`` is ``-1`` the remainder of the string starting at ``<begin>``
will be returned. If ``<string>`` is shorter than ``<length>`` then the
end of the string is used instead.
will be returned.
.. versionchanged:: 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
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:
.. code-block:: cmake
@@ -296,6 +303,8 @@ leading and trailing spaces removed.
string(GENEX_STRIP <string> <output_variable>)
.. versionadded:: 3.1
Strip any :manual:`generator expressions <cmake-generator-expressions(7)>`
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>)
.. versionadded:: 3.15
Produce the output string as the input ``<string>`` repeated ``<count>`` times.
Comparison
@@ -323,6 +334,9 @@ Comparison
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`:
Hashing
@@ -358,6 +372,9 @@ The supported ``<HASH>`` algorithm names are:
``SHA3_512``
Keccak SHA-3.
.. versionadded:: 3.8
Added ``SHA3`` hash algorithms.
Generation
^^^^^^^^^^
@@ -375,6 +392,8 @@ Convert all numbers into corresponding ASCII characters.
string(HEX <string> <output_variable>)
.. versionadded:: 3.18
Convert each byte in the input ``<string>`` to its hexadecimal representation
and store the concatenated hex digits in the ``<output_variable>``. Letters in
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 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
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:%SZ for UTC.
.. note::
.. versionadded:: 3.8
If the ``SOURCE_DATE_EPOCH`` environment variable is set,
its value will be used instead of the current time.
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>
TYPE <MD5|SHA1> [UPPER])
.. versionadded:: 3.1
Create a universally unique identifier (aka GUID) as per RFC4122
based on the hash of the combined values of ``<namespace>``
(which itself has to be a valid UUID) and ``<name>``.
@@ -489,6 +521,8 @@ with the optional ``UPPER`` flag.
JSON
^^^^
.. versionadded:: 3.19
Functionality for querying a JSON string.
.. 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
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
: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
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"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
@@ -37,3 +39,12 @@ For example, the following are all equivalent:
target_compile_definitions(foo PUBLIC -DFOO) # -D removed
target_compile_definitions(foo PUBLIC "" FOO) # "" ignored
target_compile_definitions(foo PUBLIC -D FOO) # -D becomes "", then ignored
Definitions may optionally have values:
.. code-block:: cmake
target_compile_definitions(foo PUBLIC FOO=1)
Note that many compilers treat ``-DFOO`` as equivalent to ``-DFOO=1``, but
other tools may not recognize this in all circumstances (e.g. IntelliSense).

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>``.
``PUBLIC`` and ``INTERFACE`` items will populate the
: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.
.. 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
:command:`add_executable` or :command:`add_library` and must not be an
: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
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
: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
``<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"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(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>``.
``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
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.
Repeated calls for the same <target> append items in the order called. If
``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
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:
* **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
effect as passing the framework directory as an include directory.
On :ref:`Visual Studio Generators` for VS 2010 and above, library files
ending in ``.targets`` will be treated as MSBuild targets files and
imported into generated project files. This is not supported by other
generators.
.. versionadded:: 3.8
On :ref:`Visual Studio Generators` for VS 2010 and above, library files
ending in ``.targets`` will be treated as MSBuild targets files and
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 shell automatically.
@@ -89,6 +94,11 @@ Each ``<item>`` may be:
flags explicitly. The flags will then be placed at the toolchain-defined
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
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
^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.12
:ref:`Object Libraries` may be used as the ``<target>`` (first) argument
of ``target_link_libraries`` to specify dependencies of their sources
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
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
: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
``<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"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`

View File

@@ -12,27 +12,37 @@ Add sources to a target.
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
Specifies sources to use when building a target and/or its dependents.
Relative source file paths are interpreted as being relative to the current
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` and must not be an
The named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` or
:command:`add_custom_target` and must not be an
:ref:`ALIAS target <Alias Targets>`.
.. versionchanged:: 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
specify the scope of the items following them. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`SOURCES` property of
``<target>``, which are used when building the target itself.
``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``, which are used
when building dependents. (:ref:`IMPORTED targets <Imported Targets>`
only support ``INTERFACE`` items because they are not build targets.)
when building dependents.
The following arguments specify sources. Repeated calls for the same
``<target>`` append items in the order called.
``<target>`` append items in the order called. The targets created by
: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"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
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``,
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
``CMakeLists.txt`` file and all sources. The ``<bindir>`` and ``<srcdir>``
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
``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
: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
@@ -94,6 +102,8 @@ The options are:
given to the ``CMAKE_FLAGS`` option will be ignored.
``LINK_OPTIONS <options>...``
.. versionadded:: 3.14
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
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.
``<LANG>_STANDARD <std>``
.. versionadded:: 3.8
Specify the :prop_tgt:`C_STANDARD`, :prop_tgt:`CXX_STANDARD`,
:prop_tgt:`OBJC_STANDARD`, :prop_tgt:`OBJCXX_STANDARD`,
or :prop_tgt:`CUDA_STANDARD` target property of the generated project.
``<LANG>_STANDARD_REQUIRED <bool>``
.. versionadded:: 3.8
Specify the :prop_tgt:`C_STANDARD_REQUIRED`,
:prop_tgt:`CXX_STANDARD_REQUIRED`, :prop_tgt:`OBJC_STANDARD_REQUIRED`,
:prop_tgt:`OBJCXX_STANDARD_REQUIRED`,or :prop_tgt:`CUDA_STANDARD_REQUIRED`
target property of the generated project.
``<LANG>_EXTENSIONS <bool>``
.. versionadded:: 3.8
Specify the :prop_tgt:`C_EXTENSIONS`, :prop_tgt:`CXX_EXTENSIONS`,
:prop_tgt:`OBJC_EXTENSIONS`, :prop_tgt:`OBJCXX_EXTENSIONS`,
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
^^^^^^^^^^^^^^^^^^^^^^^
If set, the following variables are passed in to the generated
try_compile CMakeLists.txt to initialize compile target properties with
default values:
.. versionadded:: 3.4
If set, the following variables are passed in to the generated
try_compile CMakeLists.txt to initialize compile target properties with
default values:
* :variable:`CMAKE_CUDA_RUNTIME_LIBRARY`
* :variable:`CMAKE_ENABLE_EXPORTS`
* :variable:`CMAKE_LINK_SEARCH_START_STATIC`
* :variable:`CMAKE_LINK_SEARCH_END_STATIC`
* :variable:`CMAKE_MSVC_RUNTIME_LIBRARY`
* :variable:`CMAKE_POSITION_INDEPENDENT_CODE`
* :variable:`CMAKE_CUDA_RUNTIME_LIBRARY`
* :variable:`CMAKE_ENABLE_EXPORTS`
* :variable:`CMAKE_LINK_SEARCH_START_STATIC`
* :variable:`CMAKE_LINK_SEARCH_END_STATIC`
* :variable:`CMAKE_MSVC_RUNTIME_LIBRARY`
* :variable:`CMAKE_POSITION_INDEPENDENT_CODE`
If :policy:`CMP0056` is set to ``NEW``, then
:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well.
If :policy:`CMP0056` is set to ``NEW``, then
:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well.
If :policy:`CMP0083` is set to ``NEW``, then in order to obtain correct
behavior at link time, the ``check_pie_supported()`` command from the
:module:`CheckPIESupported` module must be called before using the
:command:`try_compile` command.
.. versionchanged:: 3.14
If :policy:`CMP0083` is set to ``NEW``, then in order to obtain correct
behavior at link time, the ``check_pie_supported()`` command from the
:module:`CheckPIESupported` module must be called before using the
:command:`try_compile` command.
The current settings of :policy:`CMP0065` and :policy:`CMP0083` are propagated
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
a build configuration.
Set the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to specify
the type of target used for the source file signature.
.. versionadded:: 3.6
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
variables that must be propagated into the test project. This variable is
meant for use only in toolchain files and is only honored by the
``try_compile()`` command for the source files form, not when given a whole
project.
.. versionadded:: 3.6
Set the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify
variables that must be propagated into the test project. This variable is
meant for use only in toolchain files and is only honored by the
``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``,
``<LANG>_STANDARD_REQUIRED``, or ``<LANG>_EXTENSIONS`` options are used,
then the language standard variables are honored:
.. versionchanged:: 3.8
If :policy:`CMP0067` is set to ``NEW``, or any of the ``<LANG>_STANDARD``,
``<LANG>_STANDARD_REQUIRED``, or ``<LANG>_EXTENSIONS`` options are used,
then the language standard variables are honored:
* :variable:`CMAKE_C_STANDARD`
* :variable:`CMAKE_C_STANDARD_REQUIRED`
* :variable:`CMAKE_C_EXTENSIONS`
* :variable:`CMAKE_CXX_STANDARD`
* :variable:`CMAKE_CXX_STANDARD_REQUIRED`
* :variable:`CMAKE_CXX_EXTENSIONS`
* :variable:`CMAKE_OBJC_STANDARD`
* :variable:`CMAKE_OBJC_STANDARD_REQUIRED`
* :variable:`CMAKE_OBJC_EXTENSIONS`
* :variable:`CMAKE_OBJCXX_STANDARD`
* :variable:`CMAKE_OBJCXX_STANDARD_REQUIRED`
* :variable:`CMAKE_OBJCXX_EXTENSIONS`
* :variable:`CMAKE_CUDA_STANDARD`
* :variable:`CMAKE_CUDA_STANDARD_REQUIRED`
* :variable:`CMAKE_CUDA_EXTENSIONS`
* :variable:`CMAKE_C_STANDARD`
* :variable:`CMAKE_C_STANDARD_REQUIRED`
* :variable:`CMAKE_C_EXTENSIONS`
* :variable:`CMAKE_CXX_STANDARD`
* :variable:`CMAKE_CXX_STANDARD_REQUIRED`
* :variable:`CMAKE_CXX_EXTENSIONS`
* :variable:`CMAKE_OBJC_STANDARD`
* :variable:`CMAKE_OBJC_STANDARD_REQUIRED`
* :variable:`CMAKE_OBJC_EXTENSIONS`
* :variable:`CMAKE_OBJCXX_STANDARD`
* :variable:`CMAKE_OBJCXX_STANDARD_REQUIRED`
* :variable:`CMAKE_OBJCXX_EXTENSIONS`
* :variable:`CMAKE_CUDA_STANDARD`
* :variable:`CMAKE_CUDA_STANDARD_REQUIRED`
* :variable:`CMAKE_CUDA_EXTENSIONS`
Their values are used to set the corresponding target properties in
the generated project (unless overridden by an explicit option).
Their values are used to set the corresponding target properties in
the generated project (unless overridden by an explicit option).
For the :generator:`Green Hills MULTI` generator the GHS toolset and target
system customization cache variables are also propagated into the test project.
.. versionchanged:: 3.14
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
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:
``CMAKE_FLAGS <flags>...``
@@ -46,6 +51,8 @@ The options are:
Report the compile step build output in a given variable.
``LINK_LIBRARIES <libs>...``
.. versionadded:: 3.2
Specify libraries to be linked in the generated project.
The list of libraries may refer to system libraries and to
: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.
``LINK_OPTIONS <options>...``
.. versionadded:: 3.14
Specify link step options to pass to :command:`target_link_options` in the
generated project.
@@ -74,6 +83,10 @@ a build configuration.
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
usually cannot be run on the build host. The ``try_run`` command checks
the :variable:`CMAKE_CROSSCOMPILING` variable to detect whether CMake is in

View File

@@ -12,6 +12,12 @@ any of the following formats:
- TZST (.tar.zst)
- ZIP (.zip)
.. versionadded:: 3.1
``7Z`` and ``TXZ`` formats support.
.. versionadded:: 3.16
``TZST`` format support.
When this generator is called from ``CPackSourceConfig.cmake`` (or through
the ``package_source`` target), then the generated archive will contain all
files in the project directory, except those specified in
@@ -46,6 +52,9 @@ Variables specific to CPack Archive generator
The default is ``<CPACK_PACKAGE_FILE_NAME>[-<component>]``, with spaces
replaced by '-'.
.. versionadded:: 3.9
Per-component ``CPACK_ARCHIVE_<component>_FILE_NAME`` variables.
.. variable:: CPACK_ARCHIVE_COMPONENT_INSTALL
Enable component packaging. If enabled (ON), then the archive generator
@@ -63,6 +72,8 @@ CPack generators which are essentially archives at their core. These include:
.. variable:: CPACK_ARCHIVE_THREADS
.. versionadded:: 3.18
The number of threads to use when performing the compression. If set to
``0``, the number of available cores on the machine will be used instead.
The default is ``1`` which limits compression to a single thread. Note that

View File

@@ -36,6 +36,8 @@ Bundle-specific parameters (``CPACK_BUNDLE_xxx``).
.. variable:: CPACK_BUNDLE_APPLE_CERT_APP
.. versionadded:: 3.2
The name of your Apple supplied code signing certificate for the application.
The name usually takes the form ``Developer ID Application: [Name]`` or
``3rd Party Mac Developer Application: [Name]``. If this variable is not set
@@ -43,23 +45,31 @@ Bundle-specific parameters (``CPACK_BUNDLE_xxx``).
.. variable:: CPACK_BUNDLE_APPLE_ENTITLEMENTS
.. versionadded:: 3.2
The name of the Property List (``.plist``) file that contains your Apple
entitlements for sandboxing your application. This file is required
for submission to the macOS App Store.
.. variable:: CPACK_BUNDLE_APPLE_CODESIGN_FILES
.. versionadded:: 3.2
A list of additional files that you wish to be signed. You do not need to
list the main application folder, or the main executable. You should
list any frameworks and plugins that are included in your app bundle.
.. variable:: CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER
.. versionadded:: 3.3
Additional parameter that will passed to ``codesign``.
Default value: ``--deep -f``
.. variable:: CPACK_COMMAND_CODESIGN
.. versionadded:: 3.2
Path to the ``codesign(1)`` command used to sign applications with an
Apple cert. This variable can be used to override the automatically
detected command (or specify its location if the auto-detection fails

View File

@@ -6,7 +6,9 @@ Cygwin CPack generator (Cygwin).
Variables affecting the CPack Cygwin generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- :variable:`CPACK_ARCHIVE_THREADS`
- .. versionadded:: 3.18
:variable:`CPACK_ARCHIVE_THREADS`
Variables specific to CPack Cygwin generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -54,11 +54,16 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_NAME` suffixed with -<COMPONENT>
for component-based installations.
.. versionadded:: 3.5
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME`` variables.
See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
.. variable:: CPACK_DEBIAN_FILE_NAME
CPACK_DEBIAN_<COMPONENT>_FILE_NAME
.. versionadded:: 3.6
Package file name.
* Mandatory : YES
@@ -72,6 +77,9 @@ List of CPack DEB generator specific variables:
Alternatively provided package file name must end
with either ``.deb`` or ``.ipk`` suffix.
.. versionadded:: 3.10
``.ipk`` suffix used by OPKG packaging system.
.. note::
Preferred setting of this variable is ``DEB-DEFAULT`` but for backward
@@ -86,6 +94,8 @@ List of CPack DEB generator specific variables:
.. variable:: CPACK_DEBIAN_PACKAGE_EPOCH
.. versionadded:: 3.10
The Debian package epoch
* Mandatory : No
@@ -116,6 +126,8 @@ List of CPack DEB generator specific variables:
.. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
.. versionadded:: 3.6
The Debian package release - Debian revision number.
* Mandatory : No
@@ -136,6 +148,9 @@ List of CPack DEB generator specific variables:
* Default : Output of ``dpkg --print-architecture`` (or ``i386``
if ``dpkg`` is not found)
.. versionadded:: 3.6
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE`` variables.
.. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS
CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
@@ -148,6 +163,10 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS` for component-based
installations.
.. versionadded:: 3.3
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS`` variables.
.. note::
If :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` or
@@ -165,7 +184,9 @@ List of CPack DEB generator specific variables:
.. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS
Sets inter component dependencies if listed with
.. versionadded:: 3.6
Sets inter-component dependencies if listed with
:variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables.
* Mandatory : NO
@@ -196,6 +217,15 @@ List of CPack DEB generator specific variables:
used if set. Otherwise, :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` will be added as the first
line of description as defined in `Debian Policy Manual`_.
.. versionadded:: 3.3
Per-component ``CPACK_COMPONENT_<compName>_DESCRIPTION`` variables.
.. versionadded:: 3.16
Per-component ``CPACK_DEBIAN_<COMPONENT>_DESCRIPTION`` variables.
.. versionadded:: 3.16
``CPACK_PACKAGE_DESCRIPTION_FILE`` variable.
.. _Debian Policy Manual: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
.. variable:: CPACK_DEBIAN_PACKAGE_SECTION
@@ -206,10 +236,17 @@ List of CPack DEB generator specific variables:
* Mandatory : YES
* Default : "devel"
.. versionadded:: 3.5
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION`` variables.
See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
.. variable:: CPACK_DEBIAN_ARCHIVE_TYPE
.. versionadded:: 3.7
.. deprecated:: 3.14
The archive format used for creating the Debian package.
* Mandatory : YES
@@ -228,6 +265,8 @@ List of CPack DEB generator specific variables:
.. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
.. versionadded:: 3.1
The compression used for creating the Debian package.
* Mandatory : YES
@@ -249,6 +288,9 @@ List of CPack DEB generator specific variables:
* Mandatory : YES
* Default : "optional"
.. versionadded:: 3.5
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY`` varables.
See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
.. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
@@ -260,6 +302,9 @@ List of CPack DEB generator specific variables:
* Mandatory : NO
* Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
.. versionadded:: 3.12
``CMAKE_PROJECT_HOMEPAGE_URL`` variable.
.. note::
The content of this field is a simple URL without any surrounding
@@ -284,6 +329,12 @@ List of CPack DEB generator specific variables:
may fail to find your own shared libs.
See https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
.. versionadded:: 3.3
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS`` variables.
.. versionadded:: 3.6
Correct handling of ``$ORIGIN`` in :variable:`CMAKE_INSTALL_RPATH`.
.. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
May be set when invoking cpack in order to trace debug information
@@ -308,6 +359,9 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS`` variables.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
.. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES
@@ -325,6 +379,9 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES`` variables.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
.. variable:: CPACK_DEBIAN_PACKAGE_BREAKS
@@ -345,6 +402,9 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS`` variables.
See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
.. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
@@ -362,6 +422,9 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS`` variables.
See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
.. note::
@@ -386,6 +449,9 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES`` variables.
See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
.. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
@@ -402,6 +468,9 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES`` variables.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
.. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
@@ -418,6 +487,9 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS`` variables.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
.. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
@@ -433,10 +505,15 @@ List of CPack DEB generator specific variables:
- :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based
installations.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS`` variables.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
.. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
.. versionadded:: 3.6
* Mandatory : NO
* Default : OFF
@@ -451,6 +528,8 @@ List of CPack DEB generator specific variables:
.. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
.. versionadded:: 3.6
Compatibility policy for auto-generated shlibs control file.
* Mandatory : NO
@@ -476,17 +555,14 @@ List of CPack DEB generator specific variables:
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
.. note::
The original permissions of the files will be used in the final
package unless the variable
:variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set.
In particular, the scripts should have the proper executable
flag prior to the generation of the package.
.. versionadded:: 3.4
Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA`` variables.
.. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION
.. versionadded:: 3.4
This variable indicates if the Debian policy on control files should be
strictly followed.
@@ -497,15 +573,22 @@ List of CPack DEB generator specific variables:
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
This overrides the permissions on the original files, following the rules
set by Debian policy
https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
.. note::
This overrides the permissions on the original files, following the rules
set by Debian policy
https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
The original permissions of the files will be used in the final
package unless this variable is set to ``TRUE``.
In particular, the scripts should have the proper executable
flag prior to the generation of the package.
.. variable:: CPACK_DEBIAN_PACKAGE_SOURCE
CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE
.. versionadded:: 3.5
Sets the ``Source`` field of the binary Debian package.
When the binary package name is not the same as the source package name
(in particular when several components/binaries are generated from one
@@ -529,6 +612,8 @@ List of CPack DEB generator specific variables:
Packaging of debug information
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.13
Dbgsym packages contain debug symbols for debugging packaged binaries.
Dbgsym packaging has its own set of variables:
@@ -549,6 +634,8 @@ Dbgsym packaging has its own set of variables:
Building Debian packages on Windows
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.10
To communicate UNIX file permissions from the install stage
to the CPack DEB generator the "cmake_mode_t" NTFS
alternate data stream (ADT) is used.
@@ -559,6 +646,8 @@ permissions can be preserved.
Reproducible packages
^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.13
The environment variable ``SOURCE_DATE_EPOCH`` may be set to a UNIX
timestamp, defined as the number of seconds, excluding leap seconds,
since 01 Jan 1970 00:00:00 UTC. If set, the CPack DEB generator will

View File

@@ -30,6 +30,8 @@ on macOS:
.. variable:: CPACK_DMG_DS_STORE_SETUP_SCRIPT
.. versionadded:: 3.5
Path to a custom AppleScript file. This AppleScript is used to generate
a ``.DS_Store`` file which specifies the Finder window position/geometry and
layout (such as hidden toolbars, placement of the icons etc.).
@@ -47,11 +49,15 @@ on macOS:
.. variable:: CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK
.. versionadded:: 3.6
Default behaviour is to include a symlink to ``/Applications`` in the DMG.
Set this option to ``ON`` to avoid adding the symlink.
.. variable:: CPACK_DMG_SLA_DIR
.. versionadded:: 3.5
Directory where license and menu files for different languages are stored.
Setting this causes CPack to look for a ``<language>.menu.txt`` and
``<language>.license.txt`` or ``<language>.license.rtf`` file for every
@@ -61,8 +67,13 @@ on macOS:
``<language>.license.txt`` and ``<language>.license.rtf`` exist, the ``.txt``
file will be used.
.. versionadded:: 3.17
RTF support.
.. variable:: CPACK_DMG_SLA_LANGUAGES
.. versionadded:: 3.5
Languages for which a license agreement is provided when mounting the
generated DMG. A menu file consists of 9 lines of text. The first line is
is the name of the language itself, uppercase, in English (e.g. German).
@@ -85,6 +96,8 @@ on macOS:
.. variable:: CPACK_DMG_<component>_FILE_NAME
.. versionadded:: 3.17
File name when packaging ``<component>`` as its own DMG
(``CPACK_COMPONENTS_GROUPING`` set to IGNORE).

View File

@@ -1,6 +1,8 @@
CPack External Generator
------------------------
.. versionadded:: 3.13
CPack provides many generators to create packages for a variety of platforms
and packaging systems. The intention is for CMake/CPack to be a complete
end-to-end solution for building and packaging a software project. However, it
@@ -284,6 +286,8 @@ Variables specific to CPack External generator
.. variable:: CPACK_EXTERNAL_BUILT_PACKAGES
.. versionadded:: 3.19
The ``CPACK_EXTERNAL_PACKAGE_SCRIPT`` script may set this list variable to the
full paths of generated package files. CPack will copy these files from the
staging directory back to the top build directory and possibly produce

View File

@@ -1,12 +1,15 @@
CPack FreeBSD Generator
-----------------------
.. versionadded:: 3.10
The built in (binary) CPack FreeBSD (pkg) generator (Unix only)
Variables affecting the CPack FreeBSD (pkg) generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- :variable:`CPACK_ARCHIVE_THREADS`
- .. versionadded:: 3.18
:variable:`CPACK_ARCHIVE_THREADS`
Variables specific to CPack FreeBSD (pkg) generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -86,6 +89,9 @@ the RPM information (e.g. package license).
:variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already
for Debian packaging, so we may as well re-use it).
.. versionadded:: 3.12
``CMAKE_PROJECT_HOMEPAGE_URL`` variable.
.. variable:: CPACK_FREEBSD_PACKAGE_LICENSE
The license, or licenses, which apply to this software package. This must

View File

@@ -1,6 +1,8 @@
CPack IFW Generator
-------------------
.. versionadded:: 3.1
Configure and run the Qt Installer Framework to generate a Qt installer.
.. only:: html
@@ -35,6 +37,8 @@ Debug
.. variable:: CPACK_IFW_VERBOSE
.. versionadded:: 3.3
Set to ``ON`` to enable addition debug output.
By default is ``OFF``.
@@ -71,41 +75,51 @@ Package
.. variable:: CPACK_IFW_PACKAGE_WATERMARK
.. versionadded:: 3.8
Filename for a watermark is used as QWizard::WatermarkPixmap.
.. variable:: CPACK_IFW_PACKAGE_BANNER
.. versionadded:: 3.8
Filename for a banner is used as QWizard::BannerPixmap.
.. variable:: CPACK_IFW_PACKAGE_BACKGROUND
.. versionadded:: 3.8
Filename for an image used as QWizard::BackgroundPixmap (only used by MacStyle).
.. variable:: CPACK_IFW_PACKAGE_WIZARD_STYLE
.. versionadded:: 3.8
Wizard style to be used ("Modern", "Mac", "Aero" or "Classic").
.. variable:: CPACK_IFW_PACKAGE_STYLE_SHEET
Filename for a stylesheet.
.. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH
.. versionadded:: 3.8
Default width of the wizard in pixels. Setting a banner image will override this.
.. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT
.. versionadded:: 3.8
Default height of the wizard in pixels. Setting a watermark image will override this.
.. variable:: CPACK_IFW_PACKAGE_TITLE_COLOR
.. versionadded:: 3.8
Color of the titles and subtitles (takes an HTML color code, such as "#88FF33").
.. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY
.. variable:: CPACK_IFW_PACKAGE_STYLE_SHEET
Name of the default program group for the product in the Windows Start menu.
.. versionadded:: 3.15
By default used :variable:`CPACK_IFW_PACKAGE_NAME`.
Filename for a stylesheet.
.. variable:: CPACK_IFW_TARGET_DIRECTORY
@@ -123,6 +137,14 @@ Package
You can use predefined variables.
.. variable:: CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR
.. versionadded:: 3.11
Set to ``OFF`` if the target directory should not be deleted when uninstalling.
Is ``ON`` by default
.. variable:: CPACK_IFW_PACKAGE_GROUP
The group, which will be used to configure the root package
@@ -132,39 +154,51 @@ Package
The root package name, which will be used if configuration group is not
specified
.. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY
.. versionadded:: 3.3
Name of the default program group for the product in the Windows Start menu.
By default used :variable:`CPACK_IFW_PACKAGE_NAME`.
.. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME
.. versionadded:: 3.3
Filename of the generated maintenance tool.
The platform-specific executable file extension is appended.
By default used QtIFW defaults (``maintenancetool``).
.. variable:: CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR
Set to ``OFF`` if the target directory should not be deleted when uninstalling.
Is ``ON`` by default
.. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE
.. versionadded:: 3.3
Filename for the configuration of the generated maintenance tool.
By default used QtIFW defaults (``maintenancetool.ini``).
.. variable:: CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS
.. versionadded:: 3.3
Set to ``ON`` if the installation path can contain non-ASCII characters.
Is ``ON`` for QtIFW less 2.0 tools.
.. variable:: CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH
.. versionadded:: 3.3
Set to ``OFF`` if the installation path cannot contain space characters.
Is ``ON`` for QtIFW less 2.0 tools.
.. variable:: CPACK_IFW_PACKAGE_CONTROL_SCRIPT
.. versionadded:: 3.3
Filename for a custom installer control script.
.. variable:: CPACK_IFW_PACKAGE_RESOURCES
@@ -177,6 +211,8 @@ Package
.. variable:: CPACK_IFW_PACKAGE_FILE_EXTENSION
.. versionadded:: 3.10
The target binary extension.
On Linux, the name of the target binary is automatically extended with
@@ -216,6 +252,8 @@ Components
.. variable:: CPACK_IFW_REPOSITORIES_DIRECTORIES
.. versionadded:: 3.10
Additional prepared repository dirs that will be used to resolve and
repack dependent components. This feature available only
since QtIFW 3.1.
@@ -225,6 +263,8 @@ QtIFW Tools
.. variable:: CPACK_IFW_FRAMEWORK_VERSION
.. versionadded:: 3.3
The version of used QtIFW tools.
The following variables provide the locations of the QtIFW
@@ -260,6 +300,8 @@ the path may be specified in either a CMake or an environment variable:
.. variable:: CPACK_IFW_ROOT
.. versionadded:: 3.9
An CMake variable which specifies the location of the QtIFW tool suite.
The variable will be cached in the ``CPackConfig.cmake`` file and used at
@@ -306,6 +348,8 @@ these files accessible from a download URL.
Internationalization
""""""""""""""""""""
.. versionadded:: 3.9
Some variables and command arguments support internationalization via
CMake script. This is an optional feature.

View File

@@ -3,7 +3,8 @@ CPack NSIS Generator
CPack Nullsoft Scriptable Install System (NSIS) generator specific options.
The NSIS generator requires NSIS 3.0 or newer.
.. versionchanged:: 3.17
The NSIS generator requires NSIS 3.0 or newer.
Variables specific to CPack NSIS generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -33,10 +34,14 @@ on Windows Nullsoft Scriptable Install System.
.. variable:: CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP
.. versionadded:: 3.5
The filename of a bitmap to use as the NSIS ``MUI_WELCOMEFINISHPAGE_BITMAP``.
.. variable:: CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP
.. versionadded:: 3.5
The filename of a bitmap to use as the NSIS ``MUI_UNWELCOMEFINISHPAGE_BITMAP``.
.. variable:: CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS
@@ -99,6 +104,8 @@ on Windows Nullsoft Scriptable Install System.
.. variable:: CPACK_NSIS_<compName>_INSTALL_DIRECTORY
.. versionadded:: 3.7
Custom install directory for the specified component ``<compName>`` instead
of ``$INSTDIR``.
@@ -133,29 +140,43 @@ on Windows Nullsoft Scriptable Install System.
.. variable:: CPACK_NSIS_UNINSTALL_NAME
.. versionadded:: 3.17
Specify the name of the program to uninstall the version.
Default is ``Uninstall``.
.. variable:: CPACK_NSIS_WELCOME_TITLE
.. versionadded:: 3.17
The title to display on the top of the page for the welcome page.
.. variable:: CPACK_NSIS_WELCOME_TITLE_3LINES
.. versionadded:: 3.17
Display the title in the welcome page on 3 lines instead of 2.
.. variable:: CPACK_NSIS_FINISH_TITLE
.. versionadded:: 3.17
The title to display on the top of the page for the finish page.
.. variable:: CPACK_NSIS_FINISH_TITLE_3LINES
.. versionadded:: 3.17
Display the title in the finish page on 3 lines instead of 2.
.. variable:: CPACK_NSIS_MUI_HEADERIMAGE
.. versionadded:: 3.17
The image to display on the header of installers pages.
.. variable:: CPACK_NSIS_MANIFEST_DPI_AWARE
.. versionadded:: 3.18
If set, declares that the installer is DPI-aware.

View File

@@ -1,9 +1,11 @@
CPack NuGet Generator
---------------------
.. versionadded:: 3.12
When build a NuGet package there is no direct way to control an output
filename due a lack of the corresponding CLI option of NuGet, so there
is no ``CPACK_NUGET_PACKAGE_FILENAME`` variable. To form the output filename
is no ``CPACK_NUGET_PACKAGE_FILE_NAME`` variable. To form the output filename
NuGet uses the package name and the version according to its built-in rules.
Also, be aware that including a top level directory
@@ -35,7 +37,8 @@ List of CPack NuGet generator specific variables:
.. variable:: CPACK_NUGET_PACKAGE_NAME
CPACK_NUGET_<compName>_PACKAGE_NAME
The NUGET package name.
The NUGET package name. ``CPACK_NUGET_PACKAGE_NAME`` is used as the
package ``id`` on nuget.org_
* Mandatory : YES
* Default : :variable:`CPACK_PACKAGE_NAME`
@@ -95,7 +98,7 @@ List of CPack NuGet generator specific variables:
.. variable:: CPACK_NUGET_PACKAGE_HOMEPAGE_URL
CPACK_NUGET_<compName>_PACKAGE_HOMEPAGE_URL
A URL for the package's home page, often shown in UI displays as well
An URL for the package's home page, often shown in UI displays as well
as nuget.org_.
* Mandatory : NO
@@ -104,8 +107,45 @@ List of CPack NuGet generator specific variables:
.. variable:: CPACK_NUGET_PACKAGE_LICENSEURL
CPACK_NUGET_<compName>_PACKAGE_LICENSEURL
A URL for the package's license, often shown in UI displays as well
as nuget.org_.
.. deprecated:: 3.20
Use a local license file
(:variable:`CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME`)
or a `(SPDX) license identifier`_
(:variable:`CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION`) instead.
An URL for the package's license, often shown in UI displays as well
as on nuget.org_.
* Mandatory : NO
* Default : -
.. variable:: CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION
CPACK_NUGET_<compName>_PACKAGE_LICENSE_EXPRESSION
.. versionadded:: 3.20
A Software Package Data Exchange `(SPDX) license identifier`_ such as
``MIT``, ``BSD-3-Clause``, or ``LGPL-3.0-or-later``. In the case of a
choice of licenses or more complex restrictions, compound license
expressions may be formed using boolean operators, for example
``MIT OR BSD-3-Clause``. See the `SPDX specification`_ for guidance
on forming complex license expressions.
If ``CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME`` is specified,
``CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION`` is ignored.
* Mandatory : NO
* Default : -
.. variable:: CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME
CPACK_NUGET_<compName>_PACKAGE_LICENSE_FILE_NAME
The package's license file in :file:`.txt` or :file:`.md` format.
If ``CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME`` is specified,
``CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION`` is ignored.
.. versionadded:: 3.20
* Mandatory : NO
* Default : -
@@ -113,7 +153,21 @@ List of CPack NuGet generator specific variables:
.. variable:: CPACK_NUGET_PACKAGE_ICONURL
CPACK_NUGET_<compName>_PACKAGE_ICONURL
A URL for a 64x64 image with transparency background to use as the
.. deprecated:: 3.20
Use a local icon file (:variable:`CPACK_NUGET_PACKAGE_ICON`) instead.
An URL for a 64x64 image with transparency background to use as the
icon for the package in UI display.
* Mandatory : NO
* Default : -
.. variable:: CPACK_NUGET_PACKAGE_ICON
CPACK_NUGET_<compName>_PACKAGE_ICON
.. versionadded:: 3.20
The filename of a 64x64 image with transparency background to use as the
icon for the package in UI display.
* Mandatory : NO
@@ -146,6 +200,16 @@ List of CPack NuGet generator specific variables:
* Mandatory : NO
* Default : -
.. variable:: CPACK_NUGET_PACKAGE_LANGUAGE
CPACK_NUGET_<compName>_PACKAGE_LANGUAGE
.. versionadded:: 3.20
Locale specifier for the package, for example ``en_CA``.
* Mandatory : NO
* Default : -
.. variable:: CPACK_NUGET_PACKAGE_TAGS
CPACK_NUGET_<compName>_PACKAGE_TAGS
@@ -185,5 +249,7 @@ List of CPack NuGet generator specific variables:
.. _nuget.org: http://nuget.org
.. _version specification: https://docs.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards
.. _(SPDX) license identifier: https://spdx.org/licenses/
.. _SPDX specification: https://spdx.github.io/spdx-spec/appendix-IV-SPDX-license-expressions/
.. NuGet spec docs https://docs.microsoft.com/en-us/nuget/reference/nuspec

View File

@@ -27,6 +27,14 @@ macOS using PackageMaker:
don't mind missing extra features available in the installer shipping with
later versions of macOS.
Background Image
""""""""""""""""
.. versionadded:: 3.17
This group of variables controls the background image of the generated
installer.
.. variable:: CPACK_PACKAGEMAKER_BACKGROUND
Adds a background to Distribution XML if specified. The value contains the

View File

@@ -1,6 +1,8 @@
CPack productbuild Generator
----------------------------
.. versionadded:: 3.7
productbuild CPack generator (macOS).
Variables specific to CPack productbuild generator
@@ -18,11 +20,15 @@ macOS using ProductBuild:
.. variable:: CPACK_PRODUCTBUILD_IDENTITY_NAME
.. versionadded:: 3.8
Adds a digital signature to the resulting package.
.. variable:: CPACK_PRODUCTBUILD_KEYCHAIN_PATH
.. versionadded:: 3.8
Specify a specific keychain to search for the signing identity.
@@ -35,11 +41,15 @@ macOS using ProductBuild:
.. variable:: CPACK_PKGBUILD_IDENTITY_NAME
.. versionadded:: 3.8
Adds a digital signature to the resulting package.
.. variable:: CPACK_PKGBUILD_KEYCHAIN_PATH
.. versionadded:: 3.8
Specify a specific keychain to search for the signing identity.
@@ -60,12 +70,22 @@ macOS using ProductBuild:
.. variable:: CPACK_PRODUCTBUILD_RESOURCES_DIR
.. versionadded:: 3.9
If specified the productbuild generator copies files from this directory
(including subdirectories) to the ``Resources`` directory. This is done
before the :variable:`CPACK_RESOURCE_FILE_WELCOME`,
:variable:`CPACK_RESOURCE_FILE_README`, and
:variable:`CPACK_RESOURCE_FILE_LICENSE` files are copied.
Background Image
""""""""""""""""
.. versionadded:: 3.17
This group of variables controls the background image of the generated
installer.
.. variable:: CPACK_PRODUCTBUILD_BACKGROUND
Adds a background to Distribution XML if specified. The value contains the

View File

@@ -20,7 +20,7 @@ a component GROUP name. Usually those variables correspond to RPM spec file
entities. One may find information about spec files here
http://www.rpm.org/wiki/Docs
.. note::
.. versionchanged:: 3.6
`<COMPONENT>` part of variables is preferred to be in upper case (e.g. if
component is named ``foo`` then use ``CPACK_RPM_FOO_XXXX`` variable name format)
@@ -59,6 +59,9 @@ List of CPack RPM generator specific variables:
* Mandatory : YES
* Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
.. versionadded:: 3.2
Per-component ``CPACK_RPM_<component>_PACKAGE_SUMMARY`` variables.
.. variable:: CPACK_RPM_PACKAGE_NAME
CPACK_RPM_<component>_PACKAGE_NAME
@@ -67,9 +70,14 @@ List of CPack RPM generator specific variables:
* Mandatory : YES
* Default : :variable:`CPACK_PACKAGE_NAME`
.. versionadded:: 3.5
Per-component ``CPACK_RPM_<component>_PACKAGE_NAME`` variables.
.. variable:: CPACK_RPM_FILE_NAME
CPACK_RPM_<component>_FILE_NAME
.. versionadded:: 3.6
Package file name.
* Mandatory : YES
@@ -93,6 +101,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_MAIN_COMPONENT
.. versionadded:: 3.8
Main component that is packaged without component suffix.
* Mandatory : NO
@@ -104,6 +114,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_PACKAGE_EPOCH
.. versionadded:: 3.10
The RPM package epoch
* Mandatory : No
@@ -129,6 +141,9 @@ List of CPack RPM generator specific variables:
This may be set to ``noarch`` if you know you are building a ``noarch`` package.
.. versionadded:: 3.3
Per-component ``CPACK_RPM_<component>_PACKAGE_ARCHITECTURE`` variables.
.. variable:: CPACK_RPM_PACKAGE_RELEASE
The RPM package release.
@@ -150,6 +165,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
.. versionadded:: 3.6
The dist tag that is added RPM ``Release:`` field.
* Mandatory : NO
@@ -174,6 +191,9 @@ List of CPack RPM generator specific variables:
* Mandatory : YES
* Default : "unknown"
.. versionadded:: 3.5
Per-component ``CPACK_RPM_<component>_PACKAGE_GROUP`` variables.
.. variable:: CPACK_RPM_PACKAGE_VENDOR
The RPM package vendor.
@@ -189,6 +209,9 @@ List of CPack RPM generator specific variables:
* Mandatory : NO
* Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
.. versionadded:: 3.12
``CMAKE_PROJECT_HOMEPAGE_URL`` variable.
.. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
CPACK_RPM_<component>_PACKAGE_DESCRIPTION
@@ -199,6 +222,9 @@ List of CPack RPM generator specific variables:
based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
if set or "no package description available"
.. versionadded:: 3.2
Per-component ``CPACK_RPM_<component>_PACKAGE_DESCRIPTION`` variables.
.. variable:: CPACK_RPM_COMPRESSION_TYPE
RPM compression type.
@@ -302,6 +328,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
.. versionadded:: 3.2
RPM spec requires(pre) field.
* Mandatory : NO
@@ -315,6 +343,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
.. versionadded:: 3.2
RPM spec requires(post) field.
* Mandatory : NO
@@ -328,6 +358,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
.. versionadded:: 3.2
RPM spec requires(postun) field.
* Mandatory : NO
@@ -342,6 +374,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
.. versionadded:: 3.2
RPM spec requires(preun) field.
* Mandatory : NO
@@ -492,6 +526,9 @@ List of CPack RPM generator specific variables:
rpm -qp --scripts package.rpm
.. versionadded:: 3.18
``CPACK_RPM_PRE_TRANS_SCRIPT_FILE`` variable.
.. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
CPACK_RPM_POST_TRANS_SCRIPT_FILE
@@ -513,6 +550,9 @@ List of CPack RPM generator specific variables:
rpm -qp --scripts package.rpm
.. versionadded:: 3.18
``CPACK_RPM_POST_TRANS_SCRIPT_FILE`` variable.
.. variable:: CPACK_RPM_USER_FILELIST
CPACK_RPM_<COMPONENT>_USER_FILELIST
@@ -521,13 +561,16 @@ List of CPack RPM generator specific variables:
May be used to explicitly specify ``%(<directive>)`` file line
in the spec file. Like ``%config(noreplace)`` or any other directive
that be found in the ``%files`` section. You can have multiple directives
per line, as in ``%attr(600,root,root) %config(noreplace)``. Since
that be found in the ``%files`` section. Since
the CPack RPM generator is generating the list of files (and directories) the
user specified files of the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will
be removed from the generated list. If referring to directories do
not add a trailing slash.
.. versionadded:: 3.8
You can have multiple directives per line, as in
``%attr(600,root,root) %config(noreplace)``.
.. variable:: CPACK_RPM_CHANGELOG_FILE
RPM changelog file.
@@ -555,6 +598,9 @@ List of CPack RPM generator specific variables:
the default path. If you want to add some path to the default list then you
can use :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
.. versionadded:: 3.10
Added ``/usr/share/aclocal`` to the default list of excludes.
.. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
additional list of path to be excluded.
@@ -568,6 +614,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_RELOCATION_PATHS
.. versionadded:: 3.2
Packages relocation paths list.
* Mandatory : NO
@@ -591,6 +639,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
.. versionadded:: 3.2
Per component relocation path install prefix.
* Mandatory : NO
@@ -602,6 +652,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
.. versionadded:: 3.3
Removal of default install prefix from relocation paths list.
* Mandatory : NO
@@ -613,6 +665,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
.. versionadded:: 3.3
* Mandatory : NO
* Default : -
@@ -641,6 +695,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_DEFAULT_USER
CPACK_RPM_<compName>_DEFAULT_USER
.. versionadded:: 3.6
default user ownership of RPM content
* Mandatory : NO
@@ -652,6 +708,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_DEFAULT_GROUP
CPACK_RPM_<compName>_DEFAULT_GROUP
.. versionadded:: 3.6
default group ownership of RPM content
* Mandatory : NO
@@ -663,6 +721,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
.. versionadded:: 3.6
default permissions used for packaged files
* Mandatory : NO
@@ -686,6 +746,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
.. versionadded:: 3.6
default permissions used for packaged directories
* Mandatory : NO
@@ -697,6 +759,8 @@ List of CPack RPM generator specific variables:
.. variable:: CPACK_RPM_INSTALL_WITH_EXEC
.. versionadded:: 3.11
force execute permissions on programs and shared libraries
* Mandatory : NO
@@ -714,6 +778,8 @@ List of CPack RPM generator specific variables:
Packaging of Symbolic Links
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.3
The CPack RPM generator supports packaging of symbolic links::
execute_process(COMMAND ${CMAKE_COMMAND}
@@ -731,8 +797,10 @@ those locations will be treated as if they were a part of the package
while determining if symlink should be either created or present in a
post install script - depending on relocation paths.
Symbolic links that point to locations outside packaging path produce a
warning and are treated as non relocatable permanent symbolic links.
.. versionchanged:: 3.6
Symbolic links that point to locations outside packaging path produce a
warning and are treated as non relocatable permanent symbolic links.
Previous versions of CMake produced an error in this case.
Currently there are a few limitations though:
@@ -750,6 +818,8 @@ Currently there are a few limitations though:
Packaging of debug information
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.7
Debuginfo packages contain debug symbols and sources for debugging packaged
binaries.
@@ -832,6 +902,8 @@ Debuginfo RPM packaging has its own set of variables:
.. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE
.. versionadded:: 3.8
Create a single debuginfo package even if components packaging is set.
* Mandatory : NO
@@ -853,6 +925,8 @@ Debuginfo RPM packaging has its own set of variables:
.. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME
CPACK_RPM_<component>_DEBUGINFO_FILE_NAME
.. versionadded:: 3.9
Debuginfo package file name.
* Mandatory : NO
@@ -877,6 +951,8 @@ Debuginfo RPM packaging has its own set of variables:
Packaging of sources (SRPM)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.7
SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
to provide directory containing CMakeLists.txt and source files.

View File

@@ -3,6 +3,9 @@ CPack WIX Generator
CPack WIX generator specific options
.. versionadded:: 3.7
Support :variable:`CPACK_COMPONENT_<compName>_DISABLED` variable.
Variables specific to CPack WIX generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -95,9 +98,10 @@ Windows using WiX.
If this variable is not set, it will be initialized with CPACK_PACKAGE_NAME
If this variable is set to ``.``, then application shortcuts will be
created directly in the start menu and the uninstaller shortcut will be
omitted.
.. versionadded:: 3.16
If this variable is set to ``.``, then application shortcuts will be
created directly in the start menu and the uninstaller shortcut will be
omitted.
.. variable:: CPACK_WIX_CULTURES
@@ -123,7 +127,10 @@ Windows using WiX.
.. variable:: CPACK_WIX_PATCH_FILE
Optional list of XML files with fragments to be inserted into
generated WiX sources
generated WiX sources.
.. versionadded:: 3.5
Support listing multiple patch files.
This optional variable can be used to specify an XML file that the
WIX generator will use to inject fragments into its generated
@@ -152,10 +159,17 @@ Windows using WiX.
Currently fragments can be injected into most
Component, File, Directory and Feature elements.
The following additional special Ids can be used:
.. versionadded:: 3.3
The following additional special Ids can be used:
* ``#PRODUCT`` for the ``<Product>`` element.
* ``#PRODUCTFEATURE`` for the root ``<Feature>`` element.
* ``#PRODUCT`` for the ``<Product>`` element.
* ``#PRODUCTFEATURE`` for the root ``<Feature>`` element.
.. versionadded:: 3.7
Support patching arbitrary ``<Feature>`` elements.
.. versionadded:: 3.9
Allow setting additional attributes.
The following example illustrates how this works.
@@ -227,6 +241,8 @@ Windows using WiX.
.. variable:: CPACK_WIX_PROPERTY_<PROPERTY>
.. versionadded:: 3.1
This variable can be used to provide a value for
the Windows Installer property ``<PROPERTY>``
@@ -243,16 +259,22 @@ Windows using WiX.
.. variable:: CPACK_WIX_ROOT_FEATURE_TITLE
.. versionadded:: 3.7
Sets the name of the root install feature in the WIX installer. Same as
CPACK_COMPONENT_<compName>_DISPLAY_NAME for components.
.. variable:: CPACK_WIX_ROOT_FEATURE_DESCRIPTION
.. versionadded:: 3.7
Sets the description of the root install feature in the WIX installer. Same as
CPACK_COMPONENT_<compName>_DESCRIPTION for components.
.. variable:: CPACK_WIX_SKIP_PROGRAM_FOLDER
.. versionadded:: 3.7
If this variable is set to true, the default install location
of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly.
The install location will not be located relatively below
@@ -270,6 +292,8 @@ Windows using WiX.
.. variable:: CPACK_WIX_ROOT_FOLDER_ID
.. versionadded:: 3.9
This variable allows specification of a custom root folder ID.
The generator specific ``<64>`` token can be used for
folder IDs that come in 32-bit and 64-bit variants.
@@ -289,6 +313,8 @@ Windows using WiX.
.. variable:: CPACK_WIX_CUSTOM_XMLNS
.. versionadded:: 3.19
This variable provides a list of custom namespace declarations that are necessary
for using WiX extensions. Each declaration should be in the form name=url, where
name is the plain namespace without the usual xmlns: prefix and url is an unquoted

View File

@@ -37,9 +37,11 @@ CMake developer documentation is provided by the following documents:
* The `CMake Source Code Guide`_.
* The `CMake Documentation Guide`_.
* The `CMake Experimental Features Guide`_.
.. _`CMake Source Code Guide`: source.rst
.. _`CMake Documentation Guide`: documentation.rst
.. _`CMake Experimental Features Guide`: experimental.rst
Maintainer Documentation
========================

10
Help/dev/experimental.rst Normal file
View File

@@ -0,0 +1,10 @@
CMake Experimental Features Guide
*********************************
The following is a guide to CMake experimental features that are
under development and not yet included in official documentation.
See documentation on `CMake Development`_ for more information.
.. _`CMake Development`: README.rst
No experimental features are under development in this version of CMake.

View File

@@ -357,3 +357,13 @@ policies added for that version. Commit with a message such as::
The files generatd by `install(EXPORT)` and `export()` commands
are known to work with policies as of CMake $prev, so enable them
in sufficiently new CMake versions.
Update the ``cmake_minimum_required`` version range in CMake itself:
* ``CMakeLists.txt``
* ``Utilities/Doxygen/CMakeLists.txt``
* ``Utilities/Sphinx/CMakeLists.txt``
to end in the previous release. Commit with a message such as::
Configure CMake itself with policies through CMake $prev

13
Help/envvar/CUDAARCHS.rst Normal file
View File

@@ -0,0 +1,13 @@
CUDAARCHS
---------
.. versionadded:: 3.20
.. include:: ENV_VAR.txt
Value used to initialize :variable:`CMAKE_CUDA_ARCHITECTURES` on the first
configuration if it's not already defined. Subsequent runs will use the value
stored in the cache.
This is a semicolon-separated list of architectures as described in
:prop_tgt:`CUDA_ARCHITECTURES`.

View File

@@ -7,13 +7,15 @@ Project files for CodeBlocks will be created in the top directory and
in every subdirectory which features a ``CMakeLists.txt`` file containing
a :command:`project` call. Additionally a hierarchy of makefiles is generated
into the build tree.
The :variable:`CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES` variable may
be set to ``ON`` to exclude any files which are located outside of
the project root directory.
The appropriate make program can build the
project through the default ``all`` target. An ``install`` target is
also provided.
.. versionadded:: 3.10
The :variable:`CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES` variable may
be set to ``ON`` to exclude any files which are located outside of
the project root directory.
This "extra" generator may be specified as:
``CodeBlocks - MinGW Makefiles``
@@ -23,7 +25,8 @@ This "extra" generator may be specified as:
Generate with :generator:`NMake Makefiles`.
``CodeBlocks - NMake Makefiles JOM``
Generate with :generator:`NMake Makefiles JOM`.
.. versionadded:: 3.8
Generate with :generator:`NMake Makefiles JOM`.
``CodeBlocks - Ninja``
Generate with :generator:`Ninja`.

View File

@@ -6,13 +6,15 @@ Generates CodeLite project files.
Project files for CodeLite will be created in the top directory and
in every subdirectory which features a CMakeLists.txt file containing
a :command:`project` call.
The :variable:`CMAKE_CODELITE_USE_TARGETS` variable may be set to ``ON``
to change the default behavior from projects to targets as the basis
for project files.
The appropriate make program can build the
project through the default ``all`` target. An ``install`` target
is also provided.
.. versionadded:: 3.7
The :variable:`CMAKE_CODELITE_USE_TARGETS` variable may be set to ``ON``
to change the default behavior from projects to targets as the basis
for project files.
This "extra" generator may be specified as:
``CodeLite - MinGW Makefiles``

View File

@@ -3,22 +3,36 @@ Green Hills MULTI
.. versionadded:: 3.3
.. versionadded:: 3.15
Linux support.
Generates Green Hills MULTI project files (experimental, work-in-progress).
The buildsystem has predetermined build-configuration settings that can be controlled
via the :variable:`CMAKE_BUILD_TYPE` variable.
Customizations are available through the following cache variables:
* ``GHS_CUSTOMIZATION``
* ``GHS_GPJ_MACROS``
.. versionadded:: 3.14
The buildsystem has predetermined build-configuration settings that can be controlled
via the :variable:`CMAKE_BUILD_TYPE` variable.
Toolset and Platform Selection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.13
Customizations that are used to pick toolset and target system:
The ``-A <arch>`` can be supplied for setting the target architecture.
``<arch>`` usually is one of ``arm``, ``ppc``, ``86``, etcetera.
If the target architecture is not specified then
the default architecture of ``arm`` will be used.
* The ``-A <arch>`` can be supplied for setting the target architecture.
``<arch>`` usually is one of ``arm``, ``ppc``, ``86``, etcetera.
If the target architecture is not specified then
the default architecture of ``arm`` will be used.
The ``-T <toolset>`` option can be used to set the directory location of the toolset.
Both absolute and relative paths are valid. Relative paths use ``GHS_TOOLSET_ROOT``
as the root. If the toolset is not specified then the latest toolset found in
``GHS_TOOLSET_ROOT`` will be used.
* The ``-T <toolset>`` option can be used to set the directory location of the toolset.
Both absolute and relative paths are valid. Relative paths use ``GHS_TOOLSET_ROOT``
as the root. If the toolset is not specified then the latest toolset found in
``GHS_TOOLSET_ROOT`` will be used.
Cache variables that are used for toolset and target system customization:
@@ -50,15 +64,18 @@ Cache variables that are used for toolset and target system customization:
a specific RTOS is to be used.
| ``GHS_OS_DIR_OPTION`` default value is ``-os_dir``.
.. versionadded:: 3.15
``GHS_OS_DIR_OPTION`` variable.
* ``GHS_BSP_NAME``
| Sets ``-bsp`` entry in project file.
| Defaults to ``sim<arch>`` for ``integrity`` platforms.
Customizations are available through the following cache variables:
Target Properties
^^^^^^^^^^^^^^^^^
* ``GHS_CUSTOMIZATION``
* ``GHS_GPJ_MACROS``
.. versionadded:: 3.14
The following properties are available:

View File

@@ -2,3 +2,6 @@ NMake Makefiles JOM
-------------------
Generates JOM makefiles.
.. versionadded:: 3.8
:generator:`CodeBlocks` generator can be used as an extra generator.

View File

@@ -11,32 +11,57 @@ For each subdirectory ``sub/dir`` of the project, additional targets
are generated:
``sub/dir/all``
Depends on all targets required by the subdirectory.
.. versionadded:: 3.6
Depends on all targets required by the subdirectory.
``sub/dir/install``
Runs the install step in the subdirectory, if any.
.. versionadded:: 3.7
Runs the install step in the subdirectory, if any.
``sub/dir/install/strip``
Runs the install step in the subdirectory followed by a ``CMAKE_STRIP`` command,
if any.
The ``CMAKE_STRIP`` variable will contain the platform's ``strip`` utility, which
removes symbols information from generated binaries.
.. versionadded:: 3.7
Runs the install step in the subdirectory followed by a ``CMAKE_STRIP`` command,
if any.
The ``CMAKE_STRIP`` variable will contain the platform's ``strip`` utility, which
removes symbols information from generated binaries.
``sub/dir/test``
Runs the test step in the subdirectory, if any.
.. versionadded:: 3.7
Runs the test step in the subdirectory, if any.
``sub/dir/package``
Runs the package step in the subdirectory, if any.
.. versionadded:: 3.7
Runs the package step in the subdirectory, if any.
Fortran Support
^^^^^^^^^^^^^^^
.. versionadded:: 3.7
The ``Ninja`` generator conditionally supports Fortran when the ``ninja``
tool is at least version 1.10 (which has the required features).
Swift Support
^^^^^^^^^^^^^
.. versionadded:: 3.15
The Swift support is experimental, not considered stable, and may change
in future releases of CMake.
See Also
^^^^^^^^
The :generator:`Ninja Multi-Config` generator is similar to the ``Ninja``
generator, but generates multiple configurations at once.
.. versionadded:: 3.17
The :generator:`Ninja Multi-Config` generator is similar to the ``Ninja``
generator, but generates multiple configurations at once.

View File

@@ -1,7 +1,11 @@
For each toolset that comes with this version of Visual Studio, there are
variants that are themselves compiled for 32-bit (``x86``) and
64-bit (``x64``) hosts (independent of the architecture they target).
|VS_TOOLSET_HOST_ARCH_DEFAULT|
One may explicitly request use of either the 32-bit or 64-bit host tools
by adding either ``host=x86`` or ``host=x64`` to the toolset specification.
See the :variable:`CMAKE_GENERATOR_TOOLSET` variable for details.
.. versionadded:: 3.8
For each toolset that comes with this version of Visual Studio, there are
variants that are themselves compiled for 32-bit (``x86``) and
64-bit (``x64``) hosts (independent of the architecture they target).
|VS_TOOLSET_HOST_ARCH_DEFAULT|
One may explicitly request use of either the 32-bit or 64-bit host tools
by adding either ``host=x86`` or ``host=x64`` to the toolset specification.
See the :variable:`CMAKE_GENERATOR_TOOLSET` variable for details.
.. versionadded:: 3.14
Added suport for ``host=x86`` option.

View File

@@ -17,13 +17,14 @@ Platform Selection
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
.. versionadded:: 3.1
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
* ``cmake -G "Visual Studio 10 2010" -A Win32``
* ``cmake -G "Visual Studio 10 2010" -A x64``
* ``cmake -G "Visual Studio 10 2010" -A Itanium``
* ``cmake -G "Visual Studio 10 2010" -A Win32``
* ``cmake -G "Visual Studio 10 2010" -A x64``
* ``cmake -G "Visual Studio 10 2010" -A Itanium``
For compatibility with CMake versions prior to 3.1, one may specify
a target platform name optionally at the end of the generator name.

View File

@@ -17,15 +17,16 @@ Platform Selection
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
.. versionadded:: 3.1
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
* ``cmake -G "Visual Studio 11 2012" -A Win32``
* ``cmake -G "Visual Studio 11 2012" -A x64``
* ``cmake -G "Visual Studio 11 2012" -A ARM``
* ``cmake -G "Visual Studio 11 2012" -A <WinCE-SDK>``
(Specify a target platform matching a Windows CE SDK name.)
* ``cmake -G "Visual Studio 11 2012" -A Win32``
* ``cmake -G "Visual Studio 11 2012" -A x64``
* ``cmake -G "Visual Studio 11 2012" -A ARM``
* ``cmake -G "Visual Studio 11 2012" -A <WinCE-SDK>``
(Specify a target platform matching a Windows CE SDK name.)
For compatibility with CMake versions prior to 3.1, one may specify
a target platform name optionally at the end of the generator name.

View File

@@ -17,13 +17,14 @@ Platform Selection
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
.. versionadded:: 3.1
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
* ``cmake -G "Visual Studio 12 2013" -A Win32``
* ``cmake -G "Visual Studio 12 2013" -A x64``
* ``cmake -G "Visual Studio 12 2013" -A ARM``
* ``cmake -G "Visual Studio 12 2013" -A Win32``
* ``cmake -G "Visual Studio 12 2013" -A x64``
* ``cmake -G "Visual Studio 12 2013" -A ARM``
For compatibility with CMake versions prior to 3.1, one may specify
a target platform name optionally at the end of the generator name.

View File

@@ -51,6 +51,8 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
Windows 10 SDK Maximum Version for VS 2015
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.19
Microsoft stated in a "Windows 10 October 2018 Update" blog post that Windows
10 SDK versions (15063, 16299, 17134, 17763) are not supported by VS 2015 and
are only supported by VS 2017 and later. Therefore by default CMake

View File

@@ -14,18 +14,20 @@ projects (JavaScript, Powershell, Python, etc.) are not supported.
Instance Selection
^^^^^^^^^^^^^^^^^^
VS 2017 supports multiple installations on the same machine.
The :variable:`CMAKE_GENERATOR_INSTANCE` variable may be set as a
cache entry containing the absolute path to a Visual Studio instance.
If the value is not specified explicitly by the user or a toolchain file,
CMake queries the Visual Studio Installer to locate VS instances, chooses
one, and sets the variable as a cache entry to hold the value persistently.
.. versionadded:: 3.9
VS 2017 supports multiple installations on the same machine.
The :variable:`CMAKE_GENERATOR_INSTANCE` variable may be set as a
cache entry containing the absolute path to a Visual Studio instance.
If the value is not specified explicitly by the user or a toolchain file,
CMake queries the Visual Studio Installer to locate VS instances, chooses
one, and sets the variable as a cache entry to hold the value persistently.
When CMake first chooses an instance, if the ``VS150COMNTOOLS`` environment
variable is set and points to the ``Common7/Tools`` directory within
one of the instances, that instance will be used. Otherwise, if more
than one instance is installed we do not define which one is chosen
by default.
.. versionadded:: 3.11
When CMake first chooses an instance, if the ``VS150COMNTOOLS`` environment
variable is set and points to the ``Common7/Tools`` directory within
one of the instances, that instance will be used. Otherwise, if more
than one instance is installed we do not define which one is chosen
by default.
Platform Selection
^^^^^^^^^^^^^^^^^^

View File

@@ -8,15 +8,16 @@ Platform Selection
The default target platform name (architecture) is ``Win32``.
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
.. versionadded:: 3.1
The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
name (architecture). For example:
* ``cmake -G "Visual Studio 9 2008" -A Win32``
* ``cmake -G "Visual Studio 9 2008" -A x64``
* ``cmake -G "Visual Studio 9 2008" -A Itanium``
* ``cmake -G "Visual Studio 9 2008" -A <WinCE-SDK>``
(Specify a target platform matching a Windows CE SDK name.)
* ``cmake -G "Visual Studio 9 2008" -A Win32``
* ``cmake -G "Visual Studio 9 2008" -A x64``
* ``cmake -G "Visual Studio 9 2008" -A Itanium``
* ``cmake -G "Visual Studio 9 2008" -A <WinCE-SDK>``
(Specify a target platform matching a Windows CE SDK name.)
For compatibility with CMake versions prior to 3.1, one may specify
a target platform name optionally at the end of the generator name.

View File

@@ -3,7 +3,8 @@ Xcode
Generate Xcode project files.
This supports Xcode 5.0 and above.
.. versionchanged:: 3.15
This generator supports Xcode 5.0 and above.
.. _`Xcode Build System Selection`:
@@ -14,7 +15,8 @@ By default Xcode is allowed to select its own default toolchain.
The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
This generator supports toolset specification using one of these forms:
.. versionadded:: 3.19
This generator supports toolset specification using one of these forms:
* ``toolset``
* ``toolset[,key=value]*``
@@ -33,3 +35,12 @@ Supported pairs are:
For example, to select the original build system under Xcode 12,
run :manual:`cmake(1)` with the option ``-T buildsystem=1``.
Swift Support
^^^^^^^^^^^^^
.. versionadded:: 3.4
When using the :generator:`Xcode` generator with Xcode 6.1 or higher,
one may enable the ``Swift`` language with the :command:`enable_language`
command or the :command:`project`.

View File

@@ -82,8 +82,8 @@ as the include directories, compile definitions, etc. used to build the
artifacts. Such information can be obtained by using the
:manual:`File API <cmake-file-api(7)>`. The manual page for the File API
contains more information about the API and how to invoke it.
:manual:`Server mode <cmake-server(7)>` is deprecated and should not be
used on CMake 3.14 or later.
:manual:`Server mode <cmake-server(7)>` was removed as of CMake 3.20 and
should not be used on CMake 3.14 or later.
IDEs should avoid creating more build trees than necessary, and only create
multiple build trees if the user wishes to switch to a different compiler,

Some files were not shown because too many files have changed in this diff Show More