summaryrefslogtreecommitdiff
path: root/Help
diff options
context:
space:
mode:
Diffstat (limited to 'Help')
-rw-r--r--Help/command/DEVICE_LINK_OPTIONS.txt2
-rw-r--r--Help/command/FIND_XXX.txt25
-rw-r--r--Help/command/LINK_OPTIONS_LINKER.txt3
-rw-r--r--Help/command/OPTIONS_SHELL.txt16
-rw-r--r--Help/command/add_custom_command.rst30
-rw-r--r--Help/command/build_command.rst16
-rw-r--r--Help/command/cmake_language.rst4
-rw-r--r--Help/command/cmake_minimum_required.rst23
-rw-r--r--Help/command/cmake_path.rst3
-rw-r--r--Help/command/configure_file.rst26
-rw-r--r--Help/command/ctest_build.rst8
-rw-r--r--Help/command/ctest_test.rst110
-rw-r--r--Help/command/enable_language.rst5
-rw-r--r--Help/command/file.rst107
-rw-r--r--Help/command/foreach.rst5
-rw-r--r--Help/command/install.rst162
-rw-r--r--Help/command/install_files.rst2
-rw-r--r--Help/command/install_programs.rst2
-rw-r--r--Help/command/install_targets.rst2
-rw-r--r--Help/command/list.rst4
-rw-r--r--Help/command/project.rst18
-rw-r--r--Help/command/set.rst10
-rw-r--r--Help/command/source_group.rst3
-rw-r--r--Help/command/target_link_libraries.rst85
-rw-r--r--Help/cpack_gen/archive.rst7
-rw-r--r--Help/cpack_gen/deb.rst2
-rw-r--r--Help/cpack_gen/dmg.rst8
-rw-r--r--Help/cpack_gen/freebsd.rst4
-rw-r--r--Help/cpack_gen/nsis.rst6
-rw-r--r--Help/cpack_gen/rpm.rst6
-rw-r--r--Help/dev/experimental.rst4
-rw-r--r--Help/dev/review.rst9
-rw-r--r--Help/envvar/CMAKE_LANG_LINKER_LAUNCHER.rst13
-rw-r--r--Help/envvar/CMAKE_TOOLCHAIN_FILE.rst12
-rw-r--r--Help/envvar/CUDAHOSTCXX.rst4
-rw-r--r--Help/envvar/HIPCXX.rst13
-rw-r--r--Help/envvar/HIPFLAGS.rst15
-rw-r--r--Help/generator/Ninja Multi-Config.rst4
-rw-r--r--Help/generator/VS_TOOLSET_HOST_ARCH.txt18
-rw-r--r--Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt11
-rw-r--r--Help/generator/Visual Studio 10 2010.rst5
-rw-r--r--Help/generator/Visual Studio 11 2012.rst5
-rw-r--r--Help/generator/Visual Studio 12 2013.rst7
-rw-r--r--Help/generator/Visual Studio 14 2015.rst7
-rw-r--r--Help/generator/Visual Studio 15 2017.rst7
-rw-r--r--Help/generator/Visual Studio 16 2019.rst5
-rw-r--r--Help/generator/Visual Studio 17 2022.rst62
-rw-r--r--Help/guide/importing-exporting/MathFunctions/CMakeLists.txt21
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt14
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt7
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt14
-rw-r--r--Help/guide/importing-exporting/index.rst6
-rw-r--r--Help/guide/tutorial/A Basic Starting Point.rst151
-rw-r--r--Help/guide/tutorial/Adding Export Configuration.rst100
-rw-r--r--Help/guide/tutorial/Adding Generator Expressions.rst74
-rw-r--r--Help/guide/tutorial/Adding Support for a Testing Dashboard.rst61
-rw-r--r--Help/guide/tutorial/Adding System Introspection.rst58
-rw-r--r--Help/guide/tutorial/Adding Usage Requirements for a Library.rst52
-rw-r--r--Help/guide/tutorial/Adding a Custom Command and Generated File.rst85
-rw-r--r--Help/guide/tutorial/Adding a Library.rst130
-rw-r--r--Help/guide/tutorial/Installing and Testing.rst93
-rw-r--r--Help/guide/tutorial/Packaging Debug and Release.rst86
-rw-r--r--Help/guide/tutorial/Packaging an Installer.rst57
-rw-r--r--Help/guide/tutorial/Selecting Static or Shared Libraries.rst77
-rw-r--r--Help/guide/tutorial/Step12/CMakeLists.txt1
-rw-r--r--Help/guide/tutorial/index.rst973
-rw-r--r--Help/manual/OPTIONS_BUILD.txt8
-rw-r--r--Help/manual/cmake-compile-features.7.rst1
-rw-r--r--Help/manual/cmake-developer.7.rst18
-rw-r--r--Help/manual/cmake-env-variables.7.rst4
-rw-r--r--Help/manual/cmake-file-api.7.rst287
-rw-r--r--Help/manual/cmake-generator-expressions.7.rst160
-rw-r--r--Help/manual/cmake-generators.7.rst1
-rw-r--r--Help/manual/cmake-modules.7.rst1
-rw-r--r--Help/manual/cmake-policies.7.rst13
-rw-r--r--Help/manual/cmake-presets.7.rst164
-rw-r--r--Help/manual/cmake-properties.7.rst6
-rw-r--r--Help/manual/cmake-toolchains.7.rst4
-rw-r--r--Help/manual/cmake-variables.7.rst7
-rw-r--r--Help/manual/cmake.1.rst17
-rw-r--r--Help/manual/ctest.1.rst75
-rw-r--r--Help/manual/presets/example.json15
-rw-r--r--Help/manual/presets/schema.json503
-rw-r--r--Help/module/FindMsys.rst1
-rw-r--r--Help/policy/CMP0102.rst4
-rw-r--r--Help/policy/CMP0104.rst2
-rw-r--r--Help/policy/CMP0110.rst2
-rw-r--r--Help/policy/CMP0121.rst21
-rw-r--r--Help/policy/CMP0122.rst17
-rw-r--r--Help/policy/CMP0123.rst32
-rw-r--r--Help/policy/CMP0124.rst20
-rw-r--r--Help/policy/CMP0125.rst25
-rw-r--r--Help/policy/CMP0126.rst22
-rw-r--r--Help/prop_dir/BUILDSYSTEM_TARGETS.rst2
-rw-r--r--Help/prop_dir/IMPORTED_TARGETS.rst14
-rw-r--r--Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst21
-rw-r--r--Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst9
-rw-r--r--Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst6
-rw-r--r--Help/prop_sf/COMPILE_FLAGS.rst7
-rw-r--r--Help/prop_sf/COMPILE_OPTIONS.rst7
-rw-r--r--Help/prop_sf/GENERATED.rst7
-rw-r--r--Help/prop_sf/LANGUAGE.rst4
-rw-r--r--Help/prop_test/FAIL_REGULAR_EXPRESSION.rst6
-rw-r--r--Help/prop_test/FIXTURES_REQUIRED.rst4
-rw-r--r--Help/prop_test/PASS_REGULAR_EXPRESSION.rst4
-rw-r--r--Help/prop_test/SKIP_REGULAR_EXPRESSION.rst4
-rw-r--r--Help/prop_tgt/COMPILE_OPTIONS.rst12
-rw-r--r--Help/prop_tgt/CUDA_ARCHITECTURES.rst2
-rw-r--r--Help/prop_tgt/CUDA_STANDARD.rst24
-rw-r--r--Help/prop_tgt/CXX_STANDARD.rst26
-rw-r--r--Help/prop_tgt/C_STANDARD.rst21
-rw-r--r--Help/prop_tgt/HIP_ARCHITECTURES.rst27
-rw-r--r--Help/prop_tgt/IMPORTED_OBJECTS.rst22
-rw-r--r--Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst2
-rw-r--r--Help/prop_tgt/LANG_LINKER_LAUNCHER.rst16
-rw-r--r--Help/prop_tgt/LINK_DEPENDS_NO_SHARED.rst5
-rw-r--r--Help/prop_tgt/LINK_OPTIONS.rst6
-rw-r--r--Help/prop_tgt/OBJCXX_STANDARD.rst22
-rw-r--r--Help/prop_tgt/OBJC_STANDARD.rst11
-rw-r--r--Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst2
-rw-r--r--Help/prop_tgt/Swift_MODULE_DIRECTORY.rst2
-rw-r--r--Help/prop_tgt/UNITY_BUILD_UNIQUE_ID.rst2
-rw-r--r--Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst5
-rw-r--r--Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst6
-rw-r--r--Help/prop_tgt/XCODE_EMBED_type.rst20
-rw-r--r--Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst18
-rw-r--r--Help/prop_tgt/XCODE_EMBED_type_PATH.rst13
-rw-r--r--Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst20
-rw-r--r--Help/release/3.15.rst2
-rw-r--r--Help/release/3.16.rst2
-rw-r--r--Help/release/3.20.rst4
-rw-r--r--Help/release/3.21.rst295
-rw-r--r--Help/release/3.6.rst2
-rw-r--r--Help/release/index.rst1
-rw-r--r--Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst2
-rw-r--r--Help/variable/CMAKE_CFG_INTDIR.rst11
-rw-r--r--Help/variable/CMAKE_CONFIGURATION_TYPES.rst6
-rw-r--r--Help/variable/CMAKE_CUDA_HOST_COMPILER.rst4
-rw-r--r--Help/variable/CMAKE_GENERATOR_TOOLSET.rst24
-rw-r--r--Help/variable/CMAKE_HIP_ARCHITECTURES.rst11
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_ID.rst3
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst2
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS.rst8
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst7
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_INIT.rst2
-rw-r--r--Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst11
-rw-r--r--Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst3
-rw-r--r--Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst2
-rw-r--r--Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst2
-rw-r--r--Help/variable/CMAKE_TLS_VERIFY.rst17
-rw-r--r--Help/variable/CMAKE_TOOLCHAIN_FILE.rst6
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst13
-rw-r--r--Help/variable/CPACK_CUSTOM_INSTALL_VARIABLES.rst44
-rw-r--r--Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst3
-rw-r--r--Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst3
-rw-r--r--Help/variable/CTEST_SCRIPT_DIRECTORY.rst5
-rw-r--r--Help/variable/EXECUTABLE_OUTPUT_PATH.rst2
-rw-r--r--Help/variable/MSVC_VERSION.rst3
-rw-r--r--Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst21
-rw-r--r--Help/variable/PROJECT_IS_TOP_LEVEL.rst31
160 files changed, 4092 insertions, 1234 deletions
diff --git a/Help/command/DEVICE_LINK_OPTIONS.txt b/Help/command/DEVICE_LINK_OPTIONS.txt
index 1297cd054..3d5020816 100644
--- a/Help/command/DEVICE_LINK_OPTIONS.txt
+++ b/Help/command/DEVICE_LINK_OPTIONS.txt
@@ -1,3 +1,5 @@
+Host And Device Specific Link Options
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.18
When a device link step is involved, which is controlled by
diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt
index 97eecfca3..5b63e1cba 100644
--- a/Help/command/FIND_XXX.txt
+++ b/Help/command/FIND_XXX.txt
@@ -11,10 +11,11 @@ The general signature is:
|FIND_XXX| (
<VAR>
name | |NAMES|
- [HINTS path1 [path2 ... ENV var]]
- [PATHS path1 [path2 ... ENV var]]
+ [HINTS [path | ENV var]... ]
+ [PATHS [path | ENV var]... ]
[PATH_SUFFIXES suffix1 [suffix2 ...]]
[DOC "cache documentation string"]
+ [NO_CACHE]
[REQUIRED]
[NO_DEFAULT_PATH]
[NO_PACKAGE_ROOT_PATH]
@@ -28,8 +29,8 @@ The general signature is:
)
This command is used to find a |SEARCH_XXX_DESC|.
-A cache entry named by ``<VAR>`` is created to store the result
-of this command.
+A cache entry, or a normal variable if ``NO_CACHE`` is specified,
+named by ``<VAR>`` is created to store the result 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``.
@@ -56,6 +57,22 @@ Options include:
``DOC``
Specify the documentation string for the ``<VAR>`` cache entry.
+``NO_CACHE``
+ .. versionadded:: 3.21
+
+ The result of the search will be stored in a normal variable rather than
+ a cache entry.
+
+ .. note::
+
+ If the variable is already set before the call (as a normal or cache
+ variable) then the search will not occur.
+
+ .. warning::
+
+ This option should be used with caution because it can greatly increase
+ the cost of repeated configure steps.
+
``REQUIRED``
.. versionadded:: 3.18
diff --git a/Help/command/LINK_OPTIONS_LINKER.txt b/Help/command/LINK_OPTIONS_LINKER.txt
index 3f66181be..e71e5ea25 100644
--- a/Help/command/LINK_OPTIONS_LINKER.txt
+++ b/Help/command/LINK_OPTIONS_LINKER.txt
@@ -1,3 +1,6 @@
+Handling Compiler Driver Differences
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
To pass options to the linker tool, each compiler driver has its own syntax.
The ``LINKER:`` prefix and ``,`` separator can be used to specify, in a portable
way, options to pass to the linker tool. ``LINKER:`` is replaced by the
diff --git a/Help/command/OPTIONS_SHELL.txt b/Help/command/OPTIONS_SHELL.txt
index 4051ffe16..4171f0162 100644
--- a/Help/command/OPTIONS_SHELL.txt
+++ b/Help/command/OPTIONS_SHELL.txt
@@ -1,11 +1,15 @@
-The final set of compile or link options used for a target is constructed by
+Option De-duplication
+^^^^^^^^^^^^^^^^^^^^^
+
+The final set of 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.
.. 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``.
+ up option groups. For example, ``-option A -option B`` becomes
+ ``-option 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:-option A" "SHELL:-option B"`` becomes ``-option A -option B``.
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index c0b95934b..d881a66b5 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -271,21 +271,30 @@ The options are:
``DEPFILE``
.. versionadded:: 3.7
- Specify a ``.d`` depfile for the :generator:`Ninja` generator and
- :ref:`Makefile Generators`.
- A ``.d`` file holds dependencies usually emitted by the custom
- command itself.
- Using ``DEPFILE`` with other generators than :generator:`Ninja` or
- :ref:`Makefile Generators` is an error.
+ Specify a ``.d`` depfile for the :generator:`Ninja`, :generator:`Xcode` and
+ :ref:`Makefile <Makefile Generators>` generators. The depfile may use
+ "generator expressions" with the syntax ``$<...>``. See the
+ :manual:`generator-expressions(7) <cmake-generator-expressions(7)>` manual
+ for available expressions. A ``.d`` file holds dependencies usually emitted
+ by the custom command itself.
+
+ Using ``DEPFILE`` with other generators than :generator:`Ninja`,
+ :generator:`Xcode` or :ref:`Makefile <Makefile Generators>` is an error.
.. versionadded:: 3.20
- Added the support of :ref:`Makefile Generators`.
+ Added support for :ref:`Makefile Generators`.
+
+ .. versionadded:: 3.21
+ Added support for :ref:`Visual Studio Generators` with VS 2012 and above,
+ for the :generator:`Xcode` generator, and for
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
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`. This policy is always ``NEW`` for
- :ref:`Makefile Generators`).
+ :ref:`Makefile Generators`, :ref:`Visual Studio Generators`,
+ and the :generator:`Xcode` generator).
.. note::
@@ -331,6 +340,8 @@ will re-run whenever ``in.txt`` changes.
where ``<config>`` is the build configuration, and then compile the generated
source as part of a library.
+.. _`add_custom_command(TARGET)`:
+
Build Events
^^^^^^^^^^^^
@@ -381,6 +392,9 @@ of the following is specified:
This allows to add individual build events for every configuration.
+.. versionadded:: 3.21
+ Support for target-dependent generator expressions.
+
Examples: Build Events
^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/command/build_command.rst b/Help/command/build_command.rst
index 6659005be..a03979d10 100644
--- a/Help/command/build_command.rst
+++ b/Help/command/build_command.rst
@@ -8,23 +8,29 @@ This is mainly intended for internal use by the :module:`CTest` module.
build_command(<variable>
[CONFIGURATION <config>]
+ [PARALLEL_LEVEL <parallel>]
[TARGET <target>]
[PROJECT_NAME <projname>] # legacy, causes warning
)
Sets the given ``<variable>`` to a command-line string of the form::
- <cmake> --build . [--config <config>] [--target <target>...] [-- -i]
+ <cmake> --build . [--config <config>] [--parallel <parallel>] [--target <target>...] [-- -i]
where ``<cmake>`` is the location of the :manual:`cmake(1)` command-line
-tool, and ``<config>`` and ``<target>`` are the values provided to the
-``CONFIGURATION`` and ``TARGET`` options, if any. The trailing ``-- -i``
-option is added for :ref:`Makefile Generators` if policy :policy:`CMP0061`
-is not set to ``NEW``.
+tool, and ``<config>``, ``<parallel>`` and ``<target>`` are the values
+provided to the ``CONFIGURATION``, ``PARALLEL_LEVEL`` and ``TARGET``
+options, if any. The trailing ``-- -i`` option is added for
+:ref:`Makefile Generators` if policy :policy:`CMP0061` is not set to
+``NEW``.
When invoked, this ``cmake --build`` command line will launch the
underlying build system tool.
+.. versionadded:: 3.21
+ The ``PARALLEL_LEVEL`` argument can be used to set the ``--parallel``
+ flag.
+
.. code-block:: cmake
build_command(<cachevariable> <makecommand>)
diff --git a/Help/command/cmake_language.rst b/Help/command/cmake_language.rst
index 99f874b19..2859f6b6d 100644
--- a/Help/command/cmake_language.rst
+++ b/Help/command/cmake_language.rst
@@ -190,7 +190,7 @@ For example, the code:
.. code-block:: cmake
cmake_language(DEFER CALL message "${deferred_message}")
- cmake_language(DEFER ID_VAR id CALL message "Cancelled Message")
+ cmake_language(DEFER ID_VAR id CALL message "Canceled Message")
cmake_language(DEFER CANCEL_CALL ${id})
message("Immediate Message")
set(deferred_message "Deferred Message")
@@ -201,7 +201,7 @@ prints::
Deferred Message
The ``Cancelled Message`` is never printed because its command is
-cancelled. The ``deferred_message`` variable reference is not evaluated
+canceled. The ``deferred_message`` variable reference is not evaluated
until the call site, so it can be set after the deferred call is scheduled.
In order to evaluate variable references immediately when scheduling a
diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst
index c3b3e7370..d15977049 100644
--- a/Help/command/cmake_minimum_required.rst
+++ b/Help/command/cmake_minimum_required.rst
@@ -5,21 +5,21 @@ Require a minimum version of cmake.
.. code-block:: cmake
- cmake_minimum_required(VERSION <min>[...<max>] [FATAL_ERROR])
+ cmake_minimum_required(VERSION <min>[...<policy_max>] [FATAL_ERROR])
.. versionadded:: 3.12
- The optional ``<max>`` version.
+ The optional ``<policy_max>`` version.
Sets the minimum required version of cmake for a project.
Also updates the policy settings as explained below.
-``<min>`` and the optional ``<max>`` are each CMake versions of the form
-``major.minor[.patch[.tweak]]``, and the ``...`` is literal.
+``<min>`` and the optional ``<policy_max>`` are each CMake versions of the
+form ``major.minor[.patch[.tweak]]``, and the ``...`` is literal.
If the running version of CMake is lower than the ``<min>`` required
version it will stop processing the project and report an error.
-The optional ``<max>`` version, if specified, must be at least the
-``<min>`` version and affects policy settings as described below.
+The optional ``<policy_max>`` version, if specified, must be at least the
+``<min>`` version and affects policy settings as described in `Policy Settings`_.
If the running version of CMake is older than 3.12, the extra ``...``
dots will be seen as version component separators, resulting in the
``...<max>`` part being ignored and preserving the pre-3.12 behavior
@@ -40,8 +40,15 @@ with an error instead of just a warning.
they may affect. See also policy :policy:`CMP0000`.
Calling ``cmake_minimum_required()`` inside a :command:`function`
- limits some effects to the function scope when invoked. Such calls
- should not be made with the intention of having global effects.
+ limits some effects to the function scope when invoked. For example,
+ the :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable won't be set
+ in the calling scope. Functions do not introduce their own policy
+ scope though, so policy settings of the caller *will* be affected
+ (see below). Due to this mix of things that do and do not affect the
+ calling scope, calling ``cmake_minimum_required()`` inside a function
+ is generally discouraged.
+
+.. _`Policy Settings`:
Policy Settings
^^^^^^^^^^^^^^^
diff --git a/Help/command/cmake_path.rst b/Help/command/cmake_path.rst
index e7a01ab60..565a37b6a 100644
--- a/Help/command/cmake_path.rst
+++ b/Help/command/cmake_path.rst
@@ -688,7 +688,8 @@ When the ``NORMALIZE`` option is specified, the path is :ref:`normalized
<Normalization>` after the path computation.
Because ``cmake_path()`` does not access the filesystem, symbolic links are
-not resolved. To compute a real path with symbolic links resolved, use the
+not resolved and any leading tilde is not expanded. To compute a real path
+with symbolic links resolved and leading tildes expanded, use the
:command:`file(REAL_PATH)` command instead.
Native Conversion
diff --git a/Help/command/configure_file.rst b/Help/command/configure_file.rst
index d00f08b7a..086668c16 100644
--- a/Help/command/configure_file.rst
+++ b/Help/command/configure_file.rst
@@ -36,8 +36,30 @@ or
depending on whether ``VAR`` is set in CMake to any value not considered
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.
+
+Unlike lines of the form ``#cmakedefine VAR ...``, in lines of the form
+``#cmakedefine01 VAR``, ``VAR`` itself will expand to ``VAR 0`` or ``VAR 1``
+rather than being assigned the value ``...``. Therefore, input lines of the form
+
+.. code-block:: c
+
+ #cmakedefine01 VAR
+
+will be replaced with either
+
+.. code-block:: c
+
+ #define VAR 0
+
+or
+
+.. code-block:: c
+
+ #define VAR 1
+
+Input lines of the form ``#cmakedefine01 VAR ...`` will expand
+as ``#cmakedefine01 VAR ... 0`` or ``#cmakedefine01 VAR ... 0``,
+which may lead to undefined behavior.
.. versionadded:: 3.10
The result lines (with the exception of the ``#undef`` comments) can be
diff --git a/Help/command/ctest_build.rst b/Help/command/ctest_build.rst
index 4d6dc5a43..e05df1afc 100644
--- a/Help/command/ctest_build.rst
+++ b/Help/command/ctest_build.rst
@@ -7,6 +7,7 @@ Perform the :ref:`CTest Build Step` as a :ref:`Dashboard Client`.
ctest_build([BUILD <build-dir>] [APPEND]
[CONFIGURATION <config>]
+ [PARALLEL_LEVEL <parallel>]
[FLAGS <flags>]
[PROJECT_NAME <project-name>]
[TARGET <target-name>]
@@ -42,6 +43,13 @@ The options are:
Otherwise the ``-C <cfg>`` option given to the :manual:`ctest(1)`
command will be used, if any.
+``PARALLEL_LEVEL <parallel>``
+ .. versionadded:: 3.21
+
+ Specify the parallel level of the underlying build system. If not
+ specified, the :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment
+ variable will be checked.
+
``FLAGS <flags>``
Pass additional arguments to the underlying build command.
If not specified the ``CTEST_BUILD_FLAGS`` variable will be checked.
diff --git a/Help/command/ctest_test.rst b/Help/command/ctest_test.rst
index b4493a03d..2153c90de 100644
--- a/Help/command/ctest_test.rst
+++ b/Help/command/ctest_test.rst
@@ -25,6 +25,7 @@ Perform the :ref:`CTest Test Step` as a :ref:`Dashboard Client`.
[RETURN_VALUE <result-var>]
[CAPTURE_CMAKE_ERROR <result-var>]
[REPEAT <mode>:<n>]
+ [OUTPUT_JUNIT <file>]
[QUIET]
)
@@ -150,6 +151,15 @@ The options are:
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.
+``OUTPUT_JUNIT``
+ .. versionadded:: 3.21
+
+ Write test results to ``<file>`` in JUnit XML format. If ``<file>`` is a
+ relative path it will be placed in the build directory. If ``<file>>``
+ already exists it will be overwritten. Note that the resulting JUnit XML
+ file is **not** uploaded to CDash because it would be redundant with
+ CTest's ``Test.xml`` file.
+
``QUIET``
.. versionadded:: 3.3
@@ -160,3 +170,103 @@ The options are:
See also the :variable:`CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE`
and :variable:`CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE` variables.
+
+.. _`Additional Test Measurements`:
+
+Additional Test Measurements
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+CTest can parse the output of your tests for extra measurements to report
+to CDash.
+
+When run as a :ref:`Dashboard Client`, CTest will include these custom
+measurements in the ``Test.xml`` file that gets uploaded to CDash.
+
+Check the `CDash test measurement documentation
+<https://github.com/Kitware/CDash/blob/master/docs/test_measurements.md>`_
+for more information on the types of test measurements that CDash recognizes.
+
+The following example demonstrates how to output a variety of custom test
+measurements.
+
+.. code-block:: c++
+
+ std::cout <<
+ "<DartMeasurement type=\"numeric/double\" name=\"score\">28.3</DartMeasurement>"
+ << std::endl;
+
+ std::cout <<
+ "<DartMeasurement type=\"text/string\" name=\"color\">red</DartMeasurement>"
+ << std::endl;
+
+ std::cout <<
+ "<DartMeasurement type=\"text/link\" name=\"CMake URL\">https://cmake.org</DartMeasurement>"
+ << std::endl;
+
+ std::cout <<
+ "<DartMeasurement type=\"text/preformatted\" name=\"Console Output\">" <<
+ "line 1.\n" <<
+ " \033[31;1m line 2. Bold red, and indented!\033[0;0ml\n" <<
+ "line 3. Not bold or indented...\n" <<
+ "</DartMeasurement>" << std::endl;
+
+Image Measurements
+""""""""""""""""""
+
+The following example demonstrates how to upload test images to CDash.
+
+.. code-block:: c++
+
+ std::cout <<
+ "<DartMeasurementFile type=\"image/jpg\" name=\"TestImage\">" <<
+ "/dir/to/test_img.jpg</DartMeasurementFile>" << std::endl;
+
+ std::cout <<
+ "<DartMeasurementFile type=\"image/gif\" name=\"ValidImage\">" <<
+ "/dir/to/valid_img.gif</DartMeasurementFile>" << std::endl;
+
+ std::cout <<
+ "<DartMeasurementFile type=\"image/png\" name=\"AlgoResult\"> <<
+ "/dir/to/img.png</DartMeasurementFile>"
+ << std::endl;
+
+Images will be displayed together in an interactive comparison mode on CDash
+if they are provided with two or more of the following names.
+
+* ``TestImage``
+* ``ValidImage``
+* ``BaselineImage``
+* ``DifferenceImage2``
+
+By convention, ``TestImage`` is the image generated by your test, and
+``ValidImage`` (or ``BaselineImage``) is basis of comparison used to determine
+if the test passed or failed.
+
+If another image name is used it will be displayed by CDash as a static image
+separate from the interactive comparison UI.
+
+Attached Files
+""""""""""""""
+
+The following example demonstrates how to upload non-image files to CDash.
+
+.. code-block:: c++
+
+ std::cout <<
+ "<DartMeasurementFile type=\"file\" name=\"MyTestInputData\">" <<
+ "/dir/to/data.csv</DartMeasurementFile>" << std::endl;
+
+If the name of the file to upload is known at configure time, you can use the
+:prop_test:`ATTACHED_FILES` or :prop_test:`ATTACHED_FILES_ON_FAIL` test
+properties instead.
+
+Custom Details
+""""""""""""""
+
+The following example demonstrates how to specify a custom value for the
+``Test Details`` field displayed on CDash.
+
+.. code-block:: c++
+
+ std::cout <<
+ "<CTestDetails>My Custom Details Value</CTestDetails>" << std::endl;
diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst
index ce765de68..d2acbc85c 100644
--- a/Help/command/enable_language.rst
+++ b/Help/command/enable_language.rst
@@ -10,7 +10,7 @@ Enables support for the named language in CMake. This is
the same as the :command:`project` command but does not create any of the extra
variables that are created by the project command. Example languages
are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``,
-``ISPC``, and ``ASM``.
+``HIP``, ``ISPC``, and ``ASM``.
.. versionadded:: 3.8
Added ``CUDA`` support.
@@ -21,6 +21,9 @@ are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``,
.. versionadded:: 3.18
Added ``ISPC`` support.
+.. versionadded:: 3.21
+ Added ``HIP`` support.
+
If enabling ``ASM``, enable it last so that CMake can check whether
compilers for other languages like ``C`` work for assembly too.
diff --git a/Help/command/file.rst b/Help/command/file.rst
index 31de610b2..943bf7c1b 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -38,7 +38,8 @@ Synopsis
`Filesystem`_
file({`GLOB`_ | `GLOB_RECURSE`_} <out-var> [...] [<globbing-expr>...])
- file(`RENAME`_ <oldname> <newname>)
+ file(`RENAME`_ <oldname> <newname> [...])
+ file(`COPY_FILE`_ <oldname> <newname> [...])
file({`REMOVE`_ | `REMOVE_RECURSE`_ } [<files>...])
file(`MAKE_DIRECTORY`_ [<dir>...])
file({`COPY`_ | `INSTALL`_} <file>... DESTINATION <dir> [...])
@@ -49,7 +50,7 @@ Synopsis
file(`CHMOD_RECURSE`_ <files>... <directories>... PERMISSIONS <permissions>... [...])
`Path Conversion`_
- file(`REAL_PATH`_ <path> <out-var> [BASE_DIRECTORY <dir>])
+ file(`REAL_PATH`_ <path> <out-var> [BASE_DIRECTORY <dir>] [EXPAND_TILDE])
file(`RELATIVE_PATH`_ <out-var> <directory> <file>)
file({`TO_CMAKE_PATH`_ | `TO_NATIVE_PATH`_} <path> <out-var>)
@@ -115,7 +116,8 @@ Parse a list of ASCII strings from ``<filename>`` and store it in
binary while reading unless this option is given.
``REGEX <regex>``
- Consider only strings that match the given regular expression.
+ Consider only strings that match the given regular expression,
+ as described under :ref:`string(REGEX) <Regex Specification>`.
``ENCODING <encoding-type>``
.. versionadded:: 3.1
@@ -178,6 +180,8 @@ the ``<format>`` and ``UTC`` options.
[PRE_EXCLUDE_REGEXES [<regexes>...]]
[POST_INCLUDE_REGEXES [<regexes>...]]
[POST_EXCLUDE_REGEXES [<regexes>...]]
+ [POST_INCLUDE_FILES [<files>...]]
+ [POST_EXCLUDE_FILES [<files>...]]
)
.. versionadded:: 3.16
@@ -185,8 +189,10 @@ the ``<format>`` and ``UTC`` options.
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.
-Instead, use it in an :command:`install(CODE)` or :command:`install(SCRIPT)`
-block. For example:
+It is intended for use at install time, either from code generated by the
+:command:`install(RUNTIME_DEPENDENCY_SET)` command, or from code provided by
+the project via :command:`install(CODE)` or :command:`install(SCRIPT)`.
+For example:
.. code-block:: cmake
@@ -275,6 +281,18 @@ be resolved. See below for a full description of how they work.
List of post-exclude regexes through which to filter the names of resolved
dependencies.
+``POST_INCLUDE_FILES <files>``
+ .. versionadded:: 3.21
+
+ List of post-include filenames through which to filter the names of resolved
+ dependencies. Symlinks are resolved when attempting to match these filenames.
+
+``POST_EXCLUDE_FILES <files>``
+ .. versionadded:: 3.21
+
+ List of post-exclude filenames through which to filter the names of resolved
+ dependencies. Symlinks are resolved when attempting to match these filenames.
+
These arguments can be used to exclude unwanted system libraries when
resolving the dependencies, or to include libraries from a specific
directory. The filtering works as follows:
@@ -288,16 +306,18 @@ directory. The filtering works as follows:
4. ``file(GET_RUNTIME_DEPENDENCIES)`` searches for the dependency according to
the linking rules of the platform (see below).
5. If the dependency is found, and its full path matches one of the
- ``POST_INCLUDE_REGEXES``, the full path is added to the resolved
- dependencies, and ``file(GET_RUNTIME_DEPENDENCIES)`` recursively resolves
- that library's own dependencies. Otherwise, resolution proceeds to step 6.
+ ``POST_INCLUDE_REGEXES`` or ``POST_INCLUDE_FILES``, the full path is added
+ to the resolved dependencies, and ``file(GET_RUNTIME_DEPENDENCIES)``
+ recursively resolves that library's own dependencies. Otherwise, resolution
+ proceeds to step 6.
6. If the dependency is found, but its full path matches one of the
- ``POST_EXCLUDE_REGEXES``, it is not added to the resolved dependencies, and
- dependency resolution stops for that dependency.
+ ``POST_EXCLUDE_REGEXES`` or ``POST_EXCLUDE_FILES``, it is not added to the
+ resolved dependencies, and dependency resolution stops for that dependency.
7. If the dependency is found, and its full path does not match either
- ``POST_INCLUDE_REGEXES`` or ``POST_EXCLUDE_REGEXES``, the full path is added
- to the resolved dependencies, and ``file(GET_RUNTIME_DEPENDENCIES)``
- recursively resolves that library's own dependencies.
+ ``POST_INCLUDE_REGEXES``, ``POST_INCLUDE_FILES``, ``POST_EXCLUDE_REGEXES``,
+ or ``POST_EXCLUDE_FILES``, the full path is added to the resolved
+ dependencies, and ``file(GET_RUNTIME_DEPENDENCIES)`` recursively resolves
+ that library's own dependencies.
Different platforms have different rules for how dependencies are resolved.
These specifics are described here.
@@ -675,11 +695,50 @@ Examples of recursive globbing include::
.. code-block:: cmake
- file(RENAME <oldname> <newname>)
+ file(RENAME <oldname> <newname>
+ [RESULT <result>]
+ [NO_REPLACE])
Move a file or directory within a filesystem from ``<oldname>`` to
``<newname>``, replacing the destination atomically.
+The options are:
+
+``RESULT <result>``
+ .. versionadded:: 3.21
+
+ Set ``<result>`` variable to ``0`` on success or an error message otherwise.
+ If ``RESULT`` is not specified and the operation fails, an error is emitted.
+
+``NO_REPLACE``
+ .. versionadded:: 3.21
+
+ If the ``<newname>`` path already exists, do not replace it.
+ If ``RESULT <result>`` is used, the result variable will be
+ set to ``NO_REPLACE``. Otherwise, an error is emitted.
+
+.. _COPY_FILE:
+
+.. code-block:: cmake
+
+ file(COPY_FILE <oldname> <newname>
+ [RESULT <result>]
+ [ONLY_IF_DIFFERENT])
+
+Copy a file from ``<oldname>`` to ``<newname>``. Directories are not
+supported. Symlinks are ignored and ``<oldfile>``'s content is read and
+written to ``<newname>`` as a new file.
+
+The options are:
+
+``RESULT <result>``
+ Set ``<result>`` variable to ``0`` on success or an error message otherwise.
+ If ``RESULT`` is not specified and the operation fails, an error is emitted.
+
+``ONLY_IF_DIFFERENT``
+ If the ``<newname>`` path already exists, do not replace it if it is the
+ same as ``<oldname>``. Otherwise, an error is emitted.
+
.. _REMOVE:
.. _REMOVE_RECURSE:
@@ -888,16 +947,26 @@ Path Conversion
.. code-block:: cmake
- file(REAL_PATH <path> <out-var> [BASE_DIRECTORY <dir>])
+ file(REAL_PATH <path> <out-var> [BASE_DIRECTORY <dir>] [EXPAND_TILDE])
.. versionadded:: 3.19
Compute the absolute path to an existing file or directory with symlinks
resolved.
-If the provided ``<path>`` is a relative path, it is evaluated relative to the
-given base directory ``<dir>``. If no base directory is provided, the default
-base directory will be :variable:`CMAKE_CURRENT_SOURCE_DIR`.
+``BASE_DIRECTORY <dir>``
+ If the provided ``<path>`` is a relative path, it is evaluated relative to the
+ given base directory ``<dir>``. If no base directory is provided, the default
+ base directory will be :variable:`CMAKE_CURRENT_SOURCE_DIR`.
+
+``EXPAND_TILDE``
+ .. versionadded:: 3.21
+
+ If the ``<path>`` is ``~`` or starts with ``~/``, the ``~`` is replaced by
+ the user's home directory. The path to the home directory is obtained from
+ environment variables. On Windows, the ``USERPROFILE`` environment variable
+ is used, falling back to the ``HOME`` environment variable if ``USERPROFILE``
+ is not defined. On all other platforms, only ``HOME`` is used.
.. _RELATIVE_PATH:
@@ -1024,7 +1093,7 @@ If neither ``NETRC`` option is given CMake will check variables
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
-variables ``CMAKE_TLS_VERIFY`` and ``CMAKE_TLS_CAINFO``, respectively.
+variables :variable:`CMAKE_TLS_VERIFY` and ``CMAKE_TLS_CAINFO``, respectively.
Additional options to ``DOWNLOAD`` are:
diff --git a/Help/command/foreach.rst b/Help/command/foreach.rst
index 8de6debae..d9f54ca75 100644
--- a/Help/command/foreach.rst
+++ b/Help/command/foreach.rst
@@ -14,9 +14,12 @@ semicolon or whitespace.
All commands between ``foreach`` and the matching ``endforeach`` are recorded
without being invoked. Once the ``endforeach`` is evaluated, the recorded
list of commands is invoked once for each item in ``<items>``.
-At the beginning of each iteration the variable ``loop_var`` will be set
+At the beginning of each iteration the variable ``<loop_var>`` will be set
to the value of the current item.
+The scope of ``<loop_var>`` is restricted to the loop scope. See policy
+:policy:`CMP0124` for details.
+
The commands :command:`break` and :command:`continue` provide means to
escape from the normal control flow.
diff --git a/Help/command/install.rst b/Help/command/install.rst
index 35207f4c4..c6af4897e 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -9,11 +9,13 @@ Synopsis
.. parsed-literal::
install(`TARGETS`_ <target>... [...])
+ install(`IMPORTED_RUNTIME_ARTIFACTS`_ <target>... [...])
install({`FILES`_ | `PROGRAMS`_} <file>... [...])
install(`DIRECTORY`_ <dir>... [...])
install(`SCRIPT`_ <file> [...])
install(`CODE`_ <code> [...])
install(`EXPORT`_ <export-name> [...])
+ install(`RUNTIME_DEPENDENCY_SET`_ <set-name> [...])
Introduction
^^^^^^^^^^^^
@@ -124,6 +126,7 @@ Installing Targets
.. code-block:: cmake
install(TARGETS targets... [EXPORT <export-name>]
+ [RUNTIME_DEPENDENCIES args...|RUNTIME_DEPENDENCY_SET <set-name>]
[[ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|
PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]
[DESTINATION <dir>]
@@ -338,6 +341,49 @@ top level:
relative path is specified, it is treated as relative to the
``$<INSTALL_PREFIX>``.
+``RUNTIME_DEPENDENCY_SET``
+ .. versionadded:: 3.21
+
+ This option causes all runtime dependencies of installed executable, shared
+ library, and module targets to be added to the specified runtime dependency
+ set. This set can then be installed with an
+ `install(RUNTIME_DEPENDENCY_SET)`_ command.
+
+ This keyword and the ``RUNTIME_DEPENDENCIES`` keyword are mutually
+ exclusive.
+
+``RUNTIME_DEPENDENCIES``
+ .. versionadded:: 3.21
+
+ This option causes all runtime dependencies of installed executable, shared
+ library, and module targets to be installed along with the targets
+ themselves. The ``RUNTIME``, ``LIBRARY``, ``FRAMEWORK``, and generic
+ arguments are used to determine the properties (``DESTINATION``,
+ ``COMPONENT``, etc.) of the installation of these dependencies.
+
+ ``RUNTIME_DEPENDENCIES`` is semantically equivalent to the following pair
+ of calls:
+
+ .. code-block:: cmake
+
+ install(TARGETS ... RUNTIME_DEPENDENCY_SET <set-name>)
+ install(RUNTIME_DEPENDENCY_SET <set-name> args...)
+
+ where ``<set-name>`` will be a randomly generated set name.
+ The ``args...`` may include any of the following keywords supported by
+ the `install(RUNTIME_DEPENDENCY_SET)`_ command:
+
+ * ``DIRECTORIES``
+ * ``PRE_INCLUDE_REGEXES``
+ * ``PRE_EXCLUDE_REGEXES``
+ * ``POST_INCLUDE_REGEXES``
+ * ``POST_EXCLUDE_REGEXES``
+ * ``POST_INCLUDE_FILES``
+ * ``POST_EXCLUDE_FILES``
+
+ The ``RUNTIME_DEPENDENCIES`` and ``RUNTIME_DEPENDENCY_SET`` keywords are
+ mutually exclusive.
+
One or more groups of properties may be specified in a single call to
the ``TARGETS`` form of this command. A target may be installed more than
once to different locations. Consider hypothetical targets ``myExe``,
@@ -382,6 +428,44 @@ set to ``TRUE`` has undefined behavior.
to ensure that such out-of-directory targets are built before the
subdirectory-specific install rules are run.
+Installing Imported Runtime Artifacts
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. _`install(IMPORTED_RUNTIME_ARTIFACTS)`:
+.. _IMPORTED_RUNTIME_ARTIFACTS:
+
+.. versionadded:: 3.21
+
+.. code-block:: cmake
+
+ install(IMPORTED_RUNTIME_ARTIFACTS targets...
+ [RUNTIME_DEPENDENCY_SET <set-name>]
+ [[LIBRARY|RUNTIME|FRAMEWORK|BUNDLE]
+ [DESTINATION <dir>]
+ [PERMISSIONS permissions...]
+ [CONFIGURATIONS [Debug|Release|...]]
+ [COMPONENT <component>]
+ [OPTIONAL] [EXCLUDE_FROM_ALL]
+ ] [...]
+ )
+
+The ``IMPORTED_RUNTIME_ARTIFACTS`` form specifies rules for installing the
+runtime artifacts of imported targets. Projects may do this if they want to
+bundle outside executables or modules inside their installation. The
+``LIBRARY``, ``RUNTIME``, ``FRAMEWORK``, and ``BUNDLE`` arguments have the
+same semantics that they do in the `TARGETS`_ mode. Only the runtime artifacts
+of imported targets are installed (except in the case of :prop_tgt:`FRAMEWORK`
+libraries, :prop_tgt:`MACOSX_BUNDLE` executables, and :prop_tgt:`BUNDLE`
+CFBundles.) For example, headers and import libraries associated with DLLs are
+not installed. In the case of :prop_tgt:`FRAMEWORK` libraries,
+:prop_tgt:`MACOSX_BUNDLE` executables, and :prop_tgt:`BUNDLE` CFBundles, the
+entire directory is installed.
+
+The ``RUNTIME_DEPENDENCY_SET`` option causes the runtime artifacts of the
+imported executable, shared library, and module library ``targets`` to be
+added to the ``<set-name>`` runtime dependency set. This set can then be
+installed with an `install(RUNTIME_DEPENDENCY_SET)`_ command.
+
Installing Files
^^^^^^^^^^^^^^^^
@@ -540,7 +624,8 @@ any expression. For example, the code
will extract and install header files from a source tree.
-Some options may follow a ``PATTERN`` or ``REGEX`` expression and are applied
+Some options may follow a ``PATTERN`` or ``REGEX`` expression as described
+under :ref:`string(REGEX) <Regex Specification>` and are applied
only to files or directories matching them. The ``EXCLUDE`` option will
skip the matched file or directory. The ``PERMISSIONS`` option overrides
the permissions setting for the matched file or directory. For
@@ -619,7 +704,8 @@ Custom Installation Logic
.. code-block:: cmake
install([[SCRIPT <file>] [CODE <code>]]
- [COMPONENT <component>] [EXCLUDE_FROM_ALL] [...])
+ [ALL_COMPONENTS | COMPONENT <component>]
+ [EXCLUDE_FROM_ALL] [...])
The ``SCRIPT`` form will invoke the given CMake script files during
installation. If the script file name is a relative path it will be
@@ -634,6 +720,12 @@ example, the code
will print a message during installation.
+.. versionadded:: 3.21
+ When the ``ALL_COMPONENTS`` option is given, the custom installation
+ script code will be executed for every component of a component-specific
+ installation. This option is mutually exclusive with the ``COMPONENT``
+ option.
+
.. 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
@@ -724,7 +816,7 @@ executable from the installation tree using the imported target name
``mp_myexe`` as if the target were built in its own tree.
.. note::
- This command supercedes the :command:`install_targets` command and
+ This command supersedes the :command:`install_targets` command and
the :prop_tgt:`PRE_INSTALL_SCRIPT` and :prop_tgt:`POST_INSTALL_SCRIPT`
target properties. It also replaces the ``FILES`` forms of the
:command:`install_files` and :command:`install_programs` commands.
@@ -733,6 +825,70 @@ executable from the installation tree using the imported target name
:command:`install_files`, and :command:`install_programs` commands
is not defined.
+Installing Runtime Dependencies
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. _`install(RUNTIME_DEPENDENCY_SET)`:
+.. _RUNTIME_DEPENDENCY_SET:
+
+.. versionadded:: 3.21
+
+.. code-block:: cmake
+
+ install(RUNTIME_DEPENDENCY_SET <set-name>
+ [[LIBRARY|RUNTIME|FRAMEWORK]
+ [DESTINATION <dir>]
+ [PERMISSIONS permissions...]
+ [CONFIGURATIONS [Debug|Release|...]]
+ [COMPONENT <component>]
+ [NAMELINK_COMPONENT <component>]
+ [OPTIONAL] [EXCLUDE_FROM_ALL]
+ ] [...]
+ [PRE_INCLUDE_REGEXES regexes...]
+ [PRE_EXCLUDE_REGEXES regexes...]
+ [POST_INCLUDE_REGEXES regexes...]
+ [POST_EXCLUDE_REGEXES regexes...]
+ [POST_INCLUDE_FILES files...]
+ [POST_EXCLUDE_FILES files...]
+ [DIRECTORIES directories...]
+ )
+
+Installs a runtime dependency set previously created by one or more
+`install(TARGETS)`_ or `install(IMPORTED_RUNTIME_ARTIFACTS)`_ commands. The
+dependencies of targets belonging to a runtime dependency set are installed in
+the ``RUNTIME`` destination and component on DLL platforms, and in the
+``LIBRARY`` destination and component on non-DLL platforms. macOS frameworks
+are installed in the ``FRAMEWORK`` destination and component.
+Targets built within the build tree will never be installed as runtime
+dependencies, nor will their own dependencies, unless the targets themselves
+are installed with `install(TARGETS)`_.
+
+The generated install script calls :command:`file(GET_RUNTIME_DEPENDENCIES)`
+on the build-tree files to calculate the runtime dependencies. The build-tree
+executable files are passed as the ``EXECUTABLES`` argument, the build-tree
+shared libraries as the ``LIBRARIES`` argument, and the build-tree modules as
+the ``MODULES`` argument. On macOS, if one of the executables is a
+:prop_tgt:`MACOSX_BUNDLE`, that executable is passed as the
+``BUNDLE_EXECUTABLE`` argument. At most one such bundle executable may be in
+the runtime dependency set on macOS. The :prop_tgt:`MACOSX_BUNDLE` property
+has no effect on other platforms. Note that
+:command:`file(GET_RUNTIME_DEPENDENCIES)` only supports collecting the runtime
+dependencies for Windows, Linux and macOS platforms, so
+``install(RUNTIME_DEPENDENCY_SET)`` has the same limitation.
+
+The following sub-arguments are forwarded through as the corresponding
+arguments to :command:`file(GET_RUNTIME_DEPENDENCIES)` (for those that provide
+a non-empty list of directories, regular expressions or files). They all
+support :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+* ``DIRECTORIES <directories>``
+* ``PRE_INCLUDE_REGEXES <regexes>``
+* ``PRE_EXCLUDE_REGEXES <regexes>``
+* ``POST_INCLUDE_REGEXES <regexes>``
+* ``POST_EXCLUDE_REGEXES <regexes>``
+* ``POST_INCLUDE_FILES <files>``
+* ``POST_EXCLUDE_FILES <files>``
+
Generated Installation Script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/command/install_files.rst b/Help/command/install_files.rst
index ff074a8a7..494f3d0ee 100644
--- a/Help/command/install_files.rst
+++ b/Help/command/install_files.rst
@@ -5,7 +5,7 @@ install_files
Use the :command:`install(FILES)` command instead.
-This command has been superceded by the :command:`install` command. It is
+This command has been superseded by the :command:`install` command. It is
provided for compatibility with older CMake code. The ``FILES`` form is
directly replaced by the ``FILES`` form of the :command:`install`
command. The regexp form can be expressed more clearly using the ``GLOB``
diff --git a/Help/command/install_programs.rst b/Help/command/install_programs.rst
index fab64820d..eafae8996 100644
--- a/Help/command/install_programs.rst
+++ b/Help/command/install_programs.rst
@@ -5,7 +5,7 @@ install_programs
Use the :command:`install(PROGRAMS)` command instead.
-This command has been superceded by the :command:`install` command. It is
+This command has been superseded by the :command:`install` command. It is
provided for compatibility with older CMake code. The ``FILES`` form is
directly replaced by the ``PROGRAMS`` form of the :command:`install`
command. The regexp form can be expressed more clearly using the ``GLOB``
diff --git a/Help/command/install_targets.rst b/Help/command/install_targets.rst
index c9efdce67..9355f8d53 100644
--- a/Help/command/install_targets.rst
+++ b/Help/command/install_targets.rst
@@ -5,7 +5,7 @@ install_targets
Use the :command:`install(TARGETS)` command instead.
-This command has been superceded by the :command:`install` command. It is
+This command has been superseded by the :command:`install` command. It is
provided for compatibility with older CMake code.
::
diff --git a/Help/command/list.rst b/Help/command/list.rst
index 7accc5a39..f46641f0b 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -141,8 +141,8 @@ Appends elements to the list.
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.
-For more information on regular expressions see also the
-:command:`string` command.
+For more information on regular expressions look under
+:ref:`string(REGEX) <Regex Specification>`.
.. _INSERT:
diff --git a/Help/command/project.rst b/Help/command/project.rst
index 6c931b692..2a9dcfe30 100644
--- a/Help/command/project.rst
+++ b/Help/command/project.rst
@@ -20,12 +20,18 @@ Sets the name of the project, and stores it in the variable
``CMakeLists.txt`` also stores the project name in the
variable :variable:`CMAKE_PROJECT_NAME`.
-Also sets the variables
+Also sets the variables:
-* :variable:`PROJECT_SOURCE_DIR`,
- :variable:`<PROJECT-NAME>_SOURCE_DIR`
-* :variable:`PROJECT_BINARY_DIR`,
- :variable:`<PROJECT-NAME>_BINARY_DIR`
+:variable:`PROJECT_SOURCE_DIR`, :variable:`<PROJECT-NAME>_SOURCE_DIR`
+ Absolute path to the source directory for the project.
+
+:variable:`PROJECT_BINARY_DIR`, :variable:`<PROJECT-NAME>_BINARY_DIR`
+ Absolute path to the binary directory for the project.
+
+:variable:`PROJECT_IS_TOP_LEVEL`, :variable:`<PROJECT-NAME>_IS_TOP_LEVEL`
+ .. versionadded:: 3.21
+
+ Boolean value indicating whether the project is top-level.
Further variables are set by the optional arguments described in the following.
If any of these arguments is not used, then the corresponding variables are
@@ -97,7 +103,7 @@ The options are:
Selects which programming languages are needed to build the project.
Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``,
- ``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, ``ISPC``, and ``ASM``.
+ ``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, ``HIP``, ``ISPC``, and ``ASM``.
By default ``C`` and ``CXX`` are enabled if no language options are given.
Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages,
to skip enabling any languages.
diff --git a/Help/command/set.rst b/Help/command/set.rst
index c0e02e246..af862e4da 100644
--- a/Help/command/set.rst
+++ b/Help/command/set.rst
@@ -68,9 +68,13 @@ users.
If the cache entry does not exist prior to the call or the ``FORCE``
option is given then the cache entry will be set to the given value.
-Furthermore, any normal variable binding in the current scope will
-be removed to expose the newly cached value to any immediately
-following evaluation.
+
+.. note::
+
+ The content of the cache variable will not be directly accessible if a normal
+ variable of the same name already exists (see :ref:`rules of variable
+ evaluation <CMake Language Variables>`). If policy :policy:`CMP0126` is set
+ to ``OLD``, any normal variable binding in the current scope will be removed.
It is possible for the cache entry to exist prior to the call but
have no type set if it was created on the :manual:`cmake(1)` command
diff --git a/Help/command/source_group.rst b/Help/command/source_group.rst
index 5db1ec8c5..a4b5bf1c6 100644
--- a/Help/command/source_group.rst
+++ b/Help/command/source_group.rst
@@ -11,6 +11,9 @@ There are two different signatures to create source groups.
Defines a group into which sources will be placed in project files.
This is intended to set up file tabs in Visual Studio.
+The group is scoped in the directory where the command is called,
+and applies to sources in targets created in that directory.
+
The options are:
``TREE``
diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst
index 872e264e9..ac231bc8f 100644
--- a/Help/command/target_link_libraries.rst
+++ b/Help/command/target_link_libraries.rst
@@ -289,6 +289,91 @@ treated as :ref:`Interface Libraries`, but when they appear in
a target's :prop_tgt:`LINK_LIBRARIES` property their object files
will be included in the link too.
+.. _`Linking Object Libraries via $<TARGET_OBJECTS>`:
+
+Linking Object Libraries via $<TARGET_OBJECTS>
+""""""""""""""""""""""""""""""""""""""""""""""
+
+.. versionadded:: 3.21
+
+The object files associated with an object library may be referenced
+by the :genex:`$<TARGET_OBJECTS>` generator expression. Such object
+files are placed on the link line *before* all libraries, regardless
+of their relative order. Additionally, an ordering dependency will be
+added to the build sysstem to make sure the object library is up-to-date
+before the dependent target links. For example, the code
+
+.. code-block:: cmake
+
+ add_library(obj3 OBJECT obj3.c)
+ target_compile_definitions(obj3 PUBLIC OBJ3)
+
+ add_executable(main3 main3.c)
+ target_link_libraries(main3 PRIVATE a3 $<TARGET_OBJECTS:obj3> b3)
+
+links executable ``main3`` with object files from ``main3.c``
+and ``obj3.c`` followed by the ``a3`` and ``b3`` libraries.
+``main3.c`` is *not* compiled with usage requirements from ``obj3``,
+such as ``-DOBJ3``.
+
+This approach can be used to achieve transitive inclusion of object
+files in link lines as usage requirements. Continuing the above
+example, the code
+
+.. code-block:: cmake
+
+ add_library(iface_obj3 INTERFACE)
+ target_link_libraries(iface_obj3 INTERFACE obj3 $<TARGET_OBJECTS:obj3>)
+
+creates an interface library ``iface_obj3`` that forwards the ``obj3``
+usage requirements and adds the ``obj3`` object files to dependents'
+link lines. The code
+
+.. code-block:: cmake
+
+ add_executable(use_obj3 use_obj3.c)
+ target_link_libraries(use_obj3 PRIVATE iface_obj3)
+
+compiles ``use_obj3.c`` with ``-DOBJ3`` and links executable ``use_obj3``
+with object files from ``use_obj3.c`` and ``obj3.c``.
+
+This also works transitively through a static library. Since a static
+library does not link, it does not consume the object files from
+object libraries referenced this way. Instead, the object files
+become transitive link dependencies of the static library.
+Continuing the above example, the code
+
+.. code-block:: cmake
+
+ add_library(static3 STATIC static3.c)
+ target_link_libraries(static3 PRIVATE iface_obj3)
+
+ add_executable(use_static3 use_static3.c)
+ target_link_libraries(use_static3 PRIVATE static3)
+
+compiles ``static3.c`` with ``-DOBJ3`` and creates ``libstatic3.a``
+using only its own object file. ``use_static3.c`` is compiled *without*
+``-DOBJ3`` because the usage requirement is not transitive through
+the private dependency of ``static3``. However, the link dependencies
+of ``static3`` are propagated, including the ``iface_obj3`` reference
+to ``$<TARGET_OBJECTS:obj3>``. The ``use_static3`` executable is
+created with object files from ``use_static3.c`` and ``obj3.c``, and
+linked to library ``libstatic3.a``.
+
+When using this approach, it is the project's responsibility to avoid
+linking multiple dependent binaries to ``iface_obj3``, because they will
+all get the ``obj3`` object files on their link lines.
+
+.. note::
+
+ Referencing :genex:`$<TARGET_OBJECTS>` in ``target_link_libraries``
+ calls worked in versions of CMake prior to 3.21 for some cases,
+ but was not fully supported:
+
+ * It did not place the object files before libraries on link lines.
+ * It did not add an ordering dependency on the object library.
+ * It did not work in Xcode with multiple architectures.
+
Cyclic Dependencies of Static Libraries
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/cpack_gen/archive.rst b/Help/cpack_gen/archive.rst
index b9418126f..47e8e1354 100644
--- a/Help/cpack_gen/archive.rst
+++ b/Help/cpack_gen/archive.rst
@@ -82,7 +82,8 @@ CPack generators which are essentially archives at their core. These include:
See also the :variable:`CPACK_THREADS` variable.
-.. note::
+ .. versionadded:: 3.21
- Official CMake binaries available on ``cmake.org`` ship with a ``liblzma``
- that does not support parallel compression.
+ Official CMake binaries available on ``cmake.org`` now ship
+ with a ``liblzma`` that supports parallel compression.
+ Older versions did not.
diff --git a/Help/cpack_gen/deb.rst b/Help/cpack_gen/deb.rst
index 03c4ea8db..d8d53ece3 100644
--- a/Help/cpack_gen/deb.rst
+++ b/Help/cpack_gen/deb.rst
@@ -289,7 +289,7 @@ List of CPack DEB generator specific variables:
* Default : "optional"
.. versionadded:: 3.5
- Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY`` varables.
+ Per-component ``CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY`` variables.
See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
diff --git a/Help/cpack_gen/dmg.rst b/Help/cpack_gen/dmg.rst
index 4c662a6f8..64e976998 100644
--- a/Help/cpack_gen/dmg.rst
+++ b/Help/cpack_gen/dmg.rst
@@ -51,7 +51,7 @@ on macOS:
.. versionadded:: 3.6
- Default behaviour is to include a symlink to ``/Applications`` in the DMG.
+ Default behavior 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
@@ -103,6 +103,12 @@ on macOS:
- Default: ``CPACK_PACKAGE_FILE_NAME-<component>``
+.. variable:: CPACK_DMG_FILESYSTEM
+
+ The filesystem format. Common values are ``APFS`` and ``HFS+``.
+ See ``man hdiutil`` for a full list of supported formats.
+ Defaults to ``HFS+``.
+
.. variable:: CPACK_COMMAND_HDIUTIL
Path to the ``hdiutil(1)`` command used to operate on disk image files on
diff --git a/Help/cpack_gen/freebsd.rst b/Help/cpack_gen/freebsd.rst
index 2c9356956..f429bc5fa 100644
--- a/Help/cpack_gen/freebsd.rst
+++ b/Help/cpack_gen/freebsd.rst
@@ -74,7 +74,7 @@ the RPM information (e.g. package license).
* Default:
- :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` (this may be set already
- for Debian packaging, so we may as well re-use it).
+ for Debian packaging, so it is used as a fallback).
.. variable:: CPACK_FREEBSD_PACKAGE_WWW
@@ -87,7 +87,7 @@ the RPM information (e.g. package license).
- :variable:`CMAKE_PROJECT_HOMEPAGE_URL`, or if that is not set,
:variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already
- for Debian packaging, so we may as well re-use it).
+ for Debian packaging, so it is used as a fallback).
.. versionadded:: 3.12
The ``CMAKE_PROJECT_HOMEPAGE_URL`` variable.
diff --git a/Help/cpack_gen/nsis.rst b/Help/cpack_gen/nsis.rst
index de1f3b5fb..02e33ba30 100644
--- a/Help/cpack_gen/nsis.rst
+++ b/Help/cpack_gen/nsis.rst
@@ -195,3 +195,9 @@ on Windows Nullsoft Scriptable Install System.
If set, trim down the size of the control to the size of the branding text string.
Allowed values for this variable are ``LEFT``, ``CENTER`` or ``RIGHT``.
If not specified, the default behavior is ``LEFT``.
+
+.. variable:: CPACK_NSIS_EXECUTABLE
+
+ .. versionadded:: 3.21
+
+ If set, specify the name of the NSIS executable. Default is ``makensis``.
diff --git a/Help/cpack_gen/rpm.rst b/Help/cpack_gen/rpm.rst
index 5260a1d7c..322ab68aa 100644
--- a/Help/cpack_gen/rpm.rst
+++ b/Help/cpack_gen/rpm.rst
@@ -394,8 +394,10 @@ List of CPack RPM generator specific variables:
* Mandatory : NO
* Default : -
- May be used to set weak RPM dependencies (suggests). Note that you must
- enclose the complete requires string between quotes.
+ May be used to set weak RPM dependencies (suggests). If ``rpmbuild`` doesn't
+ support the ``Suggests`` tag, CPack will emit a warning and ignore this
+ variable. Note that you must enclose the complete requires string between
+ quotes.
.. variable:: CPACK_RPM_PACKAGE_PROVIDES
CPACK_RPM_<component>_PACKAGE_PROVIDES
diff --git a/Help/dev/experimental.rst b/Help/dev/experimental.rst
index d0191615a..2380de4b7 100644
--- a/Help/dev/experimental.rst
+++ b/Help/dev/experimental.rst
@@ -39,7 +39,7 @@ to the file specified by the ``<DEP_FILE>`` placeholder, and write module
dependencies to the file specified by the ``<DYNDEP_FILE>`` placeholder.
The module dependencies should be written in the format described
-by the `P1689r3`_ paper.
+by the `P1689r4`_ paper.
Compiler writers may try out their scanning functionality using
the `cxx-modules-sandbox`_ test project, modified to set variables
@@ -66,5 +66,5 @@ the GCC documentation, but the relevant section for the purposes of CMake is:
-- GCC module mapper documentation
.. _`D1483r1`: https://mathstuf.fedorapeople.org/fortran-modules/fortran-modules.html
-.. _`P1689r3`: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1689r3.html
+.. _`P1689r4`: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1689r4.html
.. _`cxx-modules-sandbox`: https://github.com/mathstuf/cxx-modules-sandbox
diff --git a/Help/dev/review.rst b/Help/dev/review.rst
index 8326e7015..198e100a9 100644
--- a/Help/dev/review.rst
+++ b/Help/dev/review.rst
@@ -20,8 +20,10 @@ creating a *merge request* ("MR"). The new MR will appear on the
process is managed by the merge request page for the change.
During the review process, the MR submitter should address review comments
-or test failures by updating the MR with a (force-)push of the topic
-branch. The update initiates a new round of review.
+or test failures by updating their local topic branch to fix their commits
+(e.g. via ``git commit --amend`` or ``git rebase -i``), and then issuing a
+(force-)push of the topic branch to their remote (e.g. ``git push --force``).
+This will automatically initiate a new round of review on the existing MR.
We recommend that users enable the "Remove source branch when merge
request is accepted" option when creating the MR or by editing it.
@@ -254,7 +256,8 @@ The preferred form for references to other commits is
The author date of the commit, in its original time zone, formatted as
``CCYY-MM-DD``. ``git-log(1)`` shows the original time zone by default.
-This may be generated with
+This may be generated with ``git show -s --pretty=reference <commit>`` with
+Git 2.25 and newer. Older versions of Git can generate the same format via
``git show -s --date=short --pretty="format:%h (%s, %ad)" <commit>``.
If the commit is a fix for the mentioned commit, consider using a ``Fixes:``
diff --git a/Help/envvar/CMAKE_LANG_LINKER_LAUNCHER.rst b/Help/envvar/CMAKE_LANG_LINKER_LAUNCHER.rst
new file mode 100644
index 000000000..6251d9c75
--- /dev/null
+++ b/Help/envvar/CMAKE_LANG_LINKER_LAUNCHER.rst
@@ -0,0 +1,13 @@
+CMAKE_<LANG>_LINKER_LAUNCHER
+----------------------------
+
+.. versionadded:: 3.21
+
+.. include:: ENV_VAR.txt
+
+Default launcher to use when linking a target of the specified language. Will
+only be used by CMake to initialize the variable on the first configuration.
+Afterwards, it is available through the cache setting of the variable of the
+same name. For any configuration run (including the first), the environment
+variable will be ignored if the :variable:`CMAKE_<LANG>_LINKER_LAUNCHER`
+variable is defined.
diff --git a/Help/envvar/CMAKE_TOOLCHAIN_FILE.rst b/Help/envvar/CMAKE_TOOLCHAIN_FILE.rst
new file mode 100644
index 000000000..7ea9cea35
--- /dev/null
+++ b/Help/envvar/CMAKE_TOOLCHAIN_FILE.rst
@@ -0,0 +1,12 @@
+CMAKE_TOOLCHAIN_FILE
+--------------------
+
+.. versionadded:: 3.21
+
+.. include:: ENV_VAR.txt
+
+The ``CMAKE_TOOLCHAIN_FILE`` environment variable specifies a default value
+for the :variable:`CMAKE_TOOLCHAIN_FILE` variable when there is no explicit
+configuration given on the first run while creating a new build tree.
+On later runs in an existing build tree the value persists in the cache
+as :variable:`CMAKE_TOOLCHAIN_FILE`.
diff --git a/Help/envvar/CUDAHOSTCXX.rst b/Help/envvar/CUDAHOSTCXX.rst
index 963f9d113..cf65927a5 100644
--- a/Help/envvar/CUDAHOSTCXX.rst
+++ b/Help/envvar/CUDAHOSTCXX.rst
@@ -15,6 +15,10 @@ ignored if the :variable:`CMAKE_CUDA_HOST_COMPILER` variable is defined.
This environment variable is primarily meant for use with projects that
enable ``CUDA`` as a first-class language.
+.. note::
+
+ Ignored when using :ref:`Visual Studio Generators`.
+
.. versionadded:: 3.13
The :module:`FindCUDA`
module will use this variable to initialize its ``CUDA_HOST_COMPILER`` setting.
diff --git a/Help/envvar/HIPCXX.rst b/Help/envvar/HIPCXX.rst
new file mode 100644
index 000000000..23329e978
--- /dev/null
+++ b/Help/envvar/HIPCXX.rst
@@ -0,0 +1,13 @@
+HIPCXX
+------
+
+.. versionadded:: 3.21
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``HIP`` language files. Will only be used by
+CMake on the first configuration to determine ``HIP`` compiler, after which the
+value for ``HIP`` is stored in the cache as
+:variable:`CMAKE_HIP_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration
+run (including the first), the environment variable will be ignored if the
+:variable:`CMAKE_HIP_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
diff --git a/Help/envvar/HIPFLAGS.rst b/Help/envvar/HIPFLAGS.rst
new file mode 100644
index 000000000..0df3416e2
--- /dev/null
+++ b/Help/envvar/HIPFLAGS.rst
@@ -0,0 +1,15 @@
+HIPFLAGS
+--------
+
+.. versionadded:: 3.21
+
+.. include:: ENV_VAR.txt
+
+Default compilation flags to be used when compiling ``HIP`` files. Will only be
+used by CMake on the first configuration to determine ``HIP`` default
+compilation flags, after which the value for ``HIPFLAGS`` is stored in the
+cache as :variable:`CMAKE_HIP_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration
+run (including the first), the environment variable will be ignored if
+the :variable:`CMAKE_HIP_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined.
+
+See also :variable:`CMAKE_HIP_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`.
diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst
index 89011925f..e5ce4f5cd 100644
--- a/Help/generator/Ninja Multi-Config.rst
+++ b/Help/generator/Ninja Multi-Config.rst
@@ -34,7 +34,9 @@ below for how to enable cross-config mode.
The ``Ninja Multi-Config`` generator recognizes the following variables:
:variable:`CMAKE_CONFIGURATION_TYPES`
- Specifies the total set of configurations to build.
+ Specifies the total set of configurations to build. Unlike with other
+ multi-config generators, this variable has a value of
+ ``Debug;Release;RelWithDebInfo`` by default.
:variable:`CMAKE_CROSS_CONFIGS`
Specifies a :ref:`semicolon-separated list <CMake Language Lists>` of
diff --git a/Help/generator/VS_TOOLSET_HOST_ARCH.txt b/Help/generator/VS_TOOLSET_HOST_ARCH.txt
index e36171999..029363115 100644
--- a/Help/generator/VS_TOOLSET_HOST_ARCH.txt
+++ b/Help/generator/VS_TOOLSET_HOST_ARCH.txt
@@ -1,11 +1,7 @@
-.. 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.
+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.
diff --git a/Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt b/Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt
new file mode 100644
index 000000000..069638bd2
--- /dev/null
+++ b/Help/generator/VS_TOOLSET_HOST_ARCH_LEGACY.txt
@@ -0,0 +1,11 @@
+.. 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 support for ``host=x86`` option.
diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst
index b4376d88b..c06555036 100644
--- a/Help/generator/Visual Studio 10 2010.rst
+++ b/Help/generator/Visual Studio 10 2010.rst
@@ -9,8 +9,9 @@ generator using the name ``Visual Studio 10`` without the year component.
Project Types
^^^^^^^^^^^^^
-Only Visual C++ and C# projects may be generated. Other types of
-projects (Database, Website, etc.) are not supported.
+Only Visual C++ and C# projects may be generated (and Fortran with
+Intel compiler integration). Other types of projects (Database,
+Website, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst
index 932548bd2..3952228fe 100644
--- a/Help/generator/Visual Studio 11 2012.rst
+++ b/Help/generator/Visual Studio 11 2012.rst
@@ -9,8 +9,9 @@ generator using the name "Visual Studio 11" without the year component.
Project Types
^^^^^^^^^^^^^
-Only Visual C++ and C# projects may be generated. Other types of
-projects (JavaScript, Database, Website, etc.) are not supported.
+Only Visual C++ and C# projects may be generated (and Fortran with
+Intel compiler integration). Other types of projects (JavaScript,
+Database, Website, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst
index b5fa1bf49..54a4d7eb9 100644
--- a/Help/generator/Visual Studio 12 2013.rst
+++ b/Help/generator/Visual Studio 12 2013.rst
@@ -9,8 +9,9 @@ generator using the name "Visual Studio 12" without the year component.
Project Types
^^^^^^^^^^^^^
-Only Visual C++ and C# projects may be generated. Other types of
-projects (JavaScript, Powershell, Python, etc.) are not supported.
+Only Visual C++ and C# projects may be generated (and Fortran with
+Intel compiler integration). Other types of projects (JavaScript,
+Powershell, Python, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
@@ -46,4 +47,4 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
By default this generator uses the 32-bit variant even on a 64-bit host.
-.. include:: VS_TOOLSET_HOST_ARCH.txt
+.. include:: VS_TOOLSET_HOST_ARCH_LEGACY.txt
diff --git a/Help/generator/Visual Studio 14 2015.rst b/Help/generator/Visual Studio 14 2015.rst
index 9c616414f..d704ab271 100644
--- a/Help/generator/Visual Studio 14 2015.rst
+++ b/Help/generator/Visual Studio 14 2015.rst
@@ -8,8 +8,9 @@ Generates Visual Studio 14 (VS 2015) project files.
Project Types
^^^^^^^^^^^^^
-Only Visual C++ and C# projects may be generated. Other types of
-projects (JavaScript, Powershell, Python, etc.) are not supported.
+Only Visual C++ and C# projects may be generated (and Fortran with
+Intel compiler integration). Other types of projects (JavaScript,
+Powershell, Python, etc.) are not supported.
Platform Selection
^^^^^^^^^^^^^^^^^^
@@ -44,7 +45,7 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
By default this generator uses the 32-bit variant even on a 64-bit host.
-.. include:: VS_TOOLSET_HOST_ARCH.txt
+.. include:: VS_TOOLSET_HOST_ARCH_LEGACY.txt
.. _`Windows 10 SDK Maximum Version for VS 2015`:
diff --git a/Help/generator/Visual Studio 15 2017.rst b/Help/generator/Visual Studio 15 2017.rst
index a002f2ff6..a4f5f98e3 100644
--- a/Help/generator/Visual Studio 15 2017.rst
+++ b/Help/generator/Visual Studio 15 2017.rst
@@ -8,8 +8,9 @@ Generates Visual Studio 15 (VS 2017) project files.
Project Types
^^^^^^^^^^^^^
-Only Visual C++ and C# projects may be generated. Other types of
-projects (JavaScript, Powershell, Python, etc.) are not supported.
+Only Visual C++ and C# projects may be generated (and Fortran with
+Intel compiler integration). Other types of projects (JavaScript,
+Powershell, Python, etc.) are not supported.
Instance Selection
^^^^^^^^^^^^^^^^^^
@@ -63,4 +64,4 @@ via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
By default this generator uses the 32-bit variant even on a 64-bit host.
-.. include:: VS_TOOLSET_HOST_ARCH.txt
+.. include:: VS_TOOLSET_HOST_ARCH_LEGACY.txt
diff --git a/Help/generator/Visual Studio 16 2019.rst b/Help/generator/Visual Studio 16 2019.rst
index 3da80915a..72399e0a2 100644
--- a/Help/generator/Visual Studio 16 2019.rst
+++ b/Help/generator/Visual Studio 16 2019.rst
@@ -8,8 +8,9 @@ Generates Visual Studio 16 (VS 2019) project files.
Project Types
^^^^^^^^^^^^^
-Only Visual C++ and C# projects may be generated. Other types of
-projects (JavaScript, Powershell, Python, etc.) are not supported.
+Only Visual C++ and C# projects may be generated (and Fortran with
+Intel compiler integration). Other types of projects (JavaScript,
+Powershell, Python, etc.) are not supported.
Instance Selection
^^^^^^^^^^^^^^^^^^
diff --git a/Help/generator/Visual Studio 17 2022.rst b/Help/generator/Visual Studio 17 2022.rst
new file mode 100644
index 000000000..06deda463
--- /dev/null
+++ b/Help/generator/Visual Studio 17 2022.rst
@@ -0,0 +1,62 @@
+Visual Studio 17 2022
+---------------------
+
+.. versionadded:: 3.21
+
+Generates Visual Studio 17 (VS 2022) project files.
+
+.. warning::
+
+ This is experimental and based on "Visual Studio 2022 Preview 1.1".
+ As of this version of CMake, VS 2022 has not been released.
+
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated (and Fortran with
+Intel compiler integration). Other types of projects (JavaScript,
+Powershell, Python, etc.) are not supported.
+
+Instance Selection
+^^^^^^^^^^^^^^^^^^
+
+VS 2022 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 ``VS170COMNTOOLS`` 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
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is that of the host
+and is provided in the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
+
+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 17 2022" -A Win32``
+* ``cmake -G "Visual Studio 17 2022" -A x64``
+* ``cmake -G "Visual Studio 17 2022" -A ARM``
+* ``cmake -G "Visual Studio 17 2022" -A ARM64``
+
+Toolset Selection
+^^^^^^^^^^^^^^^^^
+
+The ``v142`` toolset that comes with VS 17 2022 Preview 1.1 is selected by
+default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
+via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
+
+.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
+ By default this generator uses the 64-bit variant on x64 hosts and
+ the 32-bit variant otherwise.
+
+.. include:: VS_TOOLSET_HOST_ARCH.txt
diff --git a/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt
index 9a9e40ee2..d277b5419 100644
--- a/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(MathFunctions)
+# make cache variables for install destinations
+include(GNUInstallDirs)
+
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
@@ -12,26 +15,26 @@ add_library(MathFunctions STATIC MathFunctions.cxx)
target_include_directories(MathFunctions
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
- "$<INSTALL_INTERFACE:include>"
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
# install the target and create export-set
install(TARGETS MathFunctions
EXPORT MathFunctionsTargets
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- RUNTIME DESTINATION bin
- INCLUDES DESTINATION include
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install header file
-install(FILES MathFunctions.h DESTINATION include)
+install(FILES MathFunctions.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# generate and install export file
install(EXPORT MathFunctionsTargets
FILE MathFunctionsTargets.cmake
NAMESPACE MathFunctions::
- DESTINATION lib/cmake/MathFunctions
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions
)
# include CMakePackageConfigHelpers macro
@@ -58,14 +61,14 @@ write_basic_package_version_file(
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
- INSTALL_DESTINATION lib/cmake/MathFunctions
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions
)
# install config files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake"
- DESTINATION lib/cmake/MathFunctions
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions
)
# generate the export targets for the build tree
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
index 17ad95210..9de935eea 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
@@ -7,24 +7,24 @@ add_library(MathFunctions::Addition ALIAS Addition)
target_include_directories(Addition
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
- $<INSTALL_INTERFACE:include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# install the target and create export-set
install(TARGETS Addition
EXPORT AdditionTargets
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- RUNTIME DESTINATION bin
- INCLUDES DESTINATION include
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install header file
-install(FILES Addition.h DESTINATION include)
+install(FILES Addition.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# generate and install export file
install(EXPORT AdditionTargets
FILE MathFunctionsAdditionTargets.cmake
NAMESPACE MathFunctions::
- DESTINATION lib/cmake/MathFunctions
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions
)
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
index fd95e28df..90ee89f0f 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(MathFunctionsComponents)
+# make cache variables for install destinations
+include(GNUInstallDirs)
+
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
@@ -24,7 +27,7 @@ write_basic_package_version_file(
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
- INSTALL_DESTINATION lib/cmake/MathFunctions
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
@@ -32,5 +35,5 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake"
- DESTINATION lib/cmake/MathFunctions
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions
)
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
index be5ae65d1..517c5e26a 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
@@ -7,24 +7,24 @@ add_library(MathFunctions::SquareRoot ALIAS SquareRoot)
target_include_directories(SquareRoot
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
- "$<INSTALL_INTERFACE:include>"
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
# install the target and create export-set
install(TARGETS SquareRoot
EXPORT SquareRootTargets
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- RUNTIME DESTINATION bin
- INCLUDES DESTINATION include
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install header file
-install(FILES SquareRoot.h DESTINATION include)
+install(FILES SquareRoot.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# generate and install export file
install(EXPORT SquareRootTargets
FILE MathFunctionsSquareRootTargets.cmake
NAMESPACE MathFunctions::
- DESTINATION lib/cmake/MathFunctions
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions
)
diff --git a/Help/guide/importing-exporting/index.rst b/Help/guide/importing-exporting/index.rst
index 2e6e06da4..dd3efb8bb 100644
--- a/Help/guide/importing-exporting/index.rst
+++ b/Help/guide/importing-exporting/index.rst
@@ -202,6 +202,10 @@ project. Start by specifying the :command:`cmake_minimum_required` version and
:language: cmake
:end-before: # create library
+The :module:`GNUInstallDirs` module is included in order to provide the
+project with the flexibility to install into different platform layouts by
+making the directories available as cache variables.
+
Create a library called ``MathFunctions`` with the :command:`add_library`
command:
@@ -636,7 +640,7 @@ We can use the :command:`find_package` command:
:start-after: # find MathFunctions
:end-before: # create executable
-Create an exectuable:
+Create an executable:
.. literalinclude:: Downstream/CMakeLists.txt
:language: cmake
diff --git a/Help/guide/tutorial/A Basic Starting Point.rst b/Help/guide/tutorial/A Basic Starting Point.rst
new file mode 100644
index 000000000..41e8479b2
--- /dev/null
+++ b/Help/guide/tutorial/A Basic Starting Point.rst
@@ -0,0 +1,151 @@
+Step 1: A Basic Starting Point
+==============================
+
+The most basic project is an executable built from source code files.
+For simple projects, a three line ``CMakeLists.txt`` file is all that is
+required. This will be the starting point for our tutorial. Create a
+``CMakeLists.txt`` file in the ``Step1`` directory that looks like:
+
+.. code-block:: cmake
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-start
+
+ cmake_minimum_required(VERSION 3.10)
+
+ # set the project name
+ project(Tutorial)
+
+ # add the executable
+ add_executable(Tutorial tutorial.cxx)
+
+
+Note that this example uses lower case commands in the ``CMakeLists.txt`` file.
+Upper, lower, and mixed case commands are supported by CMake. The source
+code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be
+used to compute the square root of a number.
+
+Adding a Version Number and Configured Header File
+--------------------------------------------------
+
+The first feature we will add is to provide our executable and project with a
+version number. While we could do this exclusively in the source code, using
+``CMakeLists.txt`` provides more flexibility.
+
+First, modify the ``CMakeLists.txt`` file to use the :command:`project` command
+to set the project name and version number.
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-project-VERSION
+ :language: cmake
+ :end-before: # specify the C++ standard
+
+Then, configure a header file to pass the version number to the source
+code:
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-configure_file
+ :language: cmake
+ :start-after: # to the source code
+ :end-before: # add the executable
+
+Since the configured file will be written into the binary tree, we
+must add that directory to the list of paths to search for include
+files. Add the following lines to the end of the ``CMakeLists.txt`` file:
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-target_include_directories
+ :language: cmake
+ :start-after: # so that we will find TutorialConfig.h
+
+Using your favorite editor, create ``TutorialConfig.h.in`` in the source
+directory with the following contents:
+
+.. literalinclude:: Step2/TutorialConfig.h.in
+ :caption: TutorialConfig.h.in
+ :name: TutorialConfig.h.in
+ :language: c++
+
+When CMake configures this header file the values for
+``@Tutorial_VERSION_MAJOR@`` and ``@Tutorial_VERSION_MINOR@`` will be
+replaced.
+
+Next modify ``tutorial.cxx`` to include the configured header file,
+``TutorialConfig.h``.
+
+Finally, let's print out the executable name and version number by updating
+``tutorial.cxx`` as follows:
+
+.. literalinclude:: Step2/tutorial.cxx
+ :caption: tutorial.cxx
+ :name: tutorial.cxx-print-version
+ :language: c++
+ :start-after: {
+ :end-before: // convert input to double
+
+Specify the C++ Standard
+-------------------------
+
+Next let's add some C++11 features to our project by replacing ``atof`` with
+``std::stod`` in ``tutorial.cxx``. At the same time, remove
+``#include <cstdlib>``.
+
+.. literalinclude:: Step2/tutorial.cxx
+ :caption: tutorial.cxx
+ :name: tutorial.cxx-cxx11
+ :language: c++
+ :start-after: // convert input to double
+ :end-before: // calculate square root
+
+We will need to explicitly state in the CMake code that it should use the
+correct flags. The easiest way to enable support for a specific C++ standard
+in CMake is by using the :variable:`CMAKE_CXX_STANDARD` variable. For this
+tutorial, set the :variable:`CMAKE_CXX_STANDARD` variable in the
+``CMakeLists.txt`` file to ``11`` and :variable:`CMAKE_CXX_STANDARD_REQUIRED`
+to ``True``. Make sure to add the ``CMAKE_CXX_STANDARD`` declarations above the
+call to ``add_executable``.
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-CXX_STANDARD
+ :language: cmake
+ :end-before: # configure a header file to pass some of the CMake settings
+
+Build and Test
+--------------
+
+Run the :manual:`cmake <cmake(1)>` executable or the
+:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
+with your chosen build tool.
+
+For example, from the command line we could navigate to the
+``Help/guide/tutorial`` directory of the CMake source code tree and create a
+build directory:
+
+.. code-block:: console
+
+ mkdir Step1_build
+
+Next, navigate to the build directory and run CMake to configure the project
+and generate a native build system:
+
+.. code-block:: console
+
+ cd Step1_build
+ cmake ../Step1
+
+Then call that build system to actually compile/link the project:
+
+.. code-block:: console
+
+ cmake --build .
+
+Finally, try to use the newly built ``Tutorial`` with these commands:
+
+.. code-block:: console
+
+ Tutorial 4294967296
+ Tutorial 10
+ Tutorial
diff --git a/Help/guide/tutorial/Adding Export Configuration.rst b/Help/guide/tutorial/Adding Export Configuration.rst
new file mode 100644
index 000000000..e5ab6a226
--- /dev/null
+++ b/Help/guide/tutorial/Adding Export Configuration.rst
@@ -0,0 +1,100 @@
+Step 11: Adding Export Configuration
+====================================
+
+During :guide:`tutorial/Installing and Testing` of the tutorial we added the
+ability for CMake to install the library and headers of the project. During
+:guide:`tutorial/Packaging an Installer` we added the ability to package up
+this information so it could be distributed to other people.
+
+The next step is to add the necessary information so that other CMake projects
+can use our project, be it from a build directory, a local install or when
+packaged.
+
+The first step is to update our :command:`install(TARGETS)` commands to not
+only specify a ``DESTINATION`` but also an ``EXPORT``. The ``EXPORT`` keyword
+generates and installs a CMake file containing code to import all targets
+listed in the install command from the installation tree. So let's go ahead and
+explicitly ``EXPORT`` the ``MathFunctions`` library by updating the ``install``
+command in ``MathFunctions/CMakeLists.txt`` to look like:
+
+.. literalinclude:: Complete/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-install-TARGETS-EXPORT
+ :language: cmake
+ :start-after: # install rules
+
+Now that we have ``MathFunctions`` being exported, we also need to explicitly
+install the generated ``MathFunctionsTargets.cmake`` file. This is done by
+adding the following to the bottom of the top-level ``CMakeLists.txt``:
+
+.. literalinclude:: Complete/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-install-EXPORT
+ :language: cmake
+ :start-after: # install the configuration targets
+ :end-before: include(CMakePackageConfigHelpers)
+
+At this point you should try and run CMake. If everything is setup properly
+you will see that CMake will generate an error that looks like:
+
+.. code-block:: console
+
+ Target "MathFunctions" INTERFACE_INCLUDE_DIRECTORIES property contains
+ path:
+
+ "/Users/robert/Documents/CMakeClass/Tutorial/Step11/MathFunctions"
+
+ which is prefixed in the source directory.
+
+What CMake is trying to say is that during generating the export information
+it will export a path that is intrinsically tied to the current machine and
+will not be valid on other machines. The solution to this is to update the
+``MathFunctions`` :command:`target_include_directories` to understand that it
+needs different ``INTERFACE`` locations when being used from within the build
+directory and from an install / package. This means converting the
+:command:`target_include_directories` call for ``MathFunctions`` to look like:
+
+.. literalinclude:: Step12/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-target_include_directories
+ :language: cmake
+ :start-after: # to find MathFunctions.h, while we don't.
+ :end-before: # should we use our own math functions
+
+Once this has been updated, we can re-run CMake and verify that it doesn't
+warn anymore.
+
+At this point, we have CMake properly packaging the target information that is
+required but we will still need to generate a ``MathFunctionsConfig.cmake`` so
+that the CMake :command:`find_package` command can find our project. So let's go
+ahead and add a new file to the top-level of the project called
+``Config.cmake.in`` with the following contents:
+
+.. literalinclude:: Step12/Config.cmake.in
+ :caption: Config.cmake.in
+ :name: Config.cmake.in
+
+Then, to properly configure and install that file, add the following to the
+bottom of the top-level ``CMakeLists.txt``:
+
+.. literalinclude:: Step12/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-install-Config.cmake
+ :language: cmake
+ :start-after: # install the configuration targets
+ :end-before: # generate the export
+
+At this point, we have generated a relocatable CMake Configuration for our
+project that can be used after the project has been installed or packaged. If
+we want our project to also be used from a build directory we only have to add
+the following to the bottom of the top level ``CMakeLists.txt``:
+
+.. literalinclude:: Step12/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-export
+ :language: cmake
+ :start-after: # needs to be after the install(TARGETS ) command
+
+With this export call we now generate a ``Targets.cmake``, allowing the
+configured ``MathFunctionsConfig.cmake`` in the build directory to be used by
+other projects, without needing it to be installed.
diff --git a/Help/guide/tutorial/Adding Generator Expressions.rst b/Help/guide/tutorial/Adding Generator Expressions.rst
new file mode 100644
index 000000000..55acb346f
--- /dev/null
+++ b/Help/guide/tutorial/Adding Generator Expressions.rst
@@ -0,0 +1,74 @@
+Step 10: Adding Generator Expressions
+=====================================
+
+:manual:`Generator expressions <cmake-generator-expressions(7)>` are evaluated
+during build system generation to produce information specific to each build
+configuration.
+
+:manual:`Generator expressions <cmake-generator-expressions(7)>` are allowed in
+the context of many target properties, such as :prop_tgt:`LINK_LIBRARIES`,
+:prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_DEFINITIONS` and others.
+They may also be used when using commands to populate those properties, such as
+:command:`target_link_libraries`, :command:`target_include_directories`,
+:command:`target_compile_definitions` and others.
+
+:manual:`Generator expressions <cmake-generator-expressions(7)>` may be used
+to enable conditional linking, conditional definitions used when compiling,
+conditional include directories and more. The conditions may be based on the
+build configuration, target properties, platform information or any other
+queryable information.
+
+There are different types of
+:manual:`generator expressions <cmake-generator-expressions(7)>` including
+Logical, Informational, and Output expressions.
+
+Logical expressions are used to create conditional output. The basic
+expressions are the ``0`` and ``1`` expressions. A ``$<0:...>`` results in the
+empty string, and ``<1:...>`` results in the content of ``...``. They can also
+be nested.
+
+A common usage of
+:manual:`generator expressions <cmake-generator-expressions(7)>` is to
+conditionally add compiler flags, such as those for language levels or
+warnings. A nice pattern is to associate this information to an ``INTERFACE``
+target allowing this information to propagate. Let's start by constructing an
+``INTERFACE`` target and specifying the required C++ standard level of ``11``
+instead of using :variable:`CMAKE_CXX_STANDARD`.
+
+So the following code:
+
+.. literalinclude:: Step10/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-CXX_STANDARD-variable-remove
+ :language: cmake
+ :start-after: project(Tutorial VERSION 1.0)
+ :end-before: # control where the static and shared libraries are built so that on windows
+
+Would be replaced with:
+
+.. literalinclude:: Step11/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-cxx_std-feature
+ :language: cmake
+ :start-after: project(Tutorial VERSION 1.0)
+ :end-before: # add compiler warning flags just when building this project via
+
+
+Next we add the desired compiler warning flags that we want for our project. As
+warning flags vary based on the compiler we use the ``COMPILE_LANG_AND_ID``
+generator expression to control which flags to apply given a language and a set
+of compiler ids as seen below:
+
+.. literalinclude:: Step11/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-target_compile_options-genex
+ :language: cmake
+ :start-after: # the BUILD_INTERFACE genex
+ :end-before: # control where the static and shared libraries are built so that on windows
+
+Looking at this we see that the warning flags are encapsulated inside a
+``BUILD_INTERFACE`` condition. This is done so that consumers of our installed
+project will not inherit our warning flags.
+
+**Exercise**: Modify ``MathFunctions/CMakeLists.txt`` so that all targets have
+a :command:`target_link_libraries` call to ``tutorial_compiler_flags``.
diff --git a/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst b/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst
new file mode 100644
index 000000000..26aae4f81
--- /dev/null
+++ b/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst
@@ -0,0 +1,61 @@
+Step 8: Adding Support for a Testing Dashboard
+==============================================
+
+Adding support for submitting our test results to a dashboard is simple. We
+already defined a number of tests for our project in
+:ref:`Testing Support <Tutorial Testing Support>`. Now we just have to run
+those tests and submit them to a dashboard. To include support for dashboards
+we include the :module:`CTest` module in our top-level ``CMakeLists.txt``.
+
+Replace:
+
+.. code-block:: cmake
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-enable_testing-remove
+
+ # enable testing
+ enable_testing()
+
+With:
+
+.. code-block:: cmake
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-include-CTest
+
+ # enable dashboard scripting
+ include(CTest)
+
+The :module:`CTest` module will automatically call ``enable_testing()``, so we
+can remove it from our CMake files.
+
+We will also need to create a ``CTestConfig.cmake`` file in the top-level
+directory where we can specify the name of the project and where to submit the
+dashboard.
+
+.. literalinclude:: Step9/CTestConfig.cmake
+ :caption: CTestConfig.cmake
+ :name: CTestConfig.cmake
+ :language: cmake
+
+The :manual:`ctest <ctest(1)>` executable will read in this file when it runs.
+To create a simple dashboard you can run the :manual:`cmake <cmake(1)>`
+executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project,
+but do not build it yet. Instead, change directory to the binary tree, and then
+run:
+
+.. code-block:: console
+
+ ctest [-VV] -D Experimental
+
+Remember, for multi-config generators (e.g. Visual Studio), the configuration
+type must be specified:
+
+.. code-block:: console
+
+ ctest [-VV] -C Debug -D Experimental
+
+Or, from an IDE, build the ``Experimental`` target.
+
+The :manual:`ctest <ctest(1)>` executable will build and test the project and
+submit the results to Kitware's public dashboard:
+https://my.cdash.org/index.php?project=CMakeTutorial.
diff --git a/Help/guide/tutorial/Adding System Introspection.rst b/Help/guide/tutorial/Adding System Introspection.rst
new file mode 100644
index 000000000..7210a8dbc
--- /dev/null
+++ b/Help/guide/tutorial/Adding System Introspection.rst
@@ -0,0 +1,58 @@
+Step 5: Adding System Introspection
+===================================
+
+Let us consider adding some code to our project that depends on features the
+target platform may not have. For this example, we will add some code that
+depends on whether or not the target platform has the ``log`` and ``exp``
+functions. Of course almost every platform has these functions but for this
+tutorial assume that they are not common.
+
+If the platform has ``log`` and ``exp`` then we will use them to compute the
+square root in the ``mysqrt`` function. We first test for the availability of
+these functions using the :module:`CheckSymbolExists` module in
+``MathFunctions/CMakeLists.txt``. On some platforms, we will need to link to
+the ``m`` library. If ``log`` and ``exp`` are not initially found, require the
+``m`` library and try again.
+
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-check_symbol_exists
+ :language: cmake
+ :start-after: # does this system provide the log and exp functions?
+ :end-before: # add compile definitions
+
+If available, use :command:`target_compile_definitions` to specify
+``HAVE_LOG`` and ``HAVE_EXP`` as ``PRIVATE`` compile definitions.
+
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-target_compile_definitions
+ :language: cmake
+ :start-after: # add compile definitions
+ :end-before: # install rules
+
+If ``log`` and ``exp`` are available on the system, then we will use them to
+compute the square root in the ``mysqrt`` function. Add the following code to
+the ``mysqrt`` function in ``MathFunctions/mysqrt.cxx`` (don't forget the
+``#endif`` before returning the result!):
+
+.. literalinclude:: Step6/MathFunctions/mysqrt.cxx
+ :caption: MathFunctions/mysqrt.cxx
+ :name: MathFunctions/mysqrt.cxx-ifdef
+ :language: c++
+ :start-after: // if we have both log and exp then use them
+ :end-before: // do ten iterations
+
+We will also need to modify ``mysqrt.cxx`` to include ``cmath``.
+
+.. literalinclude:: Step6/MathFunctions/mysqrt.cxx
+ :caption: MathFunctions/mysqrt.cxx
+ :name: MathFunctions/mysqrt.cxx-include-cmath
+ :language: c++
+ :end-before: #include <iostream>
+
+Run the :manual:`cmake <cmake(1)>` executable or the
+:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
+with your chosen build tool and run the Tutorial executable.
+
+Which function gives better results now, ``sqrt`` or ``mysqrt``?
diff --git a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst
new file mode 100644
index 000000000..a8e914eda
--- /dev/null
+++ b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst
@@ -0,0 +1,52 @@
+Step 3: Adding Usage Requirements for a Library
+===============================================
+
+Usage requirements allow for far better control over a library or executable's
+link and include line while also giving more control over the transitive
+property of targets inside CMake. The primary commands that leverage usage
+requirements are:
+
+ - :command:`target_compile_definitions`
+ - :command:`target_compile_options`
+ - :command:`target_include_directories`
+ - :command:`target_link_libraries`
+
+Let's refactor our code from :guide:`tutorial/Adding a Library` to use the
+modern CMake approach of usage requirements. We first state that anybody
+linking to ``MathFunctions`` needs to include the current source directory,
+while ``MathFunctions`` itself doesn't. So this can become an ``INTERFACE``
+usage requirement.
+
+Remember ``INTERFACE`` means things that consumers require but the producer
+doesn't. Add the following lines to the end of
+``MathFunctions/CMakeLists.txt``:
+
+.. literalinclude:: Step4/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-target_include_directories-INTERFACE
+ :language: cmake
+ :start-after: # to find MathFunctions.h
+
+Now that we've specified usage requirements for ``MathFunctions`` we can safely
+remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level
+``CMakeLists.txt``, here:
+
+.. literalinclude:: Step4/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-remove-EXTRA_INCLUDES
+ :language: cmake
+ :start-after: # add the MathFunctions library
+ :end-before: # add the executable
+
+And here:
+
+.. literalinclude:: Step4/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-target_include_directories-remove-EXTRA_INCLUDES
+ :language: cmake
+ :start-after: # so that we will find TutorialConfig.h
+
+Once this is done, run the :manual:`cmake <cmake(1)>` executable or the
+:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
+with your chosen build tool or by using ``cmake --build .`` from the build
+directory.
diff --git a/Help/guide/tutorial/Adding a Custom Command and Generated File.rst b/Help/guide/tutorial/Adding a Custom Command and Generated File.rst
new file mode 100644
index 000000000..70c669562
--- /dev/null
+++ b/Help/guide/tutorial/Adding a Custom Command and Generated File.rst
@@ -0,0 +1,85 @@
+Step 6: Adding a Custom Command and Generated File
+==================================================
+
+Suppose, for the purpose of this tutorial, we decide that we never want to use
+the platform ``log`` and ``exp`` functions and instead would like to
+generate a table of precomputed values to use in the ``mysqrt`` function.
+In this section, we will create the table as part of the build process,
+and then compile that table into our application.
+
+First, let's remove the check for the ``log`` and ``exp`` functions in
+``MathFunctions/CMakeLists.txt``. Then remove the check for ``HAVE_LOG`` and
+``HAVE_EXP`` from ``mysqrt.cxx``. At the same time, we can remove
+:code:`#include <cmath>`.
+
+In the ``MathFunctions`` subdirectory, a new source file named
+``MakeTable.cxx`` has been provided to generate the table.
+
+After reviewing the file, we can see that the table is produced as valid C++
+code and that the output filename is passed in as an argument.
+
+The next step is to add the appropriate commands to the
+``MathFunctions/CMakeLists.txt`` file to build the MakeTable executable and
+then run it as part of the build process. A few commands are needed to
+accomplish this.
+
+First, at the top of ``MathFunctions/CMakeLists.txt``, the executable for
+``MakeTable`` is added as any other executable would be added.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-add_executable-MakeTable
+ :language: cmake
+ :start-after: # first we add the executable that generates the table
+ :end-before: # add the command to generate the source code
+
+Then we add a custom command that specifies how to produce ``Table.h``
+by running MakeTable.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-add_custom_command-Table.h
+ :language: cmake
+ :start-after: # add the command to generate the source code
+ :end-before: # add the main library
+
+Next we have to let CMake know that ``mysqrt.cxx`` depends on the generated
+file ``Table.h``. This is done by adding the generated ``Table.h`` to the list
+of sources for the library MathFunctions.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-add_library-Table.h
+ :language: cmake
+ :start-after: # add the main library
+ :end-before: # state that anybody linking
+
+We also have to add the current binary directory to the list of include
+directories so that ``Table.h`` can be found and included by ``mysqrt.cxx``.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-target_include_directories-Table.h
+ :language: cmake
+ :start-after: # state that we depend on our bin
+ :end-before: # install rules
+
+Now let's use the generated table. First, modify ``mysqrt.cxx`` to include
+``Table.h``. Next, we can rewrite the ``mysqrt`` function to use the table:
+
+.. literalinclude:: Step7/MathFunctions/mysqrt.cxx
+ :caption: MathFunctions/mysqrt.cxx
+ :name: MathFunctions/mysqrt.cxx
+ :language: c++
+ :start-after: // a hack square root calculation using simple operations
+
+Run the :manual:`cmake <cmake(1)>` executable or the
+:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
+with your chosen build tool.
+
+When this project is built it will first build the ``MakeTable`` executable.
+It will then run ``MakeTable`` to produce ``Table.h``. Finally, it will
+compile ``mysqrt.cxx`` which includes ``Table.h`` to produce the
+``MathFunctions`` library.
+
+Run the Tutorial executable and verify that it is using the table.
diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst
new file mode 100644
index 000000000..180636141
--- /dev/null
+++ b/Help/guide/tutorial/Adding a Library.rst
@@ -0,0 +1,130 @@
+Step 2: Adding a Library
+========================
+
+Now we will add a library to our project. This library will contain our own
+implementation for computing the square root of a number. The executable can
+then use this library instead of the standard square root function provided by
+the compiler.
+
+For this tutorial we will put the library into a subdirectory
+called ``MathFunctions``. This directory already contains a header file,
+``MathFunctions.h``, and a source file ``mysqrt.cxx``. The source file has one
+function called ``mysqrt`` that provides similar functionality to the
+compiler's ``sqrt`` function.
+
+Add the following one line ``CMakeLists.txt`` file to the ``MathFunctions``
+directory:
+
+.. literalinclude:: Step3/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt
+ :language: cmake
+
+To make use of the new library we will add an :command:`add_subdirectory`
+call in the top-level ``CMakeLists.txt`` file so that the library will get
+built. We add the new library to the executable, and add ``MathFunctions`` as
+an include directory so that the ``mysqrt.h`` header file can be found. The
+last few lines of the top-level ``CMakeLists.txt`` file should now look like:
+
+.. code-block:: cmake
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-add_subdirectory
+
+ # add the MathFunctions library
+ add_subdirectory(MathFunctions)
+
+ # add the executable
+ add_executable(Tutorial tutorial.cxx)
+
+ target_link_libraries(Tutorial PUBLIC MathFunctions)
+
+ # add the binary tree to the search path for include files
+ # so that we will find TutorialConfig.h
+ target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ "${PROJECT_SOURCE_DIR}/MathFunctions"
+ )
+
+Now let us make the ``MathFunctions`` library optional. While for the tutorial
+there really isn't any need to do so, for larger projects this is a common
+occurrence. The first step is to add an option to the top-level
+``CMakeLists.txt`` file.
+
+.. literalinclude:: Step3/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-option
+ :language: cmake
+ :start-after: # should we use our own math functions
+ :end-before: # add the MathFunctions library
+
+This option will be displayed in the :manual:`cmake-gui <cmake-gui(1)>` and
+:manual:`ccmake <ccmake(1)>`
+with a default value of ``ON`` that can be changed by the user. This setting
+will be stored in the cache so that the user does not need to set the value
+each time they run CMake on a build directory.
+
+The next change is to make building and linking the ``MathFunctions`` library
+conditional. To do this we change the end of the top-level ``CMakeLists.txt``
+file to look like the following:
+
+.. literalinclude:: Step3/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-target_link_libraries-EXTRA_LIBS
+ :language: cmake
+ :start-after: # add the MathFunctions library
+
+Note the use of the variable ``EXTRA_LIBS`` to collect up any optional
+libraries to later be linked into the executable. The variable
+``EXTRA_INCLUDES`` is used similarly for optional header files. This is a
+classic approach when dealing with many optional components, we will cover
+the modern approach in the next step.
+
+The corresponding changes to the source code are fairly straightforward.
+First, in ``tutorial.cxx``, include the ``MathFunctions.h`` header if we
+need it:
+
+.. literalinclude:: Step3/tutorial.cxx
+ :caption: tutorial.cxx
+ :name: tutorial.cxx-ifdef-include
+ :language: c++
+ :start-after: // should we include the MathFunctions header
+ :end-before: int main
+
+Then, in the same file, make ``USE_MYMATH`` control which square root
+function is used:
+
+.. literalinclude:: Step3/tutorial.cxx
+ :caption: tutorial.cxx
+ :name: tutorial.cxx-ifdef-const
+ :language: c++
+ :start-after: // which square root function should we use?
+ :end-before: std::cout << "The square root of
+
+Since the source code now requires ``USE_MYMATH`` we can add it to
+``TutorialConfig.h.in`` with the following line:
+
+.. literalinclude:: Step3/TutorialConfig.h.in
+ :caption: TutorialConfig.h.in
+ :name: TutorialConfig.h.in-cmakedefine
+ :language: c++
+ :lines: 4
+
+**Exercise**: Why is it important that we configure ``TutorialConfig.h.in``
+after the option for ``USE_MYMATH``? What would happen if we inverted the two?
+
+Run the :manual:`cmake <cmake(1)>` executable or the
+:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
+with your chosen build tool. Then run the built Tutorial executable.
+
+Now let's update the value of ``USE_MYMATH``. The easiest way is to use the
+:manual:`cmake-gui <cmake-gui(1)>` or :manual:`ccmake <ccmake(1)>` if you're
+in the terminal. Or, alternatively, if you want to change the option from the
+command-line, try:
+
+.. code-block:: console
+
+ cmake ../Step2 -DUSE_MYMATH=OFF
+
+Rebuild and run the tutorial again.
+
+Which function gives better results, ``sqrt`` or ``mysqrt``?
diff --git a/Help/guide/tutorial/Installing and Testing.rst b/Help/guide/tutorial/Installing and Testing.rst
new file mode 100644
index 000000000..2fc3202e5
--- /dev/null
+++ b/Help/guide/tutorial/Installing and Testing.rst
@@ -0,0 +1,93 @@
+Step 4: Installing and Testing
+==============================
+
+Now we can start adding install rules and testing support to our project.
+
+Install Rules
+-------------
+
+The install rules are fairly simple: for ``MathFunctions`` we want to install
+the library and header file and for the application we want to install the
+executable and configured header.
+
+So to the end of ``MathFunctions/CMakeLists.txt`` we add:
+
+.. literalinclude:: Step5/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-install-TARGETS
+ :language: cmake
+ :start-after: # install rules
+
+And to the end of the top-level ``CMakeLists.txt`` we add:
+
+.. literalinclude:: Step5/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-install-TARGETS
+ :language: cmake
+ :start-after: # add the install targets
+ :end-before: # enable testing
+
+That is all that is needed to create a basic local install of the tutorial.
+
+Now run the :manual:`cmake <cmake(1)>` executable or the
+:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
+with your chosen build tool.
+
+Then run the install step by using the ``install`` option of the
+:manual:`cmake <cmake(1)>` command (introduced in 3.15, older versions of
+CMake must use ``make install``) from the command line. For
+multi-configuration tools, don't forget to use the ``--config`` argument to
+specify the configuration. If using an IDE, simply build the ``INSTALL``
+target. This step will install the appropriate header files, libraries, and
+executables. For example:
+
+.. code-block:: console
+
+ cmake --install .
+
+The CMake variable :variable:`CMAKE_INSTALL_PREFIX` is used to determine the
+root of where the files will be installed. If using the ``cmake --install``
+command, the installation prefix can be overridden via the ``--prefix``
+argument. For example:
+
+.. code-block:: console
+
+ cmake --install . --prefix "/home/myuser/installdir"
+
+Navigate to the install directory and verify that the installed Tutorial runs.
+
+.. _`Tutorial Testing Support`:
+
+Testing Support
+---------------
+
+Next let's test our application. At the end of the top-level ``CMakeLists.txt``
+file we can enable testing and then add a number of basic tests to verify that
+the application is working correctly.
+
+.. literalinclude:: Step5/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-enable_testing
+ :language: cmake
+ :start-after: # enable testing
+
+The first test simply verifies that the application runs, does not segfault or
+otherwise crash, and has a zero return value. This is the basic form of a
+CTest test.
+
+The next test makes use of the :prop_test:`PASS_REGULAR_EXPRESSION` test
+property to verify that the output of the test contains certain strings. In
+this case, verifying that the usage message is printed when an incorrect number
+of arguments are provided.
+
+Lastly, we have a function called ``do_test`` that runs the application and
+verifies that the computed square root is correct for given input. For each
+invocation of ``do_test``, another test is added to the project with a name,
+input, and expected results based on the passed arguments.
+
+Rebuild the application and then cd to the binary directory and run the
+:manual:`ctest <ctest(1)>` executable: ``ctest -N`` and ``ctest -VV``. For
+multi-config generators (e.g. Visual Studio), the configuration type must be
+specified. To run tests in Debug mode, for example, use ``ctest -C Debug -VV``
+from the build directory (not the Debug subdirectory!). Alternatively, build
+the ``RUN_TESTS`` target from the IDE.
diff --git a/Help/guide/tutorial/Packaging Debug and Release.rst b/Help/guide/tutorial/Packaging Debug and Release.rst
new file mode 100644
index 000000000..91b46a778
--- /dev/null
+++ b/Help/guide/tutorial/Packaging Debug and Release.rst
@@ -0,0 +1,86 @@
+Step 12: Packaging Debug and Release
+====================================
+
+**Note:** This example is valid for single-configuration generators and will
+not work for multi-configuration generators (e.g. Visual Studio).
+
+By default, CMake's model is that a build directory only contains a single
+configuration, be it Debug, Release, MinSizeRel, or RelWithDebInfo. It is
+possible, however, to setup CPack to bundle multiple build directories and
+construct a package that contains multiple configurations of the same project.
+
+First, we want to ensure that the debug and release builds use different names
+for the executables and libraries that will be installed. Let's use `d` as the
+postfix for the debug executable and libraries.
+
+Set :variable:`CMAKE_DEBUG_POSTFIX` near the beginning of the top-level
+``CMakeLists.txt`` file:
+
+.. literalinclude:: Complete/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-CMAKE_DEBUG_POSTFIX-variable
+ :language: cmake
+ :start-after: project(Tutorial VERSION 1.0)
+ :end-before: target_compile_features(tutorial_compiler_flags
+
+And the :prop_tgt:`DEBUG_POSTFIX` property on the tutorial executable:
+
+.. literalinclude:: Complete/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-DEBUG_POSTFIX-property
+ :language: cmake
+ :start-after: # add the executable
+ :end-before: # add the binary tree to the search path for include files
+
+Let's also add version numbering to the ``MathFunctions`` library. In
+``MathFunctions/CMakeLists.txt``, set the :prop_tgt:`VERSION` and
+:prop_tgt:`SOVERSION` properties:
+
+.. literalinclude:: Complete/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-VERSION-properties
+ :language: cmake
+ :start-after: # setup the version numbering
+ :end-before: # install rules
+
+From the ``Step12`` directory, create ``debug`` and ``release``
+subbdirectories. The layout will look like:
+
+.. code-block:: none
+
+ - Step12
+ - debug
+ - release
+
+Now we need to setup debug and release builds. We can use
+:variable:`CMAKE_BUILD_TYPE` to set the configuration type:
+
+.. code-block:: console
+
+ cd debug
+ cmake -DCMAKE_BUILD_TYPE=Debug ..
+ cmake --build .
+ cd ../release
+ cmake -DCMAKE_BUILD_TYPE=Release ..
+ cmake --build .
+
+Now that both the debug and release builds are complete, we can use a custom
+configuration file to package both builds into a single release. In the
+``Step12`` directory, create a file called ``MultiCPackConfig.cmake``. In this
+file, first include the default configuration file that was created by the
+:manual:`cmake <cmake(1)>` executable.
+
+Next, use the ``CPACK_INSTALL_CMAKE_PROJECTS`` variable to specify which
+projects to install. In this case, we want to install both debug and release.
+
+.. literalinclude:: Complete/MultiCPackConfig.cmake
+ :caption: MultiCPackConfig.cmake
+ :name: MultiCPackConfig.cmake
+ :language: cmake
+
+From the ``Step12`` directory, run :manual:`cpack <cpack(1)>` specifying our
+custom configuration file with the ``config`` option:
+
+.. code-block:: console
+
+ cpack --config MultiCPackConfig.cmake
diff --git a/Help/guide/tutorial/Packaging an Installer.rst b/Help/guide/tutorial/Packaging an Installer.rst
new file mode 100644
index 000000000..5eb3e3e5f
--- /dev/null
+++ b/Help/guide/tutorial/Packaging an Installer.rst
@@ -0,0 +1,57 @@
+Step 7: Packaging an Installer
+==============================
+
+Next suppose that we want to distribute our project to other people so that
+they can use it. We want to provide both binary and source distributions on a
+variety of platforms. This is a little different from the install we did
+previously in :guide:`tutorial/Installing and Testing`, where we were
+installing the binaries that we had built from the source code. In this
+example we will be building installation packages that support binary
+installations and package management features. To accomplish this we will use
+CPack to create platform specific installers. Specifically we need to add a
+few lines to the bottom of our top-level ``CMakeLists.txt`` file.
+
+.. literalinclude:: Step8/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-include-CPack
+ :language: cmake
+ :start-after: # setup installer
+
+That is all there is to it. We start by including
+:module:`InstallRequiredSystemLibraries`. This module will include any runtime
+libraries that are needed by the project for the current platform. Next we set
+some CPack variables to where we have stored the license and version
+information for this project. The version information was set earlier in this
+tutorial and the ``license.txt`` has been included in the top-level source
+directory for this step.
+
+Finally we include the :module:`CPack module <CPack>` which will use these
+variables and some other properties of the current system to setup an
+installer.
+
+The next step is to build the project in the usual manner and then run the
+:manual:`cpack <cpack(1)>` executable. To build a binary distribution, from the
+binary directory run:
+
+.. code-block:: console
+
+ cpack
+
+To specify the generator, use the ``-G`` option. For multi-config builds, use
+``-C`` to specify the configuration. For example:
+
+.. code-block:: console
+
+ cpack -G ZIP -C Debug
+
+To create a source distribution you would type:
+
+.. code-block:: console
+
+ cpack --config CPackSourceConfig.cmake
+
+Alternatively, run ``make package`` or right click the ``Package`` target and
+``Build Project`` from an IDE.
+
+Run the installer found in the binary directory. Then run the installed
+executable and verify that it works.
diff --git a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst
new file mode 100644
index 000000000..2d5f70e06
--- /dev/null
+++ b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst
@@ -0,0 +1,77 @@
+Step 9: Selecting Static or Shared Libraries
+============================================
+
+In this section we will show how the :variable:`BUILD_SHARED_LIBS` variable can
+be used to control the default behavior of :command:`add_library`,
+and allow control over how libraries without an explicit type (``STATIC``,
+``SHARED``, ``MODULE`` or ``OBJECT``) are built.
+
+To accomplish this we need to add :variable:`BUILD_SHARED_LIBS` to the
+top-level ``CMakeLists.txt``. We use the :command:`option` command as it allows
+users to optionally select if the value should be ``ON`` or ``OFF``.
+
+Next we are going to refactor ``MathFunctions`` to become a real library that
+encapsulates using ``mysqrt`` or ``sqrt``, instead of requiring the calling
+code to do this logic. This will also mean that ``USE_MYMATH`` will not control
+building ``MathFunctions``, but instead will control the behavior of this
+library.
+
+The first step is to update the starting section of the top-level
+``CMakeLists.txt`` to look like:
+
+.. literalinclude:: Step10/CMakeLists.txt
+ :caption: CMakeLists.txt
+ :name: CMakeLists.txt-option-BUILD_SHARED_LIBS
+ :language: cmake
+ :end-before: # add the binary tree
+
+Now that we have made ``MathFunctions`` always be used, we will need to update
+the logic of that library. So, in ``MathFunctions/CMakeLists.txt`` we need to
+create a SqrtLibrary that will conditionally be built and installed when
+``USE_MYMATH`` is enabled. Now, since this is a tutorial, we are going to
+explicitly require that SqrtLibrary is built statically.
+
+The end result is that ``MathFunctions/CMakeLists.txt`` should look like:
+
+.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-add_library-STATIC
+ :language: cmake
+ :lines: 1-36,42-
+
+Next, update ``MathFunctions/mysqrt.cxx`` to use the ``mathfunctions`` and
+``detail`` namespaces:
+
+.. literalinclude:: Step10/MathFunctions/mysqrt.cxx
+ :caption: MathFunctions/mysqrt.cxx
+ :name: MathFunctions/mysqrt.cxx-namespace
+ :language: c++
+
+We also need to make some changes in ``tutorial.cxx``, so that it no longer
+uses ``USE_MYMATH``:
+
+#. Always include ``MathFunctions.h``
+#. Always use ``mathfunctions::sqrt``
+#. Don't include ``cmath``
+
+Finally, update ``MathFunctions/MathFunctions.h`` to use dll export defines:
+
+.. literalinclude:: Step10/MathFunctions/MathFunctions.h
+ :caption: MathFunctions/MathFunctions.h
+ :name: MathFunctions/MathFunctions.h
+ :language: c++
+
+At this point, if you build everything, you may notice that linking fails
+as we are combining a static library without position independent code with a
+library that has position independent code. The solution to this is to
+explicitly set the :prop_tgt:`POSITION_INDEPENDENT_CODE` target property of
+SqrtLibrary to be ``True`` no matter the build type.
+
+.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
+ :caption: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-POSITION_INDEPENDENT_CODE
+ :language: cmake
+ :lines: 37-42
+
+**Exercise**: We modified ``MathFunctions.h`` to use dll export defines.
+Using CMake documentation can you find a helper module to simplify this?
diff --git a/Help/guide/tutorial/Step12/CMakeLists.txt b/Help/guide/tutorial/Step12/CMakeLists.txt
index eca79d9df..1b0c82667 100644
--- a/Help/guide/tutorial/Step12/CMakeLists.txt
+++ b/Help/guide/tutorial/Step12/CMakeLists.txt
@@ -110,6 +110,7 @@ write_basic_package_version_file(
# install the configuration file
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake
DESTINATION lib/cmake/MathFunctions
)
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index 94753d5dc..8b20a2dfe 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -1,946 +1,43 @@
CMake Tutorial
**************
-.. only:: html
-
- .. contents::
-
Introduction
============
The CMake tutorial provides a step-by-step guide that covers common build
system issues that CMake helps address. Seeing how various topics all
-work together in an example project can be very helpful. The tutorial
-documentation and source code for examples can be found in the
-``Help/guide/tutorial`` directory of the CMake source code tree. Each step has
-its own subdirectory containing code that may be used as a starting point. The
-tutorial examples are progressive so that each step provides the complete
-solution for the previous step.
-
-A Basic Starting Point (Step 1)
-===============================
-
-The most basic project is an executable built from source code files.
-For simple projects, a three line ``CMakeLists.txt`` file is all that is
-required. This will be the starting point for our tutorial. Create a
-``CMakeLists.txt`` file in the ``Step1`` directory that looks like:
-
-.. code-block:: cmake
-
- cmake_minimum_required(VERSION 3.10)
-
- # set the project name
- project(Tutorial)
-
- # add the executable
- add_executable(Tutorial tutorial.cxx)
-
-
-Note that this example uses lower case commands in the ``CMakeLists.txt`` file.
-Upper, lower, and mixed case commands are supported by CMake. The source
-code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be
-used to compute the square root of a number.
-
-Adding a Version Number and Configured Header File
---------------------------------------------------
-
-The first feature we will add is to provide our executable and project with a
-version number. While we could do this exclusively in the source code, using
-``CMakeLists.txt`` provides more flexibility.
-
-First, modify the ``CMakeLists.txt`` file to use the :command:`project` command
-to set the project name and version number.
-
-.. literalinclude:: Step2/CMakeLists.txt
- :language: cmake
- :end-before: # specify the C++ standard
-
-Then, configure a header file to pass the version number to the source
-code:
-
-.. literalinclude:: Step2/CMakeLists.txt
- :language: cmake
- :start-after: # to the source code
- :end-before: # add the executable
-
-Since the configured file will be written into the binary tree, we
-must add that directory to the list of paths to search for include
-files. Add the following lines to the end of the ``CMakeLists.txt`` file:
-
-.. literalinclude:: Step2/CMakeLists.txt
- :language: cmake
- :start-after: # so that we will find TutorialConfig.h
-
-Using your favorite editor, create ``TutorialConfig.h.in`` in the source
-directory with the following contents:
-
-.. literalinclude:: Step2/TutorialConfig.h.in
- :language: cmake
-
-When CMake configures this header file the values for
-``@Tutorial_VERSION_MAJOR@`` and ``@Tutorial_VERSION_MINOR@`` will be
-replaced.
-
-Next modify ``tutorial.cxx`` to include the configured header file,
-``TutorialConfig.h``.
-
-Finally, let's print out the executable name and version number by updating
-``tutorial.cxx`` as follows:
-
-.. literalinclude:: Step2/tutorial.cxx
- :language: c++
- :start-after: {
- :end-before: // convert input to double
-
-Specify the C++ Standard
--------------------------
-
-Next let's add some C++11 features to our project by replacing ``atof`` with
-``std::stod`` in ``tutorial.cxx``. At the same time, remove
-``#include <cstdlib>``.
-
-.. literalinclude:: Step2/tutorial.cxx
- :language: c++
- :start-after: // convert input to double
- :end-before: // calculate square root
-
-We will need to explicitly state in the CMake code that it should use the
-correct flags. The easiest way to enable support for a specific C++ standard
-in CMake is by using the :variable:`CMAKE_CXX_STANDARD` variable. For this
-tutorial, set the :variable:`CMAKE_CXX_STANDARD` variable in the
-``CMakeLists.txt`` file to 11 and :variable:`CMAKE_CXX_STANDARD_REQUIRED` to
-True. Make sure to add the ``CMAKE_CXX_STANDARD`` declarations above the call
-to ``add_executable``.
-
-.. literalinclude:: Step2/CMakeLists.txt
- :language: cmake
- :end-before: # configure a header file to pass some of the CMake settings
-
-Build and Test
---------------
-
-Run the :manual:`cmake <cmake(1)>` executable or the
-:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
-with your chosen build tool.
-
-For example, from the command line we could navigate to the
-``Help/guide/tutorial`` directory of the CMake source code tree and create a
-build directory:
-
-.. code-block:: console
-
- mkdir Step1_build
-
-Next, navigate to the build directory and run CMake to configure the project
-and generate a native build system:
-
-.. code-block:: console
-
- cd Step1_build
- cmake ../Step1
-
-Then call that build system to actually compile/link the project:
-
-.. code-block:: console
-
- cmake --build .
-
-Finally, try to use the newly built ``Tutorial`` with these commands:
-
-.. code-block:: console
-
- Tutorial 4294967296
- Tutorial 10
- Tutorial
-
-Adding a Library (Step 2)
-=========================
-
-Now we will add a library to our project. This library will contain our own
-implementation for computing the square root of a number. The executable can
-then use this library instead of the standard square root function provided by
-the compiler.
-
-For this tutorial we will put the library into a subdirectory
-called ``MathFunctions``. This directory already contains a header file,
-``MathFunctions.h``, and a source file ``mysqrt.cxx``. The source file has one
-function called ``mysqrt`` that provides similar functionality to the
-compiler's ``sqrt`` function.
-
-Add the following one line ``CMakeLists.txt`` file to the ``MathFunctions``
-directory:
-
-.. literalinclude:: Step3/MathFunctions/CMakeLists.txt
- :language: cmake
-
-To make use of the new library we will add an :command:`add_subdirectory`
-call in the top-level ``CMakeLists.txt`` file so that the library will get
-built. We add the new library to the executable, and add ``MathFunctions`` as
-an include directory so that the ``mysqrt.h`` header file can be found. The
-last few lines of the top-level ``CMakeLists.txt`` file should now look like:
-
-.. code-block:: cmake
-
- # add the MathFunctions library
- add_subdirectory(MathFunctions)
-
- # add the executable
- add_executable(Tutorial tutorial.cxx)
-
- target_link_libraries(Tutorial PUBLIC MathFunctions)
-
- # add the binary tree to the search path for include files
- # so that we will find TutorialConfig.h
- target_include_directories(Tutorial PUBLIC
- "${PROJECT_BINARY_DIR}"
- "${PROJECT_SOURCE_DIR}/MathFunctions"
- )
-
-Now let us make the MathFunctions library optional. While for the tutorial
-there really isn't any need to do so, for larger projects this is a common
-occurrence. The first step is to add an option to the top-level
-``CMakeLists.txt`` file.
-
-.. literalinclude:: Step3/CMakeLists.txt
- :language: cmake
- :start-after: # should we use our own math functions
- :end-before: # add the MathFunctions library
-
-This option will be displayed in the :manual:`cmake-gui <cmake-gui(1)>` and
-:manual:`ccmake <ccmake(1)>`
-with a default value of ON that can be changed by the user. This setting will
-be stored in the cache so that the user does not need to set the value each
-time they run CMake on a build directory.
-
-The next change is to make building and linking the MathFunctions library
-conditional. To do this we change the end of the top-level ``CMakeLists.txt``
-file to look like the following:
-
-.. literalinclude:: Step3/CMakeLists.txt
- :language: cmake
- :start-after: # add the MathFunctions library
-
-Note the use of the variable ``EXTRA_LIBS`` to collect up any optional
-libraries to later be linked into the executable. The variable
-``EXTRA_INCLUDES`` is used similarly for optional header files. This is a
-classic approach when dealing with many optional components, we will cover
-the modern approach in the next step.
-
-The corresponding changes to the source code are fairly straightforward.
-First, in ``tutorial.cxx``, include the ``MathFunctions.h`` header if we
-need it:
-
-.. literalinclude:: Step3/tutorial.cxx
- :language: c++
- :start-after: // should we include the MathFunctions header
- :end-before: int main
-
-Then, in the same file, make ``USE_MYMATH`` control which square root
-function is used:
-
-.. literalinclude:: Step3/tutorial.cxx
- :language: c++
- :start-after: // which square root function should we use?
- :end-before: std::cout << "The square root of
-
-Since the source code now requires ``USE_MYMATH`` we can add it to
-``TutorialConfig.h.in`` with the following line:
-
-.. literalinclude:: Step3/TutorialConfig.h.in
- :language: c
- :lines: 4
-
-**Exercise**: Why is it important that we configure ``TutorialConfig.h.in``
-after the option for ``USE_MYMATH``? What would happen if we inverted the two?
-
-Run the :manual:`cmake <cmake(1)>` executable or the
-:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
-with your chosen build tool. Then run the built Tutorial executable.
-
-Now let's update the value of ``USE_MYMATH``. The easiest way is to use the
-:manual:`cmake-gui <cmake-gui(1)>` or :manual:`ccmake <ccmake(1)>` if you're
-in the terminal. Or, alternatively, if you want to change the option from the
-command-line, try:
-
-.. code-block:: console
-
- cmake ../Step2 -DUSE_MYMATH=OFF
-
-Rebuild and run the tutorial again.
-
-Which function gives better results, sqrt or mysqrt?
-
-Adding Usage Requirements for Library (Step 3)
-==============================================
-
-Usage requirements allow for far better control over a library or executable's
-link and include line while also giving more control over the transitive
-property of targets inside CMake. The primary commands that leverage usage
-requirements are:
-
- - :command:`target_compile_definitions`
- - :command:`target_compile_options`
- - :command:`target_include_directories`
- - :command:`target_link_libraries`
-
-Let's refactor our code from `Adding a Library (Step 2)`_ to use the modern
-CMake approach of usage requirements. We first state that anybody linking to
-MathFunctions needs to include the current source directory, while
-MathFunctions itself doesn't. So this can become an ``INTERFACE`` usage
-requirement.
-
-Remember ``INTERFACE`` means things that consumers require but the producer
-doesn't. Add the following lines to the end of
-``MathFunctions/CMakeLists.txt``:
-
-.. literalinclude:: Step4/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # to find MathFunctions.h
-
-Now that we've specified usage requirements for MathFunctions we can safely
-remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level
-``CMakeLists.txt``, here:
-
-.. literalinclude:: Step4/CMakeLists.txt
- :language: cmake
- :start-after: # add the MathFunctions library
- :end-before: # add the executable
-
-And here:
-
-.. literalinclude:: Step4/CMakeLists.txt
- :language: cmake
- :start-after: # so that we will find TutorialConfig.h
-
-Once this is done, run the :manual:`cmake <cmake(1)>` executable or the
-:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
-with your chosen build tool or by using ``cmake --build .`` from the build
-directory.
-
-Installing and Testing (Step 4)
-===============================
-
-Now we can start adding install rules and testing support to our project.
-
-Install Rules
--------------
-
-The install rules are fairly simple: for MathFunctions we want to install the
-library and header file and for the application we want to install the
-executable and configured header.
-
-So to the end of ``MathFunctions/CMakeLists.txt`` we add:
-
-.. literalinclude:: Step5/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # install rules
-
-And to the end of the top-level ``CMakeLists.txt`` we add:
-
-.. literalinclude:: Step5/CMakeLists.txt
- :language: cmake
- :start-after: # add the install targets
- :end-before: # enable testing
-
-That is all that is needed to create a basic local install of the tutorial.
-
-Now run the :manual:`cmake <cmake(1)>` executable or the
-:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
-with your chosen build tool.
-
-Then run the install step by using the ``install`` option of the
-:manual:`cmake <cmake(1)>` command (introduced in 3.15, older versions of
-CMake must use ``make install``) from the command line. For
-multi-configuration tools, don't forget to use the ``--config`` argument to
-specify the configuration. If using an IDE, simply build the ``INSTALL``
-target. This step will install the appropriate header files, libraries, and
-executables. For example:
-
-.. code-block:: console
-
- cmake --install .
-
-The CMake variable :variable:`CMAKE_INSTALL_PREFIX` is used to determine the
-root of where the files will be installed. If using the ``cmake --install``
-command, the installation prefix can be overridden via the ``--prefix``
-argument. For example:
-
-.. code-block:: console
-
- cmake --install . --prefix "/home/myuser/installdir"
-
-Navigate to the install directory and verify that the installed Tutorial runs.
-
-Testing Support
----------------
-
-Next let's test our application. At the end of the top-level ``CMakeLists.txt``
-file we can enable testing and then add a number of basic tests to verify that
-the application is working correctly.
-
-.. literalinclude:: Step5/CMakeLists.txt
- :language: cmake
- :start-after: # enable testing
-
-The first test simply verifies that the application runs, does not segfault or
-otherwise crash, and has a zero return value. This is the basic form of a
-CTest test.
-
-The next test makes use of the :prop_test:`PASS_REGULAR_EXPRESSION` test
-property to verify that the output of the test contains certain strings. In
-this case, verifying that the usage message is printed when an incorrect number
-of arguments are provided.
-
-Lastly, we have a function called ``do_test`` that runs the application and
-verifies that the computed square root is correct for given input. For each
-invocation of ``do_test``, another test is added to the project with a name,
-input, and expected results based on the passed arguments.
-
-Rebuild the application and then cd to the binary directory and run the
-:manual:`ctest <ctest(1)>` executable: ``ctest -N`` and ``ctest -VV``. For
-multi-config generators (e.g. Visual Studio), the configuration type must be
-specified. To run tests in Debug mode, for example, use ``ctest -C Debug -VV``
-from the build directory (not the Debug subdirectory!). Alternatively, build
-the ``RUN_TESTS`` target from the IDE.
-
-Adding System Introspection (Step 5)
-====================================
-
-Let us consider adding some code to our project that depends on features the
-target platform may not have. For this example, we will add some code that
-depends on whether or not the target platform has the ``log`` and ``exp``
-functions. Of course almost every platform has these functions but for this
-tutorial assume that they are not common.
-
-If the platform has ``log`` and ``exp`` then we will use them to compute the
-square root in the ``mysqrt`` function. We first test for the availability of
-these functions using the :module:`CheckSymbolExists` module in
-``MathFunctions/CMakeLists.txt``. On some platforms, we will need to link to
-the m library. If ``log`` and ``exp`` are not initially found, require the m
-library and try again.
-
-.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # does this system provide the log and exp functions?
- :end-before: # add compile definitions
-
-If available, use :command:`target_compile_definitions` to specify
-``HAVE_LOG`` and ``HAVE_EXP`` as ``PRIVATE`` compile definitions.
-
-.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # add compile definitions
- :end-before: # install rules
-
-If ``log`` and ``exp`` are available on the system, then we will use them to
-compute the square root in the ``mysqrt`` function. Add the following code to
-the ``mysqrt`` function in ``MathFunctions/mysqrt.cxx`` (don't forget the
-``#endif`` before returning the result!):
-
-.. literalinclude:: Step6/MathFunctions/mysqrt.cxx
- :language: c++
- :start-after: // if we have both log and exp then use them
- :end-before: // do ten iterations
-
-We will also need to modify ``mysqrt.cxx`` to include ``cmath``.
-
-.. literalinclude:: Step6/MathFunctions/mysqrt.cxx
- :language: c++
- :end-before: #include <iostream>
-
-Run the :manual:`cmake <cmake(1)>` executable or the
-:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
-with your chosen build tool and run the Tutorial executable.
-
-Which function gives better results now, sqrt or mysqrt?
-
-Adding a Custom Command and Generated File (Step 6)
-===================================================
-
-Suppose, for the purpose of this tutorial, we decide that we never want to use
-the platform ``log`` and ``exp`` functions and instead would like to
-generate a table of precomputed values to use in the ``mysqrt`` function.
-In this section, we will create the table as part of the build process,
-and then compile that table into our application.
-
-First, let's remove the check for the ``log`` and ``exp`` functions in
-``MathFunctions/CMakeLists.txt``. Then remove the check for ``HAVE_LOG`` and
-``HAVE_EXP`` from ``mysqrt.cxx``. At the same time, we can remove
-:code:`#include <cmath>`.
-
-In the ``MathFunctions`` subdirectory, a new source file named
-``MakeTable.cxx`` has been provided to generate the table.
-
-After reviewing the file, we can see that the table is produced as valid C++
-code and that the output filename is passed in as an argument.
-
-The next step is to add the appropriate commands to the
-``MathFunctions/CMakeLists.txt`` file to build the MakeTable executable and
-then run it as part of the build process. A few commands are needed to
-accomplish this.
-
-First, at the top of ``MathFunctions/CMakeLists.txt``, the executable for
-``MakeTable`` is added as any other executable would be added.
-
-.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # first we add the executable that generates the table
- :end-before: # add the command to generate the source code
-
-Then we add a custom command that specifies how to produce ``Table.h``
-by running MakeTable.
-
-.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # add the command to generate the source code
- :end-before: # add the main library
-
-Next we have to let CMake know that ``mysqrt.cxx`` depends on the generated
-file ``Table.h``. This is done by adding the generated ``Table.h`` to the list
-of sources for the library MathFunctions.
-
-.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # add the main library
- :end-before: # state that anybody linking
-
-We also have to add the current binary directory to the list of include
-directories so that ``Table.h`` can be found and included by ``mysqrt.cxx``.
-
-.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # state that we depend on our bin
- :end-before: # install rules
-
-Now let's use the generated table. First, modify ``mysqrt.cxx`` to include
-``Table.h``. Next, we can rewrite the mysqrt function to use the table:
-
-.. literalinclude:: Step7/MathFunctions/mysqrt.cxx
- :language: c++
- :start-after: // a hack square root calculation using simple operations
-
-Run the :manual:`cmake <cmake(1)>` executable or the
-:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it
-with your chosen build tool.
-
-When this project is built it will first build the ``MakeTable`` executable.
-It will then run ``MakeTable`` to produce ``Table.h``. Finally, it will
-compile ``mysqrt.cxx`` which includes ``Table.h`` to produce the MathFunctions
-library.
-
-Run the Tutorial executable and verify that it is using the table.
-
-Building an Installer (Step 7)
-==============================
-
-Next suppose that we want to distribute our project to other people so that
-they can use it. We want to provide both binary and source distributions on a
-variety of platforms. This is a little different from the install we did
-previously in `Installing and Testing (Step 4)`_ , where we were
-installing the binaries that we had built from the source code. In this
-example we will be building installation packages that support binary
-installations and package management features. To accomplish this we will use
-CPack to create platform specific installers. Specifically we need to add a
-few lines to the bottom of our top-level ``CMakeLists.txt`` file.
-
-.. literalinclude:: Step8/CMakeLists.txt
- :language: cmake
- :start-after: # setup installer
-
-That is all there is to it. We start by including
-:module:`InstallRequiredSystemLibraries`. This module will include any runtime
-libraries that are needed by the project for the current platform. Next we set
-some CPack variables to where we have stored the license and version
-information for this project. The version information was set earlier in this
-tutorial and the ``license.txt`` has been included in the top-level source
-directory for this step.
-
-Finally we include the :module:`CPack module <CPack>` which will use these
-variables and some other properties of the current system to setup an
-installer.
-
-The next step is to build the project in the usual manner and then run the
-:manual:`cpack <cpack(1)>` executable. To build a binary distribution, from the
-binary directory run:
-
-.. code-block:: console
-
- cpack
-
-To specify the generator, use the ``-G`` option. For multi-config builds, use
-``-C`` to specify the configuration. For example:
-
-.. code-block:: console
-
- cpack -G ZIP -C Debug
-
-To create a source distribution you would type:
-
-.. code-block:: console
-
- cpack --config CPackSourceConfig.cmake
-
-Alternatively, run ``make package`` or right click the ``Package`` target and
-``Build Project`` from an IDE.
-
-Run the installer found in the binary directory. Then run the installed
-executable and verify that it works.
-
-Adding Support for a Dashboard (Step 8)
-=======================================
-
-Adding support for submitting our test results to a dashboard is simple. We
-already defined a number of tests for our project in `Testing Support`_. Now we
-just have to run those tests and submit them to a dashboard. To include support
-for dashboards we include the :module:`CTest` module in our top-level
-``CMakeLists.txt``.
-
-Replace:
-
-.. code-block:: cmake
-
- # enable testing
- enable_testing()
-
-With:
-
-.. code-block:: cmake
-
- # enable dashboard scripting
- include(CTest)
-
-The :module:`CTest` module will automatically call ``enable_testing()``, so we
-can remove it from our CMake files.
-
-We will also need to create a ``CTestConfig.cmake`` file in the top-level
-directory where we can specify the name of the project and where to submit the
-dashboard.
-
-.. literalinclude:: Step9/CTestConfig.cmake
- :language: cmake
-
-The :manual:`ctest <ctest(1)>` executable will read in this file when it runs.
-To create a simple dashboard you can run the :manual:`cmake <cmake(1)>`
-executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project,
-but do not build it yet. Instead, change directory to the binary tree, and then
-run:
-
- ctest [-VV] -D Experimental
-
-Remember, for multi-config generators (e.g. Visual Studio), the configuration
-type must be specified::
-
- ctest [-VV] -C Debug -D Experimental
-
-Or, from an IDE, build the ``Experimental`` target.
-
-The :manual:`ctest <ctest(1)>` executable will build and test the project and
-submit the results to Kitware's public dashboard:
-https://my.cdash.org/index.php?project=CMakeTutorial.
-
-Mixing Static and Shared (Step 9)
-=================================
-
-In this section we will show how the :variable:`BUILD_SHARED_LIBS` variable can
-be used to control the default behavior of :command:`add_library`,
-and allow control over how libraries without an explicit type (``STATIC``,
-``SHARED``, ``MODULE`` or ``OBJECT``) are built.
-
-To accomplish this we need to add :variable:`BUILD_SHARED_LIBS` to the
-top-level ``CMakeLists.txt``. We use the :command:`option` command as it allows
-users to optionally select if the value should be ON or OFF.
-
-Next we are going to refactor MathFunctions to become a real library that
-encapsulates using ``mysqrt`` or ``sqrt``, instead of requiring the calling
-code to do this logic. This will also mean that ``USE_MYMATH`` will not control
-building MathFunctions, but instead will control the behavior of this library.
-
-The first step is to update the starting section of the top-level
-``CMakeLists.txt`` to look like:
-
-.. literalinclude:: Step10/CMakeLists.txt
- :language: cmake
- :end-before: # add the binary tree
-
-Now that we have made MathFunctions always be used, we will need to update
-the logic of that library. So, in ``MathFunctions/CMakeLists.txt`` we need to
-create a SqrtLibrary that will conditionally be built and installed when
-``USE_MYMATH`` is enabled. Now, since this is a tutorial, we are going to
-explicitly require that SqrtLibrary is built statically.
-
-The end result is that ``MathFunctions/CMakeLists.txt`` should look like:
-
-.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
- :language: cmake
- :lines: 1-36,42-
-
-Next, update ``MathFunctions/mysqrt.cxx`` to use the ``mathfunctions`` and
-``detail`` namespaces:
-
-.. literalinclude:: Step10/MathFunctions/mysqrt.cxx
- :language: c++
-
-We also need to make some changes in ``tutorial.cxx``, so that it no longer
-uses ``USE_MYMATH``:
-
-#. Always include ``MathFunctions.h``
-#. Always use ``mathfunctions::sqrt``
-#. Don't include cmath
-
-Finally, update ``MathFunctions/MathFunctions.h`` to use dll export defines:
-
-.. literalinclude:: Step10/MathFunctions/MathFunctions.h
- :language: c++
-
-At this point, if you build everything, you may notice that linking fails
-as we are combining a static library without position independent code with a
-library that has position independent code. The solution to this is to
-explicitly set the :prop_tgt:`POSITION_INDEPENDENT_CODE` target property of
-SqrtLibrary to be True no matter the build type.
-
-.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
- :language: cmake
- :lines: 37-42
-
-**Exercise**: We modified ``MathFunctions.h`` to use dll export defines.
-Using CMake documentation can you find a helper module to simplify this?
-
-
-Adding Generator Expressions (Step 10)
-======================================
-
-:manual:`Generator expressions <cmake-generator-expressions(7)>` are evaluated
-during build system generation to produce information specific to each build
-configuration.
-
-:manual:`Generator expressions <cmake-generator-expressions(7)>` are allowed in
-the context of many target properties, such as :prop_tgt:`LINK_LIBRARIES`,
-:prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_DEFINITIONS` and others.
-They may also be used when using commands to populate those properties, such as
-:command:`target_link_libraries`, :command:`target_include_directories`,
-:command:`target_compile_definitions` and others.
-
-:manual:`Generator expressions <cmake-generator-expressions(7)>` may be used
-to enable conditional linking, conditional definitions used when compiling,
-conditional include directories and more. The conditions may be based on the
-build configuration, target properties, platform information or any other
-queryable information.
-
-There are different types of
-:manual:`generator expressions <cmake-generator-expressions(7)>` including
-Logical, Informational, and Output expressions.
-
-Logical expressions are used to create conditional output. The basic
-expressions are the 0 and 1 expressions. A ``$<0:...>`` results in the empty
-string, and ``<1:...>`` results in the content of "...". They can also be
-nested.
-
-A common usage of
-:manual:`generator expressions <cmake-generator-expressions(7)>` is to
-conditionally add compiler flags, such as those for language levels or
-warnings. A nice pattern is to associate this information to an ``INTERFACE``
-target allowing this information to propagate. Let's start by constructing an
-``INTERFACE`` target and specifying the required C++ standard level of ``11``
-instead of using :variable:`CMAKE_CXX_STANDARD`.
-
-So the following code:
-
-.. literalinclude:: Step10/CMakeLists.txt
- :language: cmake
- :start-after: project(Tutorial VERSION 1.0)
- :end-before: # control where the static and shared libraries are built so that on windows
-
-Would be replaced with:
-
-.. literalinclude:: Step11/CMakeLists.txt
- :language: cmake
- :start-after: project(Tutorial VERSION 1.0)
- :end-before: # add compiler warning flags just when building this project via
-
-
-Next we add the desired compiler warning flags that we want for our project. As
-warning flags vary based on the compiler we use the ``COMPILE_LANG_AND_ID``
-generator expression to control which flags to apply given a language and a set
-of compiler ids as seen below:
-
-.. literalinclude:: Step11/CMakeLists.txt
- :language: cmake
- :start-after: # the BUILD_INTERFACE genex
- :end-before: # control where the static and shared libraries are built so that on windows
-
-Looking at this we see that the warning flags are encapsulated inside a
-``BUILD_INTERFACE`` condition. This is done so that consumers of our installed
-project will not inherit our warning flags.
-
-
-**Exercise**: Modify ``MathFunctions/CMakeLists.txt`` so that all targets have
-a :command:`target_link_libraries` call to ``tutorial_compiler_flags``.
-
-
-Adding Export Configuration (Step 11)
-=====================================
-
-During `Installing and Testing (Step 4)`_ of the tutorial we added the ability
-for CMake to install the library and headers of the project. During
-`Building an Installer (Step 7)`_ we added the ability to package up this
-information so it could be distributed to other people.
-
-The next step is to add the necessary information so that other CMake projects
-can use our project, be it from a build directory, a local install or when
-packaged.
-
-The first step is to update our :command:`install(TARGETS)` commands to not
-only specify a ``DESTINATION`` but also an ``EXPORT``. The ``EXPORT`` keyword
-generates and installs a CMake file containing code to import all targets
-listed in the install command from the installation tree. So let's go ahead and
-explicitly ``EXPORT`` the MathFunctions library by updating the ``install``
-command in ``MathFunctions/CMakeLists.txt`` to look like:
-
-.. literalinclude:: Complete/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # install rules
-
-Now that we have MathFunctions being exported, we also need to explicitly
-install the generated ``MathFunctionsTargets.cmake`` file. This is done by
-adding the following to the bottom of the top-level ``CMakeLists.txt``:
-
-.. literalinclude:: Complete/CMakeLists.txt
- :language: cmake
- :start-after: # install the configuration targets
- :end-before: include(CMakePackageConfigHelpers)
-
-At this point you should try and run CMake. If everything is setup properly
-you will see that CMake will generate an error that looks like:
-
-.. code-block:: console
-
- Target "MathFunctions" INTERFACE_INCLUDE_DIRECTORIES property contains
- path:
-
- "/Users/robert/Documents/CMakeClass/Tutorial/Step11/MathFunctions"
-
- which is prefixed in the source directory.
-
-What CMake is trying to say is that during generating the export information
-it will export a path that is intrinsically tied to the current machine and
-will not be valid on other machines. The solution to this is to update the
-MathFunctions :command:`target_include_directories` to understand that it needs
-different ``INTERFACE`` locations when being used from within the build
-directory and from an install / package. This means converting the
-:command:`target_include_directories` call for MathFunctions to look like:
-
-.. literalinclude:: Step12/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # to find MathFunctions.h, while we don't.
- :end-before: # should we use our own math functions
-
-Once this has been updated, we can re-run CMake and verify that it doesn't
-warn anymore.
-
-At this point, we have CMake properly packaging the target information that is
-required but we will still need to generate a ``MathFunctionsConfig.cmake`` so
-that the CMake :command:`find_package` command can find our project. So let's go
-ahead and add a new file to the top-level of the project called
-``Config.cmake.in`` with the following contents:
-
-.. literalinclude:: Step12/Config.cmake.in
-
-Then, to properly configure and install that file, add the following to the
-bottom of the top-level ``CMakeLists.txt``:
-
-.. literalinclude:: Step12/CMakeLists.txt
- :language: cmake
- :start-after: # install the configuration targets
- :end-before: # generate the export
-
-At this point, we have generated a relocatable CMake Configuration for our
-project that can be used after the project has been installed or packaged. If
-we want our project to also be used from a build directory we only have to add
-the following to the bottom of the top level ``CMakeLists.txt``:
-
-.. literalinclude:: Step12/CMakeLists.txt
- :language: cmake
- :start-after: # needs to be after the install(TARGETS ) command
-
-With this export call we now generate a ``Targets.cmake``, allowing the
-configured ``MathFunctionsConfig.cmake`` in the build directory to be used by
-other projects, without needing it to be installed.
-
-Packaging Debug and Release (Step 12)
-=====================================
-
-**Note:** This example is valid for single-configuration generators and will
-not work for multi-configuration generators (e.g. Visual Studio).
-
-By default, CMake's model is that a build directory only contains a single
-configuration, be it Debug, Release, MinSizeRel, or RelWithDebInfo. It is
-possible, however, to setup CPack to bundle multiple build directories and
-construct a package that contains multiple configurations of the same project.
-
-First, we want to ensure that the debug and release builds use different names
-for the executables and libraries that will be installed. Let's use `d` as the
-postfix for the debug executable and libraries.
-
-Set :variable:`CMAKE_DEBUG_POSTFIX` near the beginning of the top-level
-``CMakeLists.txt`` file:
-
-.. literalinclude:: Complete/CMakeLists.txt
- :language: cmake
- :start-after: project(Tutorial VERSION 1.0)
- :end-before: target_compile_features(tutorial_compiler_flags
-
-And the :prop_tgt:`DEBUG_POSTFIX` property on the tutorial executable:
-
-.. literalinclude:: Complete/CMakeLists.txt
- :language: cmake
- :start-after: # add the executable
- :end-before: # add the binary tree to the search path for include files
-
-Let's also add version numbering to the MathFunctions library. In
-``MathFunctions/CMakeLists.txt``, set the :prop_tgt:`VERSION` and
-:prop_tgt:`SOVERSION` properties:
-
-.. literalinclude:: Complete/MathFunctions/CMakeLists.txt
- :language: cmake
- :start-after: # setup the version numbering
- :end-before: # install rules
-
-From the ``Step12`` directory, create ``debug`` and ``release``
-subbdirectories. The layout will look like:
-
-.. code-block:: none
-
- - Step12
- - debug
- - release
-
-Now we need to setup debug and release builds. We can use
-:variable:`CMAKE_BUILD_TYPE` to set the configuration type:
-
-.. code-block:: console
-
- cd debug
- cmake -DCMAKE_BUILD_TYPE=Debug ..
- cmake --build .
- cd ../release
- cmake -DCMAKE_BUILD_TYPE=Release ..
- cmake --build .
-
-Now that both the debug and release builds are complete, we can use a custom
-configuration file to package both builds into a single release. In the
-``Step12`` directory, create a file called ``MultiCPackConfig.cmake``. In this
-file, first include the default configuration file that was created by the
-:manual:`cmake <cmake(1)>` executable.
-
-Next, use the ``CPACK_INSTALL_CMAKE_PROJECTS`` variable to specify which
-projects to install. In this case, we want to install both debug and release.
-
-.. literalinclude:: Complete/MultiCPackConfig.cmake
- :language: cmake
-
-From the ``Step12`` directory, run :manual:`cpack <cpack(1)>` specifying our
-custom configuration file with the ``config`` option:
-
-.. code-block:: console
-
- cpack --config MultiCPackConfig.cmake
+work together in an example project can be very helpful.
+
+Steps
+=====
+
+The tutorial documentation and source code for examples can be found in
+the ``Help/guide/tutorial`` directory of the CMake source code tree.
+Each step has its own subdirectory containing code that may be used as a
+starting point. The tutorial examples are progressive so that each step
+provides the complete solution for the previous step.
+
+.. toctree::
+ :maxdepth: 2
+
+ A Basic Starting Point
+ Adding a Library
+ Adding Usage Requirements for a Library
+ Installing and Testing
+ Adding System Introspection
+ Adding a Custom Command and Generated File
+ Packaging an Installer
+ Adding Support for a Testing Dashboard
+ Selecting Static or Shared Libraries
+ Adding Generator Expressions
+ Adding Export Configuration
+ Packaging Debug and Release
+
+..
+ Whenever a step above is renamed or removed, leave forwarding text in
+ its original document file, and list it below to preserve old links
+ to cmake.org/cmake/help/latest/ URLs.
+
+.. toctree::
+ :maxdepth: 1
+ :hidden:
diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt
index 0947e41cb..8e23b7711 100644
--- a/Help/manual/OPTIONS_BUILD.txt
+++ b/Help/manual/OPTIONS_BUILD.txt
@@ -76,6 +76,14 @@
native build system to choose a compiler or SDK. See the
:variable:`CMAKE_GENERATOR_PLATFORM` variable for details.
+``--toolchain <path-to-file>``
+ Specify the cross compiling toolchain file, equivalent to setting
+ :variable:`CMAKE_TOOLCHAIN_FILE` variable.
+
+``--install-prefix <directory>``
+ Specify the installation directory, used by the
+ :variable:`CMAKE_INSTALL_PREFIX` variable. Must be an absolute path.
+
``-Wno-dev``
Suppress developer warnings.
diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst
index 2c2b04cbe..2b0de1101 100644
--- a/Help/manual/cmake-compile-features.7.rst
+++ b/Help/manual/cmake-compile-features.7.rst
@@ -261,6 +261,7 @@ following :variable:`compiler ids <CMAKE_<LANG>_COMPILER_ID>` as of the
versions specified for each:
* ``Cray``: Cray Compiler Environment version 8.1+.
+* ``Fujitsu``: Fujitsu HPC compiler 4.0+.
* ``PGI``: PGI version 12.10+.
* ``NVHPC``: NVIDIA HPC compilers version 11.0+.
* ``TI``: Texas Instruments compiler.
diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst
index af9a8ab0d..fe146de0f 100644
--- a/Help/manual/cmake-developer.7.rst
+++ b/Help/manual/cmake-developer.7.rst
@@ -350,6 +350,24 @@ look.
PATHS ${PC_Foo_LIBRARY_DIRS}
)
+Alternatively, if the library is available with multiple configurations, you can
+use :module:`SelectLibraryConfigurations` to automatically set the
+``Foo_LIBRARY`` variable instead:
+
+.. code-block:: cmake
+
+ find_library(Foo_LIBRARY_RELEASE
+ NAMES foo
+ PATHS ${PC_Foo_LIBRARY_DIRS}/Release
+ )
+ find_library(Foo_LIBRARY_DEBUG
+ NAMES foo
+ PATHS ${PC_Foo_LIBRARY_DIRS}/Debug
+ )
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(Foo)
+
If you have a good way of getting the version (from a header file, for
example), you can use that information to set ``Foo_VERSION`` (although
note that find modules have traditionally used ``Foo_VERSION_STRING``,
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
index bc1fa1d85..fa38588a8 100644
--- a/Help/manual/cmake-env-variables.7.rst
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -37,9 +37,11 @@ Environment Variables that Control the Build
/envvar/CMAKE_GENERATOR_PLATFORM
/envvar/CMAKE_GENERATOR_TOOLSET
/envvar/CMAKE_LANG_COMPILER_LAUNCHER
+ /envvar/CMAKE_LANG_LINKER_LAUNCHER
/envvar/CMAKE_MSVCIDE_RUN_PATH
/envvar/CMAKE_NO_VERBOSE
/envvar/CMAKE_OSX_ARCHITECTURES
+ /envvar/CMAKE_TOOLCHAIN_FILE
/envvar/DESTDIR
/envvar/LDFLAGS
/envvar/MACOSX_DEPLOYMENT_TARGET
@@ -65,6 +67,8 @@ Environment Variables for Languages
/envvar/CXXFLAGS
/envvar/FC
/envvar/FFLAGS
+ /envvar/HIPCXX
+ /envvar/HIPFLAGS
/envvar/ISPC
/envvar/ISPCFLAGS
/envvar/OBJC
diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst
index 89739b7d5..5e22ea905 100644
--- a/Help/manual/cmake-file-api.7.rst
+++ b/Help/manual/cmake-file-api.7.rst
@@ -443,7 +443,8 @@ Version 1 does not exist to avoid confusion with that from
"hasInstallRule": true,
"minimumCMakeVersion": {
"string": "3.14"
- }
+ },
+ "jsonFile": "<file>"
},
{
"source": "sub",
@@ -453,7 +454,8 @@ Version 1 does not exist to avoid confusion with that from
"targetIndexes": [ 1 ],
"minimumCMakeVersion": {
"string": "3.14"
- }
+ },
+ "jsonFile": "<file>"
}
],
"projects": [
@@ -569,6 +571,13 @@ The members specific to ``codemodel`` objects are:
:command:`install` rules, i.e. whether a ``make install``
or equivalent rule is available.
+ ``jsonFile``
+ A JSON string specifying a path relative to the codemodel file
+ to another JSON file containing a
+ `"codemodel" version 2 "directory" object`_.
+
+ This field was added in codemodel version 2.3.
+
``projects``
A JSON array of entries corresponding to the top-level project
and sub-projects defined in the build system. Each (sub-)project
@@ -633,6 +642,216 @@ The members specific to ``codemodel`` objects are:
to another JSON file containing a
`"codemodel" version 2 "target" object`_.
+"codemodel" version 2 "directory" object
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A codemodel "directory" object is referenced by a `"codemodel" version 2`_
+object's ``directories`` array. Each "directory" object is a JSON object
+with members:
+
+``paths``
+ A JSON object containing members:
+
+ ``source``
+ A string specifying the path to the source directory, represented
+ with forward slashes. If the directory is inside the top-level
+ source directory then the path is specified relative to that
+ directory (with ``.`` for the top-level source directory itself).
+ Otherwise the path is absolute.
+
+ ``build``
+ A string specifying the path to the build directory, represented
+ with forward slashes. If the directory is inside the top-level
+ build directory then the path is specified relative to that
+ directory (with ``.`` for the top-level build directory itself).
+ Otherwise the path is absolute.
+
+``installers``
+ A JSON array of entries corresponding to :command:`install` rules.
+ Each entry is a JSON object containing members:
+
+ ``component``
+ A string specifying the component selected by the corresponding
+ :command:`install` command invocation.
+
+ ``destination``
+ Optional member that is present for specific ``type`` values below.
+ The value is a string specifying the install destination path.
+ The path may be absolute or relative to the install prefix.
+
+ ``paths``
+ Optional member that is present for specific ``type`` values below.
+ The value is a JSON array of entries corresponding to the paths
+ (files or directories) to be installed. Each entry is one of:
+
+ * A string specifying the path from which a file or directory
+ is to be installed. The portion of the path not preceded by
+ a ``/`` also specifies the path (name) to which the file
+ or directory is to be installed under the destination.
+
+ * A JSON object with members:
+
+ ``from``
+ A string specifying the path from which a file or directory
+ is to be installed.
+
+ ``to``
+ A string specifying the path to which the file or directory
+ is to be installed under the destination.
+
+ In both cases the paths are represented with forward slashes. If
+ the "from" path is inside the top-level directory documented by the
+ corresponding ``type`` value, then the path is specified relative
+ to that directory. Otherwise the path is absolute.
+
+ ``type``
+ A string specifying the type of installation rule. The value is one
+ of the following, with some variants providing additional members:
+
+ ``file``
+ An :command:`install(FILES)` or :command:`install(PROGRAMS)` call.
+ The ``destination`` and ``paths`` members are populated, with paths
+ under the top-level *source* directory expressed relative to it.
+ The ``isOptional`` member may exist.
+ This type has no additional members.
+
+ ``directory``
+ An :command:`install(DIRECTORY)` call.
+ The ``destination`` and ``paths`` members are populated, with paths
+ under the top-level *source* directory expressed relative to it.
+ The ``isOptional`` member may exist.
+ This type has no additional members.
+
+ ``target``
+ An :command:`install(TARGETS)` call.
+ The ``destination`` and ``paths`` members are populated, with paths
+ under the top-level *build* directory expressed relative to it.
+ The ``isOptional`` member may exist.
+ This type has additional members ``targetId``, ``targetIndex``,
+ ``targetIsImportLibrary``, and ``targetInstallNamelink``.
+
+ ``export``
+ An :command:`install(EXPORT)` call.
+ The ``destination`` and ``paths`` members are populated, with paths
+ under the top-level *build* directory expressed relative to it.
+ The ``paths`` entries refer to files generated automatically by
+ CMake for installation, and their actual values are considered
+ private implementation details.
+ This type has additional members ``exportName`` and ``exportTargets``.
+
+ ``script``
+ An :command:`install(SCRIPT)` call.
+ This type has additional member ``scriptFile``.
+
+ ``code``
+ An :command:`install(CODE)` call.
+ This type has no additional members.
+
+ ``importedRuntimeArtifacts``
+ An :command:`install(IMPORTED_RUNTIME_ARTIFACTS)` call.
+ The ``destination`` member is populated. The ``isOptional`` member may
+ exist. This type has no additional members.
+
+ ``runtimeDependencySet``
+ An :command:`install(RUNTIME_DEPENDENCY_SET)` call or an
+ :command:`install(TARGETS)` call with ``RUNTIME_DEPENDENCIES``. The
+ ``destination`` member is populated. This type has additional members
+ ``runtimeDependencySetName`` and ``runtimeDependencySetType``.
+
+ ``isExcludeFromAll``
+ Optional member that is present with boolean value ``true`` when
+ :command:`install` is called with the ``EXCLUDE_FROM_ALL`` option.
+
+ ``isForAllComponents``
+ Optional member that is present with boolean value ``true`` when
+ :command:`install(SCRIPT|CODE)` is called with the
+ ``ALL_COMPONENTS`` option.
+
+ ``isOptional``
+ Optional member that is present with boolean value ``true`` when
+ :command:`install` is called with the ``OPTIONAL`` option.
+ This is allowed when ``type`` is ``file``, ``directory``, or ``target``.
+
+ ``targetId``
+ Optional member that is present when ``type`` is ``target``.
+ The value is a string uniquely identifying the target to be installed.
+ This matches the ``id`` member of the target in the main
+ "codemodel" object's ``targets`` array.
+
+ ``targetIndex``
+ Optional member that is present when ``type`` is ``target``.
+ The value is an unsigned integer 0-based index into the main "codemodel"
+ object's ``targets`` array for the target to be installed.
+
+ ``targetIsImportLibrary``
+ Optional member that is present when ``type`` is ``target`` and
+ the installer is for a Windows DLL import library file or for an
+ AIX linker import file. If present, it has boolean value ``true``.
+
+ ``targetInstallNamelink``
+ Optional member that is present when ``type`` is ``target`` and
+ the installer corresponds to a target that may use symbolic links
+ to implement the :prop_tgt:`VERSION` and :prop_tgt:`SOVERSION`
+ target properties.
+ The value is a string indicating how the installer is supposed to
+ handle the symlinks: ``skip`` means the installer should skip the
+ symlinks and install only the real file, and ``only`` means the
+ installer should install only the symlinks and not the real file.
+ In all cases the ``paths`` member lists what it actually installs.
+
+ ``exportName``
+ Optional member that is present when ``type`` is ``export``.
+ The value is a string specifying the name of the export.
+
+ ``exportTargets``
+ Optional member that is present when ``type`` is ``export``.
+ The value is a JSON array of entries corresponding to the targets
+ included in the export. Each entry is a JSON object with members:
+
+ ``id``
+ A string uniquely identifying the target. This matches
+ the ``id`` member of the target in the main "codemodel"
+ object's ``targets`` array.
+
+ ``index``
+ An unsigned integer 0-based index into the main "codemodel"
+ object's ``targets`` array for the target.
+
+ ``runtimeDependencySetName``
+ Optional member that is present when ``type`` is ``runtimeDependencySet``
+ and the installer was created by an
+ :command:`install(RUNTIME_DEPENDENCY_SET)` call. The value is a string
+ specifying the name of the runtime dependency set that was installed.
+
+ ``runtimeDependencySetType``
+ Optional member that is present when ``type`` is ``runtimeDependencySet``.
+ The value is a string with one of the following values:
+
+ ``library``
+ Indicates that this installer installs dependencies that are not macOS
+ frameworks.
+
+ ``framework``
+ Indicates that this installer installs dependencies that are macOS
+ frameworks.
+
+ ``scriptFile``
+ Optional member that is present when ``type`` is ``script``.
+ The value is a string specifying the path to the script file on disk,
+ represented with forward slashes. If the file is inside the top-level
+ source directory then the path is specified relative to that directory.
+ Otherwise the path is absolute.
+
+ ``backtrace``
+ Optional member that is present when a CMake language backtrace to
+ the :command:`install` or other command invocation that added this
+ installer is available. The value is an unsigned integer 0-based
+ index into the ``backtraceGraph`` member's ``nodes`` array.
+
+``backtraceGraph``
+ A `"codemodel" version 2 "backtrace graph"`_ whose nodes are referenced
+ from ``backtrace`` members elsewhere in this "directory" object.
+
"codemodel" version 2 "target" object
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -964,40 +1183,48 @@ with members:
with forward slashes.
``backtraceGraph``
- A JSON object describing the graph of backtraces whose nodes are
- referenced from ``backtrace`` members elsewhere. The members are:
+ A `"codemodel" version 2 "backtrace graph"`_ whose nodes are referenced
+ from ``backtrace`` members elsewhere in this "target" object.
- ``nodes``
- A JSON array listing nodes in the backtrace graph. Each entry
- is a JSON object with members:
+"codemodel" version 2 "backtrace graph"
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- ``file``
- An unsigned integer 0-based index into the backtrace ``files`` array.
+The ``backtraceGraph`` member of a `"codemodel" version 2 "directory" object`_,
+or `"codemodel" version 2 "target" object`_ is a JSON object describing a
+graph of backtraces. Its nodes are referenced from ``backtrace`` members
+elsewhere in the containing object. The backtrace graph object members are:
- ``line``
- An optional member present when the node represents a line within
- the file. The value is an unsigned integer 1-based line number.
+``nodes``
+ A JSON array listing nodes in the backtrace graph. Each entry
+ is a JSON object with members:
- ``command``
- An optional member present when the node represents a command
- invocation within the file. The value is an unsigned integer
- 0-based index into the backtrace ``commands`` array.
+ ``file``
+ An unsigned integer 0-based index into the backtrace ``files`` array.
- ``parent``
- An optional member present when the node is not the bottom of
- the call stack. The value is an unsigned integer 0-based index
- of another entry in the backtrace ``nodes`` array.
+ ``line``
+ An optional member present when the node represents a line within
+ the file. The value is an unsigned integer 1-based line number.
- ``commands``
- A JSON array listing command names referenced by backtrace nodes.
- Each entry is a string specifying a command name.
+ ``command``
+ An optional member present when the node represents a command
+ invocation within the file. The value is an unsigned integer
+ 0-based index into the backtrace ``commands`` array.
- ``files``
- A JSON array listing CMake language files referenced by backtrace nodes.
- Each entry is a string specifying the path to a file, represented
- with forward slashes. If the file is inside the top-level source
- directory then the path is specified relative to that directory.
- Otherwise the path is absolute.
+ ``parent``
+ An optional member present when the node is not the bottom of
+ the call stack. The value is an unsigned integer 0-based index
+ of another entry in the backtrace ``nodes`` array.
+
+``commands``
+ A JSON array listing command names referenced by backtrace nodes.
+ Each entry is a string specifying a command name.
+
+``files``
+ A JSON array listing CMake language files referenced by backtrace nodes.
+ Each entry is a string specifying the path to a file, represented
+ with forward slashes. If the file is inside the top-level source
+ directory then the path is specified relative to that directory.
+ Otherwise the path is absolute.
Object Kind "cache"
-------------------
@@ -1244,7 +1471,7 @@ The members specific to ``toolchains`` objects are:
``language``
A JSON string specifying the toolchain language, like C or CXX. Language
- names are the same as langauge names that can be passed to the
+ names are the same as language names that can be passed to the
:command:`project` command. Because CMake only supports a single toolchain
per language, this field can be used as a key.
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index 7bc490f70..5d508cb0d 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -94,6 +94,8 @@ String Comparisons
.. genex:: $<IN_LIST:string,list>
+ .. versionadded:: 3.12
+
``1`` if ``string`` is member of the semicolon-separated ``list``, else ``0``.
Uses case-sensitive comparisons.
@@ -111,10 +113,14 @@ String Comparisons
.. genex:: $<VERSION_LESS_EQUAL:v1,v2>
+ .. versionadded:: 3.7
+
``1`` if ``v1`` is a version less than or equal to ``v2``, else ``0``.
.. genex:: $<VERSION_GREATER_EQUAL:v1,v2>
+ .. versionadded:: 3.7
+
``1`` if ``v1`` is a version greater than or equal to ``v2``, else ``0``.
Variable Queries
@@ -122,6 +128,8 @@ Variable Queries
.. genex:: $<TARGET_EXISTS:target>
+ .. versionadded:: 3.12
+
``1`` if ``target`` exists, else ``0``.
.. genex:: $<CONFIG:cfgs>
@@ -155,6 +163,8 @@ Variable Queries
.. genex:: $<CUDA_COMPILER_ID:compiler_ids>
+ .. versionadded:: 3.15
+
where ``compiler_ids`` is a comma-separated list.
``1`` if the CMake's compiler id of the CUDA compiler matches any one
of the entries in ``compiler_ids``, otherwise ``0``.
@@ -162,6 +172,8 @@ Variable Queries
.. genex:: $<OBJC_COMPILER_ID:compiler_ids>
+ .. versionadded:: 3.16
+
where ``compiler_ids`` is a comma-separated list.
``1`` if the CMake's compiler id of the Objective-C compiler matches any one
of the entries in ``compiler_ids``, otherwise ``0``.
@@ -169,6 +181,8 @@ Variable Queries
.. genex:: $<OBJCXX_COMPILER_ID:compiler_ids>
+ .. versionadded:: 3.16
+
where ``compiler_ids`` is a comma-separated list.
``1`` if the CMake's compiler id of the Objective-C++ compiler matches any one
of the entries in ``compiler_ids``, otherwise ``0``.
@@ -181,8 +195,17 @@ Variable Queries
of the entries in ``compiler_ids``, otherwise ``0``.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+.. genex:: $<HIP_COMPILER_ID:compiler_ids>
+
+ where ``compiler_ids`` is a comma-separated list.
+ ``1`` if the CMake's compiler id of the HIP compiler matches any one
+ of the entries in ``compiler_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+
.. genex:: $<ISPC_COMPILER_ID:compiler_ids>
+ .. versionadded:: 3.19
+
where ``compiler_ids`` is a comma-separated list.
``1`` if the CMake's compiler id of the ISPC compiler matches any one
of the entries in ``compiler_ids``, otherwise ``0``.
@@ -200,16 +223,22 @@ Variable Queries
.. genex:: $<CUDA_COMPILER_VERSION:version>
+ .. versionadded:: 3.15
+
``1`` if the version of the CXX compiler matches ``version``, otherwise ``0``.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
.. genex:: $<OBJC_COMPILER_VERSION:version>
+ .. versionadded:: 3.16
+
``1`` if the version of the OBJC compiler matches ``version``, otherwise ``0``.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
.. genex:: $<OBJCXX_COMPILER_VERSION:version>
+ .. versionadded:: 3.16
+
``1`` if the version of the OBJCXX compiler matches ``version``, otherwise ``0``.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
@@ -218,8 +247,15 @@ Variable Queries
``1`` if the version of the Fortran compiler matches ``version``, otherwise ``0``.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+.. genex:: $<HIP_COMPILER_VERSION:version>
+
+ ``1`` if the version of the HIP compiler matches ``version``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+
.. genex:: $<ISPC_COMPILER_VERSION:version>
+ .. versionadded:: 3.19
+
``1`` if the version of the ISPC compiler matches ``version``, otherwise ``0``.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
@@ -232,6 +268,8 @@ Variable Queries
.. genex:: $<COMPILE_FEATURES:features>
+ .. versionadded:: 3.1
+
where ``features`` is a comma-spearated list.
Evaluates to ``1`` if all of the ``features`` are available for the 'head'
target, and ``0`` otherwise. If this expression is used while evaluating
@@ -245,6 +283,8 @@ Variable Queries
.. genex:: $<COMPILE_LANG_AND_ID:language,compiler_ids>
+ .. versionadded:: 3.15
+
``1`` when the language used for compilation unit matches ``language`` and
the CMake's compiler id of the language compiler matches any one of the
entries in ``compiler_ids``, otherwise ``0``. This expression is a short form
@@ -282,6 +322,8 @@ Variable Queries
.. genex:: $<COMPILE_LANGUAGE:languages>
+ .. versionadded:: 3.3
+
``1`` when the language used for compilation unit matches any of the entries
in ``languages``, otherwise ``0``. This expression may be used to specify
compile options, compile definitions, and include directories for source files of a
@@ -328,6 +370,8 @@ Variable Queries
.. genex:: $<LINK_LANG_AND_ID:language,compiler_ids>
+ .. versionadded:: 3.18
+
``1`` when the language used for link step matches ``language`` and the
CMake's compiler id of the language linker matches any one of the entries
in ``compiler_ids``, otherwise ``0``. This expression is a short form for the
@@ -368,6 +412,8 @@ Variable Queries
.. genex:: $<LINK_LANGUAGE:languages>
+ .. versionadded:: 3.18
+
``1`` when the language used for link step matches any of the entries
in ``languages``, otherwise ``0``. This expression may be used to specify
link libraries, link options, link directories and link dependencies of a
@@ -431,6 +477,8 @@ Variable Queries
.. genex:: $<DEVICE_LINK:list>
+ .. versionadded:: 3.18
+
Returns the list if it is the device link step, an empty list otherwise.
The device link step is controlled by :prop_tgt:`CUDA_SEPARABLE_COMPILATION`
and :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties and
@@ -439,6 +487,8 @@ Variable Queries
.. genex:: $<HOST_LINK:list>
+ .. versionadded:: 3.18
+
Returns the list if it is the normal link step, an empty list otherwise.
This expression is mainly useful when a device link step is also involved
(see ``$<DEVICE_LINK:list>`` generator expression). This expression can only
@@ -521,6 +571,8 @@ that must be ``0`` or ``1``.
.. genex:: $<IF:condition,true_string,false_string>
+ .. versionadded:: 3.8
+
Evaluates to ``true_string`` if ``condition`` is ``1``.
Otherwise evaluates to ``false_string``.
@@ -545,10 +597,14 @@ String Transformations
.. genex:: $<REMOVE_DUPLICATES:list>
+ .. versionadded:: 3.15
+
Removes duplicated items in the given ``list``.
.. genex:: $<FILTER:list,INCLUDE|EXCLUDE,regex>
+ .. versionadded:: 3.15
+
Includes or removes items from ``list`` that match the regular expression ``regex``.
.. genex:: $<LOWER_CASE:string>
@@ -561,12 +617,16 @@ String Transformations
.. genex:: $<GENEX_EVAL:expr>
+ .. versionadded:: 3.12
+
Content of ``expr`` evaluated as a generator expression in the current
context. This enables consumption of generator expressions whose
evaluation results itself in generator expressions.
.. genex:: $<TARGET_GENEX_EVAL:tgt,expr>
+ .. versionadded:: 3.12
+
Content of ``expr`` evaluated as a generator expression in the context of
``tgt`` target. This enables consumption of custom target properties that
themselves contain generator expressions.
@@ -635,11 +695,15 @@ Variable Queries
.. genex:: $<OBJC_COMPILER_ID>
+ .. versionadded:: 3.16
+
The CMake's compiler id of the OBJC compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
.. genex:: $<OBJCXX_COMPILER_ID>
+ .. versionadded:: 3.16
+
The CMake's compiler id of the OBJCXX compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
@@ -648,8 +712,15 @@ Variable Queries
The CMake's compiler id of the Fortran compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+.. genex:: $<HIP_COMPILER_ID>
+
+ The CMake's compiler id of the HIP compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+
.. genex:: $<ISPC_COMPILER_ID>
+ .. versionadded:: 3.19
+
The CMake's compiler id of the ISPC compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
@@ -670,11 +741,15 @@ Variable Queries
.. genex:: $<OBJC_COMPILER_VERSION>
+ .. versionadded:: 3.16
+
The version of the OBJC compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
.. genex:: $<OBJCXX_COMPILER_VERSION>
+ .. versionadded:: 3.16
+
The version of the OBJCXX compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
@@ -683,13 +758,22 @@ Variable Queries
The version of the Fortran compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+.. genex:: $<HIP_COMPILER_VERSION>
+
+ The version of the HIP compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+
.. genex:: $<ISPC_COMPILER_VERSION>
+ .. versionadded:: 3.19
+
The version of the ISPC compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
.. genex:: $<COMPILE_LANGUAGE>
+ .. versionadded:: 3.3
+
The compile language of source files when evaluating compile options.
See :ref:`the related boolean expression
<Boolean COMPILE_LANGUAGE Generator Expression>`
@@ -698,6 +782,8 @@ Variable Queries
.. genex:: $<LINK_LANGUAGE>
+ .. versionadded:: 3.18
+
The link language of target when evaluating link options.
See :ref:`the related boolean expression
<Boolean LINK_LANGUAGE Generator Expression>` ``$<LINK_LANGUAGE:language>``
@@ -728,6 +814,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_NAME_IF_EXISTS:tgt>
+ .. versionadded:: 3.12
+
The target name ``tgt`` if the target exists, an empty string otherwise.
Note that ``tgt`` is not added as a dependency of the target this
@@ -739,6 +827,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_FILE_BASE_NAME:tgt>
+ .. versionadded:: 3.15
+
Base name of ``tgt``, i.e. ``$<TARGET_FILE_NAME:tgt>`` without prefix and
suffix.
For example, if the ``tgt`` filename is ``libbase.so``, the base name is ``base``.
@@ -758,6 +848,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_FILE_PREFIX:tgt>
+ .. versionadded:: 3.15
+
Prefix of the ``tgt`` filename (such as ``lib``).
See also the :prop_tgt:`PREFIX` target property.
@@ -767,6 +859,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_FILE_SUFFIX:tgt>
+ .. versionadded:: 3.15
+
Suffix of the ``tgt`` filename (extension such as ``.so`` or ``.exe``).
See also the :prop_tgt:`SUFFIX` target property.
@@ -797,6 +891,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_LINKER_FILE_BASE_NAME:tgt>
+ .. versionadded:: 3.15
+
Base name of file used to link the target ``tgt``, i.e.
``$<TARGET_LINKER_FILE_NAME:tgt>`` without prefix and suffix. For example,
if target file name is ``libbase.a``, the base name is ``base``.
@@ -815,6 +911,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_LINKER_FILE_PREFIX:tgt>
+ .. versionadded:: 3.15
+
Prefix of file used to link target ``tgt``.
See also the :prop_tgt:`PREFIX` and :prop_tgt:`IMPORT_PREFIX` target
@@ -825,6 +923,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_LINKER_FILE_SUFFIX:tgt>
+ .. versionadded:: 3.15
+
Suffix of file used to link where ``tgt`` is the name of a target.
The suffix corresponds to the file extension (such as ".so" or ".lib").
@@ -868,6 +968,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_PDB_FILE:tgt>
+ .. versionadded:: 3.1
+
Full path to the linker generated program database file (.pdb)
where ``tgt`` is the name of a target.
@@ -877,6 +979,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_PDB_FILE_BASE_NAME:tgt>
+ .. versionadded:: 3.15
+
Base name of the linker generated program database file (.pdb)
where ``tgt`` is the name of a target.
@@ -895,6 +999,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_PDB_FILE_NAME:tgt>
+ .. versionadded:: 3.1
+
Name of the linker generated program database file (.pdb).
Note that ``tgt`` is not added as a dependency of the target this
@@ -902,6 +1008,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_PDB_FILE_DIR:tgt>
+ .. versionadded:: 3.1
+
Directory of the linker generated program database file (.pdb).
Note that ``tgt`` is not added as a dependency of the target this
@@ -909,6 +1017,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_BUNDLE_DIR:tgt>
+ .. versionadded:: 3.9
+
Full path to the bundle directory (``my.app``, ``my.framework``, or
``my.bundle``) where ``tgt`` is the name of a target.
@@ -917,6 +1027,8 @@ which is just the string ``tgt``.
.. genex:: $<TARGET_BUNDLE_CONTENT_DIR:tgt>
+ .. versionadded:: 3.9
+
Full path to the bundle content directory where ``tgt`` is the name of a
target. For the macOS SDK it leads to ``my.app/Contents``, ``my.framework``,
or ``my.bundle/Contents``. For all other SDKs (e.g. iOS) it leads to
@@ -940,11 +1052,37 @@ which is just the string ``tgt``.
:ref:`Target Usage Requirements` this is the consuming target rather
than the target specifying the requirement.
+.. genex:: $<TARGET_RUNTIME_DLLS:tgt>
+
+ .. versionadded:: 3.21
+
+ List of DLLs that the target depends on at runtime. This is determined by
+ the locations of all the ``SHARED`` and ``MODULE`` targets in the target's
+ transitive dependencies. Using this generator expression on targets other
+ than executables, ``SHARED`` libraries, and ``MODULE`` libraries is an error.
+ On non-DLL platforms, it evaluates to an empty string.
+
+ This generator expression can be used to copy all of the DLLs that a target
+ depends on into its output directory in a ``POST_BUILD`` custom command. For
+ example:
+
+ .. code-block:: cmake
+
+ find_package(foo REQUIRED)
+
+ add_executable(exe main.c)
+ target_link_libraries(exe PRIVATE foo::foo foo::bar)
+ add_custom_command(TARGET exe POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:exe> $<TARGET_FILE_DIR:exe>
+ COMMAND_EXPAND_LISTS
+ )
+
.. genex:: $<INSTALL_PREFIX>
Content of the install prefix when the target is exported via
- :command:`install(EXPORT)`, or when evaluated in
- :prop_tgt:`INSTALL_NAME_DIR`, and empty otherwise.
+ :command:`install(EXPORT)`, or when evaluated in the
+ :prop_tgt:`INSTALL_NAME_DIR` property or the ``INSTALL_NAME_DIR`` argument of
+ :command:`install(RUNTIME_DEPENDENCY_SET)`, and empty otherwise.
Output-Related Expressions
--------------------------
@@ -957,6 +1095,8 @@ Output-Related Expressions
.. genex:: $<LINK_ONLY:...>
+ .. versionadded:: 3.1
+
Content of ``...`` except when evaluated in a link interface while
propagating :ref:`Target Usage Requirements`, in which case it is the
empty string.
@@ -982,18 +1122,24 @@ Output-Related Expressions
.. genex:: $<TARGET_OBJECTS:objLib>
+ .. versionadded:: 3.1
+
List of objects resulting from build of ``objLib``.
.. genex:: $<SHELL_PATH:...>
+ .. versionadded:: 3.4
+
Content of ``...`` converted to shell path style. For example, slashes are
converted to backslashes in Windows shells and drive letters are converted
to posix paths in MSYS shells. The ``...`` must be an absolute path.
- The ``...`` may be a :ref:`semicolon-separated list <CMake Language Lists>`
- of paths, in which case each path is converted individually and a result
- list is generated using the shell path separator (``:`` on POSIX and
- ``;`` on Windows). Be sure to enclose the argument containing this genex
- in double quotes in CMake source code so that ``;`` does not split arguments.
+
+ .. versionadded:: 3.14
+ The ``...`` may be a :ref:`semicolon-separated list <CMake Language Lists>`
+ of paths, in which case each path is converted individually and a result
+ list is generated using the shell path separator (``:`` on POSIX and
+ ``;`` on Windows). Be sure to enclose the argument containing this genex
+ in double quotes in CMake source code so that ``;`` does not split arguments.
.. genex:: $<OUTPUT_CONFIG:...>
diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst
index 8ca2bf644..663b18d46 100644
--- a/Help/manual/cmake-generators.7.rst
+++ b/Help/manual/cmake-generators.7.rst
@@ -91,6 +91,7 @@ Visual Studio Generators
/generator/Visual Studio 14 2015
/generator/Visual Studio 15 2017
/generator/Visual Studio 16 2019
+ /generator/Visual Studio 17 2022
Other Generators
^^^^^^^^^^^^^^^^
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 17c1a1e5c..141eeaa76 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -185,6 +185,7 @@ They are normally called through the :command:`find_package` command.
/module/FindMPEG
/module/FindMPEG2
/module/FindMPI
+ /module/FindMsys
/module/FindODBC
/module/FindOpenACC
/module/FindOpenAL
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index bd6b2f0ca..b9e3d452f 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -51,6 +51,19 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
to determine whether to report an error on use of deprecated macros or
functions.
+Policies Introduced by CMake 3.21
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0126: set(CACHE) does not remove a normal variable of the same name. </policy/CMP0126>
+ CMP0125: find_(path|file|library|program) have consistent behavior for cache variables. </policy/CMP0125>
+ CMP0124: foreach() loop variables are only available in the loop scope. </policy/CMP0124>
+ CMP0123: ARMClang cpu/arch compile and link flags must be set explicitly. </policy/CMP0123>
+ CMP0122: UseSWIG use standard library name conventions for csharp language. </policy/CMP0122>
+ CMP0121: The list command detects invalid indices. </policy/CMP0121>
+
Policies Introduced by CMake 3.20
=================================
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst
index 467818dfa..db26b5a40 100644
--- a/Help/manual/cmake-presets.7.rst
+++ b/Help/manual/cmake-presets.7.rst
@@ -39,7 +39,7 @@ The root object recognizes the following fields:
``version``
A required integer representing the version of the JSON schema.
- The supported versions are ``1`` and ``2``.
+ The supported versions are ``1``, ``2``, and ``3``.
``cmakeMinimumRequired``
@@ -70,17 +70,17 @@ The root object recognizes the following fields:
``configurePresets``
An optional array of `Configure Preset`_ objects.
- This is allowed in preset files specifying version 1 or above.
+ This is allowed in preset files specifying version ``1`` or above.
``buildPresets``
An optional array of `Build Preset`_ objects.
- This is allowed in preset files specifying version 2 or above.
+ This is allowed in preset files specifying version ``2`` or above.
``testPresets``
An optional array of `Test Preset`_ objects.
- This is allowed in preset files specifying version 2 or above.
+ This is allowed in preset files specifying version ``2`` or above.
Configure Preset
^^^^^^^^^^^^^^^^
@@ -119,6 +119,11 @@ that may contain the following fields:
This field can also be a string, which is equivalent to an array
containing one string.
+``condition``
+
+ An optional `Condition`_ object. This is allowed in preset files specifying
+ version ``3`` or above.
+
``vendor``
An optional map containing vendor-specific information. CMake does not
@@ -140,7 +145,9 @@ that may contain the following fields:
An optional string representing the generator to use for the preset. If
``generator`` is not specified, it must be inherited from the
- ``inherits`` preset (unless this preset is ``hidden``).
+ ``inherits`` preset (unless this preset is ``hidden``). In version ``3``
+ or above, this field may be omitted to fall back to regular generator
+ discovery procedure.
Note that for Visual Studio generators, unlike in the command line ``-G``
argument, you cannot include the platform name in the generator name. Use
@@ -175,13 +182,29 @@ that may contain the following fields:
ignore the field, but the IDE can use them to set up the environment
before invoking CMake.
+``toolchainFile``
+
+ An optional string representing the path to the toolchain file.
+ This field supports `macro expansion`_. If a relative path is specified,
+ it is calculated relative to the build directory, and if not found,
+ relative to the source directory. Takes precedence over any `CMAKE_TOOLCHAIN_FILE`
+ value. This is allowed in preset files specifying version ``3`` or above.
+
``binaryDir``
An optional string representing the path to the output binary directory.
This field supports `macro expansion`_. If a relative path is specified,
it is calculated relative to the source directory. If ``binaryDir`` is not
specified, it must be inherited from the ``inherits`` preset (unless this
- preset is ``hidden``).
+ preset is ``hidden``). In version ``3`` or above, this field may be
+ omitted.
+
+``installDir``
+
+ An optional string representing the path to the installation directory.
+ This field supports `macro expansion`_. If a relative path is specified,
+ it is calculated relative to the source directory. This is allowed in
+ preset files specifying version ``3`` or above.
``cmakeExecutable``
@@ -338,6 +361,11 @@ that may contain the following fields:
This field can also be a string, which is equivalent to an array
containing one string.
+``condition``
+
+ An optional `Condition`_ object. This is allowed in preset files specifying
+ version ``3`` or above.
+
``vendor``
An optional map containing vendor-specific information. CMake does not
@@ -373,6 +401,19 @@ that may contain the following fields:
are applied. Setting a variable to ``null`` causes it to not be set,
even if a value was inherited from another preset.
+ .. note::
+
+ For a CMake project using ExternalProject with a configuration preset
+ having environment variables needed in the ExternalProject, use a build
+ preset that inherits that configuration preset or the ExternalProject
+ will not have the environment variables set in the configuration preset.
+ Example: suppose the host defaults to one compiler (say Clang)
+ and the user wishes to use another compiler (say GCC). Set configuration
+ preset environment variables ``CC`` and ``CXX`` and use a build preset
+ that inherits that configuration preset. Otherwise the ExternalProject
+ may use a different (system default) compiler than the top-level CMake
+ project.
+
``configurePreset``
An optional string specifying the name of a configure preset to
@@ -457,6 +498,11 @@ that may contain the following fields:
This field can also be a string, which is equivalent to an array
containing one string.
+``condition``
+
+ An optional `Condition`_ object. This is allowed in preset files specifying
+ version ``3`` or above.
+
``vendor``
An optional map containing vendor-specific information. CMake does not
@@ -609,7 +655,8 @@ that may contain the following fields:
An optional string specifying a regex for test names. Equivalent to
passing ``--tests-regex`` on the command line. This field supports
- macro expansion.
+ macro expansion. CMake regex syntax is described under
+ :ref:`string(REGEX) <Regex Specification>`.
``label``
@@ -782,6 +829,103 @@ that may contain the following fields:
Equivalent to passing ``--no-tests=ignore`` on the command line.
+Condition
+^^^^^^^^^
+
+The ``condition`` field of a preset, allowed in preset files specifying version
+``3`` or above, is used to determine whether or not the preset is enabled. For
+example, this can be used to disable a preset on platforms other than Windows.
+``condition`` may be either a boolean, ``null``, or an object. If it is a
+boolean, the boolean indicates whether the preset is enabled or disabled. If it
+is ``null``, the preset is enabled, but the ``null`` condition is not inherited
+by any presets that may inherit from the preset. Sub-conditions (for example in
+a ``not``, ``anyOf``, or ``allOf`` condition) may not be ``null``. If it is an
+object, it has the following fields:
+
+``type``
+
+ A required string with one of the following values:
+
+ ``"const"``
+
+ Indicates that the condition is constant. This is equivalent to using a
+ boolean in place of the object. The condition object will have the
+ following additional fields:
+
+ ``value``
+
+ A required boolean which provides a constant value for the condition's
+ evaluation.
+
+ ``"equals"``
+
+ ``"notEquals"``
+
+ Indicates that the condition compares two strings to see if they are equal
+ (or not equal). The condition object will have the following additional
+ fields:
+
+ ``lhs``
+
+ First string to compare. This field supports macro expansion.
+
+ ``rhs``
+
+ Second string to compare. This field supports macro expansion.
+
+ ``"inList"``
+
+ ``"notInList"``
+
+ Indicates that the condition searches for a string in a list of strings.
+ The condition object will have the following additional fields:
+
+ ``string``
+
+ A required string to search for. This field supports macro expansion.
+
+ ``list``
+
+ A required list of strings to search. This field supports macro
+ expansion, and uses short-circuit evaluation.
+
+ ``"matches"``
+
+ ``"notMatches"``
+
+ Indicates that the condition searches for a regular expression in a string.
+ The condition object will have the following additional fields:
+
+ ``string``
+
+ A required string to search. This field supports macro expansion.
+
+ ``regex``
+
+ A required regular expression to search for. This field supports macro
+ expansion.
+
+ ``"anyOf"``
+
+ ``"allOf"``
+
+ Indicates that the condition is an aggregation of zero or more nested
+ conditions. The condition object will have the following additional fields:
+
+ ``conditions``
+
+ A required array of condition objects. These conditions use short-circuit
+ evaluation.
+
+ ``"not"``
+
+ Indicates that the condition is an inversion of another condition. The
+ condition object will have the following additional fields:
+
+ ``condition``
+
+ A required condition object.
+
Macro Expansion
^^^^^^^^^^^^^^^
@@ -823,6 +967,12 @@ Recognized macros include:
test presets, this will evaluate to the generator specified by
``configurePreset``.
+``${hostSystemName}``
+
+ The name of the host operating system. Contains the same value as
+ :variable:`CMAKE_HOST_SYSTEM_NAME`. This is allowed in preset files
+ specifying version ``3`` or above.
+
``${dollar}``
A literal dollar sign (``$``).
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index af170dabd..5f18a8247 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -21,6 +21,7 @@ Properties of Global Scope
/prop_gbl/AUTOMOC_SOURCE_GROUP
/prop_gbl/AUTOMOC_TARGETS_FOLDER
/prop_gbl/AUTORCC_SOURCE_GROUP
+ /prop_gbl/AUTOUIC_SOURCE_GROUP
/prop_gbl/CMAKE_C_KNOWN_FEATURES
/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES
/prop_gbl/CMAKE_CXX_KNOWN_FEATURES
@@ -73,6 +74,7 @@ Properties on Directories
/prop_dir/DEFINITIONS
/prop_dir/EXCLUDE_FROM_ALL
/prop_dir/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
+ /prop_dir/IMPORTED_TARGETS
/prop_dir/INCLUDE_DIRECTORIES
/prop_dir/INCLUDE_REGULAR_EXPRESSION
/prop_dir/INTERPROCEDURAL_OPTIMIZATION
@@ -211,6 +213,7 @@ Properties on Targets
/prop_tgt/GHS_NO_SOURCE_GROUP_FILE
/prop_tgt/GNUtoMS
/prop_tgt/HAS_CXX
+ /prop_tgt/HIP_ARCHITECTURES
/prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
/prop_tgt/IMPORTED
/prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME
@@ -271,6 +274,7 @@ Properties on Targets
/prop_tgt/LANG_CPPCHECK
/prop_tgt/LANG_CPPLINT
/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE
+ /prop_tgt/LANG_LINKER_LAUNCHER
/prop_tgt/LANG_VISIBILITY_PRESET
/prop_tgt/LIBRARY_OUTPUT_DIRECTORY
/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG
@@ -402,7 +406,9 @@ Properties on Targets
/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY
/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY
/prop_tgt/XCODE_EMBED_type
+ /prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY
/prop_tgt/XCODE_EMBED_type_PATH
+ /prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY
/prop_tgt/XCODE_EXPLICIT_FILE_TYPE
/prop_tgt/XCODE_GENERATE_SCHEME
/prop_tgt/XCODE_LINK_BUILD_PHASE_MODE
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index 1ededee18..a94131049 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -96,8 +96,8 @@ Cross Compiling
===============
If :manual:`cmake(1)` is invoked with the command line parameter
-``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the file will be loaded early to set
-values for the compilers.
+``--toolchain path/to/file`` or ``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the
+file will be loaded early to set values for the compilers.
The :variable:`CMAKE_CROSSCOMPILING` variable is set to true when CMake is
cross-compiling.
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 4317dd407..39fbbed39 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -130,6 +130,7 @@ Variables that Provide Information
/variable/PROJECT-NAME_BINARY_DIR
/variable/PROJECT-NAME_DESCRIPTION
/variable/PROJECT-NAME_HOMEPAGE_URL
+ /variable/PROJECT-NAME_IS_TOP_LEVEL
/variable/PROJECT-NAME_SOURCE_DIR
/variable/PROJECT-NAME_VERSION
/variable/PROJECT-NAME_VERSION_MAJOR
@@ -139,6 +140,7 @@ Variables that Provide Information
/variable/PROJECT_BINARY_DIR
/variable/PROJECT_DESCRIPTION
/variable/PROJECT_HOMEPAGE_URL
+ /variable/PROJECT_IS_TOP_LEVEL
/variable/PROJECT_NAME
/variable/PROJECT_SOURCE_DIR
/variable/PROJECT_VERSION
@@ -243,6 +245,7 @@ Variables that Change Behavior
/variable/CMAKE_SYSTEM_LIBRARY_PATH
/variable/CMAKE_SYSTEM_PREFIX_PATH
/variable/CMAKE_SYSTEM_PROGRAM_PATH
+ /variable/CMAKE_TLS_VERIFY
/variable/CMAKE_USER_MAKE_RULES_OVERRIDE
/variable/CMAKE_WARN_DEPRECATED
/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
@@ -421,6 +424,7 @@ Variables that Control the Build
/variable/CMAKE_LANG_CPPCHECK
/variable/CMAKE_LANG_CPPLINT
/variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE
+ /variable/CMAKE_LANG_LINKER_LAUNCHER
/variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG
/variable/CMAKE_LANG_LINK_LIBRARY_FLAG
/variable/CMAKE_LANG_VISIBILITY_PRESET
@@ -519,6 +523,7 @@ Variables for Languages
/variable/CMAKE_Fortran_MODDIR_DEFAULT
/variable/CMAKE_Fortran_MODDIR_FLAG
/variable/CMAKE_Fortran_MODOUT_FLAG
+ /variable/CMAKE_HIP_ARCHITECTURES
/variable/CMAKE_ISPC_HEADER_DIRECTORY
/variable/CMAKE_ISPC_HEADER_SUFFIX
/variable/CMAKE_ISPC_INSTRUCTION_SETS
@@ -644,6 +649,7 @@ Variables for CTest
/variable/CTEST_RESOURCE_SPEC_FILE
/variable/CTEST_RUN_CURRENT_SCRIPT
/variable/CTEST_SCP_COMMAND
+ /variable/CTEST_SCRIPT_DIRECTORY
/variable/CTEST_SITE
/variable/CTEST_SUBMIT_URL
/variable/CTEST_SOURCE_DIRECTORY
@@ -667,6 +673,7 @@ Variables for CPack
/variable/CPACK_ABSOLUTE_DESTINATION_FILES
/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY
+ /variable/CPACK_CUSTOM_INSTALL_VARIABLES
/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY
/variable/CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 02828ac5b..e23ddd823 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -381,9 +381,9 @@ Options
``--preset <preset>``, ``--preset=<preset>``
Reads a :manual:`preset <cmake-presets(7)>` from
``<path-to-source>/CMakePresets.json`` and
- ``<path-to-source>/CMakeUserPresets.json``. The preset specifies the
- generator and the build directory, and optionally a list of variables and
- other arguments to pass to CMake. The current working directory must contain
+ ``<path-to-source>/CMakeUserPresets.json``. The preset may specify the
+ generator and the build directory, and a list of variables and other
+ arguments to pass to CMake. The current working directory must contain
CMake preset files. The :manual:`CMake GUI <cmake-gui(1)>` can
also recognize ``CMakePresets.json`` and ``CMakeUserPresets.json`` files. For
full details on these files, see :manual:`cmake-presets(7)`.
@@ -408,7 +408,8 @@ project binary tree:
.. code-block:: shell
- cmake --build [<dir> | --preset <preset>] [<options>] [-- <build-tool-options>]
+ cmake --build <dir> [<options>] [-- <build-tool-options>]
+ cmake --build --preset <preset> [<options>] [-- <build-tool-options>]
This abstracts a native build tool's command-line interface with the
following options:
@@ -575,6 +576,12 @@ Available commands are:
``true`` if the generator supports toolsets and ``false`` otherwise.
``platformSupport``
``true`` if the generator supports platforms and ``false`` otherwise.
+ ``supportedPlatforms``
+ .. versionadded:: 3.21
+
+ Optional member that may be present when the generator supports
+ platform specification via :variable:`CMAKE_GENERATOR_PLATFORM`
+ (``-A ...``). The value is a list of platforms known to be supported.
``extraGenerators``
A list of strings with all the extra generators compatible with
the generator.
@@ -702,7 +709,7 @@ Available commands are:
``remove [-f] <file>...``
.. deprecated:: 3.17
- Remove the file(s). The planned behaviour was that if any of the
+ Remove the file(s). The planned behavior was that if any of the
listed files already do not exist, the command returns a non-zero exit code,
but no message is logged. The ``-f`` option changes the behavior to return a
zero exit code (i.e. success) in such situations instead.
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 175359d6c..ab819f94e 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -134,6 +134,12 @@ Options
This option tells CTest to write all its output to a ``<file>`` log file.
+``--output-junit <file>``
+ Write test results in JUnit format.
+
+ This option tells CTest to write test results to a ``<file>`` JUnit XML file.
+ If ``<file>`` already exists it will be overwritten.
+
``-N,--show-only[=<format>]``
Disable actual execution of tests.
@@ -152,10 +158,14 @@ Options
See `Show as JSON Object Model`_.
``-L <regex>, --label-regex <regex>``
- Run tests with labels matching regular expression.
+ Run tests with labels matching regular expression as described under
+ :ref:`string(REGEX) <Regex Specification>`.
This option tells CTest to run only the tests whose labels match the
- given regular expression.
+ given regular expression. When more than one ``-L`` option is given,
+ a test will only be run if each regular expression matches at least one
+ of the test's labels (i.e. the multiple ``-L`` labels form an ``AND``
+ relationship). See `Label Matching`_.
``-R <regex>, --tests-regex <regex>``
Run tests matching regular expression.
@@ -173,7 +183,10 @@ Options
Exclude tests with labels matching regular expression.
This option tells CTest to NOT run the tests whose labels match the
- given regular expression.
+ given regular expression. When more than one ``-LE`` option is given,
+ a test will only be excluded if each regular expression matches at least one
+ of the test's labels (i.e. the multiple ``-LE`` labels form an ``AND``
+ relationship). See `Label Matching`_.
``-FA <regex>, --fixture-exclude-any <regex>``
Exclude fixtures matching ``<regex>`` from automatically adding any tests to
@@ -309,11 +322,13 @@ Options
Set the interactive mode to ``0`` or ``1``.
This option causes CTest to run tests in either an interactive mode
- or a non-interactive mode. On Windows this means that in
- non-interactive mode, all system debug pop up windows are blocked.
- In dashboard mode (``Experimental``, ``Nightly``, ``Continuous``), the default
- is non-interactive. When just running tests not for a dashboard the
- default is to allow popups and interactive debugging.
+ or a non-interactive mode. In dashboard mode (``Experimental``, ``Nightly``,
+ ``Continuous``), the default is non-interactive. In non-interactive mode,
+ the environment variable :envvar:`DASHBOARD_TEST_FROM_CTEST` is set.
+
+ Prior to CMake 3.11, interactive mode on Windows allowed system debug
+ popup windows to appear. Now, due to CTest's use of ``libuv`` to launch
+ test processes, all system debug popup windows are always blocked.
``--no-label-summary``
Disable timing summary information for labels.
@@ -398,6 +413,46 @@ Specify the directory in which to look for tests.
.. include:: OPTIONS_HELP.txt
+.. _`Label Matching`:
+
+Label Matching
+==============
+
+Tests may have labels attached to them. Tests may be included
+or excluded from a test run by filtering on the labels.
+Each individual filter is a regular expression applied to
+the labels attached to a test.
+
+When ``-L`` is used, in order for a test to be included in a
+test run, each regular expression must match at least one
+label. Using more than one ``-L`` option means "match **all**
+of these".
+
+The ``-LE`` option works just like ``-L``, but excludes tests
+rather than including them. A test is excluded if each regular
+expression matches at least one label.
+
+If a test has no labels attached to it, then ``-L`` will never
+include that test, and ``-LE`` will never exclude that test.
+As an example of tests with labels, consider five tests,
+with the following labels:
+
+* *test1* has labels *tuesday* and *production*
+* *test2* has labels *tuesday* and *test*
+* *test3* has labels *wednesday* and *production*
+* *test4* has label *wednesday*
+* *test5* has labels *friday* and *test*
+
+Running ``ctest`` with ``-L tuesday -L test`` will select *test2*, which has
+both labels. Running CTest with ``-L test`` will select *test2* and
+*test5*, because both of them have a label that matches that regular
+expression.
+
+Because the matching works with regular expressions, take note that
+running CTest with ``-L es`` will match all five tests.
+To select the *tuesday* and *wednesday* tests together, use a single
+regular expression that matches either of them, like ``-L "tue|wed"``.
+
.. _`Label and Subproject Summary`:
Label and Subproject Summary
@@ -1043,6 +1098,8 @@ Configuration settings include:
* `CTest Script`_ variable: :variable:`CTEST_TEST_TIMEOUT`
* :module:`CTest` module variable: ``DART_TESTING_TIMEOUT``
+To report extra test values to CDash, see :ref:`Additional Test Measurements`.
+
.. _`CTest Coverage Step`:
CTest Coverage Step
@@ -1619,4 +1676,4 @@ See Also
.. include:: LINKS.txt
-.. _`CDash`: http://cdash.org/
+_`CDash`: https://cdash.org
diff --git a/Help/manual/presets/example.json b/Help/manual/presets/example.json
index dfc2910a2..b08445a47 100644
--- a/Help/manual/presets/example.json
+++ b/Help/manual/presets/example.json
@@ -1,8 +1,8 @@
{
- "version": 2,
+ "version": 3,
"cmakeMinimumRequired": {
"major": 3,
- "minor": 20,
+ "minor": 21,
"patch": 0
},
"configurePresets": [
@@ -35,6 +35,17 @@
"displayName": "Ninja Multi-Config",
"description": "Default build using Ninja Multi-Config generator",
"generator": "Ninja Multi-Config"
+ },
+ {
+ "name": "windows-only",
+ "inherits": "default",
+ "displayName": "Windows-only configuration",
+ "description": "This build is only available on Windows",
+ "condition": {
+ "type": "equals",
+ "lhs": "${hostSystemName}",
+ "rhs": "Windows"
+ }
}
],
"buildPresets": [
diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json
index f8faf3dd7..767e80b6b 100644
--- a/Help/manual/presets/schema.json
+++ b/Help/manual/presets/schema.json
@@ -11,7 +11,7 @@
},
"cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"},
"vendor": { "$ref": "#/definitions/vendor" },
- "configurePresets": { "$ref": "#/definitions/configurePresets"}
+ "configurePresets": { "$ref": "#/definitions/configurePresetsV1"}
},
"additionalProperties": false
},
@@ -23,9 +23,23 @@
},
"cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"},
"vendor": { "$ref": "#/definitions/vendor" },
- "configurePresets": { "$ref": "#/definitions/configurePresets"},
- "buildPresets": { "$ref": "#/definitions/buildPresets"},
- "testPresets": { "$ref": "#/definitions/testPresets"}
+ "configurePresets": { "$ref": "#/definitions/configurePresetsV1"},
+ "buildPresets": { "$ref": "#/definitions/buildPresetsV2"},
+ "testPresets": { "$ref": "#/definitions/testPresetsV2"}
+ },
+ "additionalProperties": false
+ },
+ {
+ "properties": {
+ "version": {
+ "const": 3,
+ "description": "A required integer representing the version of the JSON schema."
+ },
+ "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"},
+ "vendor": { "$ref": "#/definitions/vendor" },
+ "configurePresets": { "$ref": "#/definitions/configurePresetsV3"},
+ "buildPresets": { "$ref": "#/definitions/buildPresetsV3"},
+ "testPresets": { "$ref": "#/definitions/testPresetsV3"}
},
"additionalProperties": false
}
@@ -58,7 +72,34 @@
"description": "An optional map containing vendor-specific information. CMake does not interpret the contents of this field except to verify that it is a map if it does exist. However, the keys should be a vendor-specific domain name followed by a /-separated path. For example, the Example IDE 1.0 could use example.com/ExampleIDE/1.0. The value of each field can be anything desired by the vendor, though will typically be a map.",
"properties": {}
},
- "configurePresets": {
+ "configurePresetsItemsV3": {
+ "type": "array",
+ "description": "A configure preset object.",
+ "items": {
+ "type": "object",
+ "description": "A configure preset object.",
+ "properties": {
+ "binaryDir": {
+ "type": "string",
+ "description": "An optional string representing the path to the output binary directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory. If binaryDir is not specified, the path is calculated using regular methods."
+ },
+ "generator": {
+ "type": "string",
+ "description": "An optional string representing the generator to use for the preset. If generator is not specified, the normal generator discovery procedure is used. Note that for Visual Studio generators, unlike in the command line -G argument, you cannot include the platform name in the generator name. Use the architecture field instead."
+ },
+ "toolchainFile": {
+ "type": "string",
+ "description": "An optional string representing the path to the toolchain file. This field supports macro expansion. If a relative path is specified, it is calculated relative to the build directory, and if not found, relative to the source directory."
+ },
+ "installDir": {
+ "type": "string",
+ "description": "An optional string representing the path to the installation directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory."
+ },
+ "condition": { "$ref": "#/definitions/topCondition" }
+ }
+ }
+ },
+ "configurePresetsItemsV1": {
"type": "array",
"description": "An optional array of configure preset objects.",
"items": {
@@ -302,6 +343,37 @@
},
"additionalProperties": false
}
+ }
+ }
+ },
+ "configurePresetsV3": {
+ "type": "array",
+ "description": "An optional array of configure preset objects.",
+ "allOf": [
+ { "$ref": "#/definitions/configurePresetsItemsV1" },
+ { "$ref": "#/definitions/configurePresetsItemsV3" }
+ ],
+ "items": {
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "generator": {},
+ "architecture": {},
+ "toolset": {},
+ "toolchainFile": {},
+ "binaryDir": {},
+ "installDir": {},
+ "cmakeExecutable": {},
+ "cacheVariables": {},
+ "environment": {},
+ "warnings": {},
+ "errors": {},
+ "debug": {},
+ "condition": {}
},
"required": [
"name"
@@ -309,7 +381,48 @@
"additionalProperties": false
}
},
- "buildPresets": {
+ "configurePresetsV1": {
+ "type": "array",
+ "description": "An optional array of configure preset objects.",
+ "allOf": [
+ { "$ref": "#/definitions/configurePresetsItemsV1" }
+ ],
+ "items": {
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "generator": {},
+ "architecture": {},
+ "toolset": {},
+ "binaryDir": {},
+ "cmakeExecutable": {},
+ "cacheVariables": {},
+ "environment": {},
+ "warnings": {},
+ "errors": {},
+ "debug": {}
+ },
+ "required": [
+ "name"
+ ],
+ "additionalProperties": false
+ }
+ },
+ "buildPresetsItemsV3": {
+ "type": "array",
+ "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.",
+ "items": {
+ "type": "object",
+ "properties": {
+ "condition": { "$ref": "#/definitions/topCondition" }
+ }
+ }
+ },
+ "buildPresetsItemsV2": {
"type": "array",
"description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.",
"items": {
@@ -427,11 +540,84 @@
},
"required": [
"name"
+ ]
+ }
+ },
+ "buildPresetsV3": {
+ "type": "array",
+ "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.",
+ "allOf": [
+ { "$ref": "#/definitions/buildPresetsItemsV3" },
+ { "$ref": "#/definitions/buildPresetsItemsV2" }
+ ],
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "configurePreset": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "inheritConfigureEnvironment": {},
+ "environment": {},
+ "jobs": {},
+ "targets": {},
+ "configuration": {},
+ "cleanFirst": {},
+ "verbose": {},
+ "nativeToolOptions": {},
+ "condition": {}
+ },
+ "required": [
+ "name"
+ ],
+ "additionalProperties": false
+ }
+ },
+ "buildPresetsV2": {
+ "type": "array",
+ "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.",
+ "allOf": [
+ { "$ref": "#/definitions/buildPresetsItemsV2" }
+ ],
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "configurePreset": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "inheritConfigureEnvironment": {},
+ "environment": {},
+ "jobs": {},
+ "targets": {},
+ "configuration": {},
+ "cleanFirst": {},
+ "verbose": {},
+ "nativeToolOptions": {}
+ },
+ "required": [
+ "name"
],
"additionalProperties": false
}
},
- "testPresets": {
+ "testPresetsItemsV3": {
+ "type": "array",
+ "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.",
+ "items": {
+ "type": "object",
+ "properties": {
+ "condition": { "$ref": "#/definitions/topCondition" }
+ }
+ }
+ },
+ "testPresetsItemsV2": {
"type": "array",
"description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.",
"items": {
@@ -743,9 +929,312 @@
},
"required": [
"name"
+ ]
+ }
+ },
+ "testPresetsV3": {
+ "type": "array",
+ "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.",
+ "allOf": [
+ { "$ref": "#/definitions/testPresetsItemsV2" },
+ { "$ref": "#/definitions/testPresetsItemsV3" }
+ ],
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "configurePreset": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "inheritConfigureEnvironment": {},
+ "environment": {},
+ "configuration": {},
+ "overwriteConfigurationFile": {},
+ "output": {},
+ "filter": {},
+ "execution": {},
+ "condition": {}
+ },
+ "required": [
+ "name"
+ ],
+ "additionalProperties": false
+ }
+ },
+ "testPresetsV2": {
+ "type": "array",
+ "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.",
+ "allOf": [
+ { "$ref": "#/definitions/testPresetsItemsV2" }
+ ],
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "configurePreset": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "inheritConfigureEnvironment": {},
+ "environment": {},
+ "configuration": {},
+ "overwriteConfigurationFile": {},
+ "output": {},
+ "filter": {},
+ "execution": {}
+ },
+ "required": [
+ "name"
],
"additionalProperties": false
}
+ },
+ "condition": {
+ "anyOf": [
+ {
+ "type": "boolean",
+ "description": "A boolean which provides a constant value for the condition's evaluation."
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "const"
+ },
+ "value": {
+ "type": "boolean",
+ "description": "A required boolean which provides a constant value for the condition's evaluation."
+ }
+ },
+ "required": [
+ "type",
+ "value"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "equals"
+ },
+ "lhs": {
+ "type": "string",
+ "description": "First string to compare. This field supports macro expansion."
+ },
+ "rhs": {
+ "type": "string",
+ "description": "Second string to compare. This field supports macro expansion."
+ }
+ },
+ "required": [
+ "type",
+ "lhs",
+ "rhs"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "notEquals"
+ },
+ "lhs": {
+ "type": "string",
+ "description": "First string to compare. This field supports macro expansion."
+ },
+ "rhs": {
+ "type": "string",
+ "description": "Second string to compare. This field supports macro expansion."
+ }
+ },
+ "required": [
+ "type",
+ "lhs",
+ "rhs"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "inList"
+ },
+ "string": {
+ "type": "string",
+ "description": "A required string to search for. This field supports macro expansion."
+ },
+ "list": {
+ "type": "array",
+ "description": "A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation.",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "type",
+ "string",
+ "list"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "notInList"
+ },
+ "string": {
+ "type": "string",
+ "description": "A required string to search for. This field supports macro expansion."
+ },
+ "list": {
+ "type": "array",
+ "description": "A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation.",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "type",
+ "string",
+ "list"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "matches"
+ },
+ "string": {
+ "type": "string",
+ "description": "A required string to search. This field supports macro expansion."
+ },
+ "regex": {
+ "type": "string",
+ "description": "A required regular expression to search for. This field supports macro expansion."
+ }
+ },
+ "required": [
+ "type",
+ "string",
+ "regex"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "notMatches"
+ },
+ "string": {
+ "type": "string",
+ "description": "A required string to search. This field supports macro expansion."
+ },
+ "regex": {
+ "type": "string",
+ "description": "A required regular expression to search for. This field supports macro expansion."
+ }
+ },
+ "required": [
+ "type",
+ "string",
+ "regex"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "anyOf"
+ },
+ "conditions": {
+ "type": "array",
+ "description": "A required array of condition objects. These conditions use short-circuit evaluation.",
+ "items": { "$ref": "#/definitions/condition" }
+ }
+ },
+ "required": [
+ "type",
+ "conditions"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "allOf"
+ },
+ "conditions": {
+ "type": "array",
+ "description": "A required array of condition objects. These conditions use short-circuit evaluation.",
+ "items": { "$ref": "#/definitions/condition" }
+ }
+ },
+ "required": [
+ "type",
+ "conditions"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "description": "A required string specifying the type of the condition.",
+ "const": "not"
+ },
+ "condition": { "$ref": "#/definitions/condition" }
+ },
+ "required": [
+ "type",
+ "condition"
+ ],
+ "additionalProperties": false
+ }
+ ]
+ },
+ "topCondition": {
+ "anyOf": [
+ { "$ref": "#/definitions/condition" },
+ {
+ "type": "null",
+ "description": "Null indicates that the condition always evaluates to true and is not inherited."
+ }
+ ]
}
}
}
diff --git a/Help/module/FindMsys.rst b/Help/module/FindMsys.rst
new file mode 100644
index 000000000..fc5495ce7
--- /dev/null
+++ b/Help/module/FindMsys.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindMsys.cmake
diff --git a/Help/policy/CMP0102.rst b/Help/policy/CMP0102.rst
index 78b558480..08024bfd3 100644
--- a/Help/policy/CMP0102.rst
+++ b/Help/policy/CMP0102.rst
@@ -22,6 +22,8 @@ already exist in the cache.
This policy was introduced in CMake version 3.17. Use the
:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
Unlike many policies, CMake version |release| does *not* warn
-when this policy is not set and simply uses ``OLD`` behavior.
+when this policy is not set and simply uses ``OLD`` behavior. See
+documentation of the :variable:`CMAKE_POLICY_WARNING_CMP0102
+<CMAKE_POLICY_WARNING_CMP<NNNN>>` variable to control the warning.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0104.rst b/Help/policy/CMP0104.rst
index 7c7a16e37..b125729dd 100644
--- a/Help/policy/CMP0104.rst
+++ b/Help/policy/CMP0104.rst
@@ -41,7 +41,7 @@ Examples
.. code-block:: cmake
- set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 35 50 72)
+ set_target_properties(tgt PROPERTIES CUDA_ARCHITECTURES "35;50;72")
Generates code for real and virtual architectures ``30``, ``50`` and ``72``.
diff --git a/Help/policy/CMP0110.rst b/Help/policy/CMP0110.rst
index 25a00089f..6977d41e5 100644
--- a/Help/policy/CMP0110.rst
+++ b/Help/policy/CMP0110.rst
@@ -8,7 +8,7 @@ CMP0110
:command:`add_test` can now (officially) create tests with whitespace and
other special characters in its name. Before CMake version 3.19 that was not
allowed, however, it was possible to work around this limitation by explicitly
-putting escaped quotes arount the test's name in the ``add_test`` command.
+putting escaped quotes around the test's name in the ``add_test`` command.
Although never officially supported several projects in the wild found and
implemented this workaround. However, the new change which officially allows
diff --git a/Help/policy/CMP0121.rst b/Help/policy/CMP0121.rst
new file mode 100644
index 000000000..326e7d595
--- /dev/null
+++ b/Help/policy/CMP0121.rst
@@ -0,0 +1,21 @@
+CMP0121
+-------
+
+.. versionadded:: 3.21
+
+The :command:`list` command now detects invalid indices.
+
+Prior to CMake version 3.21, the :command:`list` command's ``GET``,
+``INSERT``, ``SUBLIST``, and ``REMOVE_AT`` subcommands did not detect invalid
+index arguments.
+
+The ``OLD`` behavior of this policy is for invalid indices to be treated as
+their integer value (if any) at the start of the string. For example,
+``2good4you`` is a ``2`` and ``not_an_integer`` is a ``0``. The ``NEW``
+behavior is for invalid indices to trigger an error.
+
+This policy was introduced in CMake version 3.21. CMake version |release|
+warns when the policy is not set and uses ``OLD`` behavior. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0122.rst b/Help/policy/CMP0122.rst
new file mode 100644
index 000000000..1ff8c4862
--- /dev/null
+++ b/Help/policy/CMP0122.rst
@@ -0,0 +1,17 @@
+CMP0122
+-------
+
+.. versionadded:: 3.21
+
+:module:`UseSWIG` use library name conventions for ``CSharp`` language.
+
+Starting with CMake 3.21, :module:`UseSWIG` generates now a library using
+default naming conventions. This policy provides compatibility with projects
+that expect the legacy behavior.
+
+This policy was introduced in CMake version 3.21. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0123.rst b/Help/policy/CMP0123.rst
new file mode 100644
index 000000000..e09b5ec97
--- /dev/null
+++ b/Help/policy/CMP0123.rst
@@ -0,0 +1,32 @@
+CMP0123
+-------
+
+.. versionadded:: 3.21
+
+``ARMClang`` cpu/arch compile and link flags must be set explicitly.
+
+CMake 3.20 and lower automatically maps the :variable:`CMAKE_SYSTEM_PROCESSOR`
+variable and an undocumented ``CMAKE_SYSTEM_ARCH`` to compile and link options
+for ``ARMClang``. For example, the ``-mcpu=cortex-m33`` flag is added when
+:variable:`CMAKE_SYSTEM_PROCESSOR` equals ``cortex-m33``. CMake requires
+projects to set either variable or it raises a fatal error. However, the
+project may need to additionally specify CPU features using e.g.
+``-mcpu=cortex-m33+nodsp``, conflicting with the ``-mcpu=cortex-m33`` added
+by CMake. This results in either link errors or unusable binaries.
+
+CMake 3.21 and above prefer instead to not add any cpu/arch compile and link
+flags automatically. Instead, projects must specify them explicitly.
+This policy provides compatibility for projects that have not been updated.
+
+The ``OLD`` behavior of this policy requires projects that use ``ARMClang``
+to set either :variable:`CMAKE_SYSTEM_PROCESSOR` or ``CMAKE_SYSTEM_ARCH``
+and it automatically adds a compile option ``-mcpu=`` or ``-march=`` and
+a link option ``--cpu=`` based on those variables. The ``NEW`` behavior
+does not add compile or link options, and projects are responsible for
+setting correct options.
+
+This policy was introduced in CMake version 3.21. CMake version |release|
+warns when the policy is not set and uses ``OLD`` behavior. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0124.rst b/Help/policy/CMP0124.rst
new file mode 100644
index 000000000..88d03e35d
--- /dev/null
+++ b/Help/policy/CMP0124.rst
@@ -0,0 +1,20 @@
+CMP0124
+-------
+
+.. versionadded:: 3.21
+
+The loop variables created by :command:`foreach` command have now their scope
+restricted to the loop scope.
+
+Starting with CMake 3.21, the :command:`foreach` command ensures that the loop
+variables have their scope restricted to the loop scope.
+
+The ``OLD`` behavior for this policy let the loop variables to exist, with an
+empty value, in the outer scope of loop scope.
+
+This policy was introduced in CMake version 3.21. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn when the policy
+is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0125.rst b/Help/policy/CMP0125.rst
new file mode 100644
index 000000000..19571dc25
--- /dev/null
+++ b/Help/policy/CMP0125.rst
@@ -0,0 +1,25 @@
+CMP0125
+-------
+
+.. versionadded:: 3.21
+
+The :command:`find_file`, :command:`find_path`, :command:`find_library` and
+:command:`find_program` commands handle cache variables in the same way
+regardless of whether they are defined on the command line, with or without a
+type, or using the :command:`set` command.
+
+Starting with CMake 3.21, the :command:`find_file`, :command:`find_path`,
+:command:`find_library`, and :command:`find_program` commands ensure that the
+cache variables will be used in the same way regardless how they were defined
+and the result will be always successful if the searched artifact exists.
+
+The ``OLD`` behavior for this policy is to have the find commands' behaviors
+differ depending on how the cache variable is defined. The ``NEW`` behavior for
+this policy is to have consistent behavior.
+
+This policy was introduced in CMake version 3.21. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn when the policy
+is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0126.rst b/Help/policy/CMP0126.rst
new file mode 100644
index 000000000..0ced8fa5a
--- /dev/null
+++ b/Help/policy/CMP0126.rst
@@ -0,0 +1,22 @@
+CMP0126
+-------
+
+.. versionadded:: 3.21
+
+The :command:`set(CACHE)` does not remove a normal variable of the same name.
+
+Starting with CMake 3.21, the :command:`set(CACHE)` does not remove, in the
+current scope, any normal variable with the same name.
+
+The ``OLD`` behavior for this policy is to have the :command:`set(CACHE)`
+command removing the normal variable of the same name, if any. The ``NEW``
+behavior for this policy is to keep the normal variable of the same name.
+
+This policy was introduced in CMake version 3.21. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn when the policy
+is not set and simply uses ``OLD`` behavior. See documentation of the
+:variable:`CMAKE_POLICY_WARNING_CMP0126 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
+variable to control the warning.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/prop_dir/BUILDSYSTEM_TARGETS.rst b/Help/prop_dir/BUILDSYSTEM_TARGETS.rst
index 5c5893dfc..c998488b4 100644
--- a/Help/prop_dir/BUILDSYSTEM_TARGETS.rst
+++ b/Help/prop_dir/BUILDSYSTEM_TARGETS.rst
@@ -11,3 +11,5 @@ and :command:`add_custom_target` commands. The list does not include any
:ref:`Interface Libraries`. Each entry in the list is the logical name
of a target, suitable to pass to the :command:`get_property` command
``TARGET`` option.
+
+See also the :prop_dir:`IMPORTED_TARGETS` directory property.
diff --git a/Help/prop_dir/IMPORTED_TARGETS.rst b/Help/prop_dir/IMPORTED_TARGETS.rst
new file mode 100644
index 000000000..fea8a93d4
--- /dev/null
+++ b/Help/prop_dir/IMPORTED_TARGETS.rst
@@ -0,0 +1,14 @@
+IMPORTED_TARGETS
+----------------
+
+.. versionadded:: 3.21
+
+This read-only directory property contains a
+:ref:`semicolon-separated list <CMake Language Lists>` of
+:ref:`Imported Targets` added in the directory by calls to the
+:command:`add_library` and :command:`add_executable` commands.
+Each entry in the list is the logical name of a target, suitable
+to pass to the :command:`get_property` command ``TARGET`` option
+when called in the same directory.
+
+See also the :prop_dir:`BUILDSYSTEM_TARGETS` directory property.
diff --git a/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst
index 2e3232062..07c732bd4 100644
--- a/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst
+++ b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst
@@ -3,15 +3,16 @@ AUTOGEN_SOURCE_GROUP
.. versionadded:: 3.9
-Name of the :command:`source_group` for :prop_tgt:`AUTOMOC` and
-:prop_tgt:`AUTORCC` generated files.
+Name of the :command:`source_group` for :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTORCC` and :prop_tgt:`AUTOUIC` generated files.
-Files generated by :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` are not always
-known at configure time and therefore can't be passed to
-:command:`source_group`.
-:prop_gbl:`AUTOGEN_SOURCE_GROUP` an be used instead to generate or select
-a source group for :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` generated files.
+Files generated by :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC` and
+:prop_tgt:`AUTOUIC` are not always known at configure time and therefore can't
+be passed to :command:`source_group`.
+:prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used instead to generate or select
+a source group for :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC` and
+:prop_tgt:`AUTOUIC` generated files.
-For :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` specific overrides see
-:prop_gbl:`AUTOMOC_SOURCE_GROUP` and :prop_gbl:`AUTORCC_SOURCE_GROUP`
-respectively.
+For :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC` and :prop_tgt:`AUTOUIC` specific
+overrides see :prop_gbl:`AUTOMOC_SOURCE_GROUP`, :prop_gbl:`AUTORCC_SOURCE_GROUP`
+and :prop_gbl:`AUTOUIC_SOURCE_GROUP` respectively.
diff --git a/Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst b/Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst
new file mode 100644
index 000000000..79ebfe0ec
--- /dev/null
+++ b/Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst
@@ -0,0 +1,9 @@
+AUTOUIC_SOURCE_GROUP
+--------------------
+
+.. versionadded:: 3.21
+
+Name of the :command:`source_group` for :prop_tgt:`AUTOUIC` generated files.
+
+When set this is used instead of :prop_gbl:`AUTOGEN_SOURCE_GROUP` for
+files generated by :prop_tgt:`AUTOUIC`.
diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
index 7166381aa..2bd0febea 100644
--- a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
+++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
@@ -24,6 +24,12 @@ The features known to this version of CMake are:
``c_std_11``
Compiler mode is at least C 11.
+``c_std_17``
+ Compiler mode is at least C 17.
+
+``c_std_23``
+ Compiler mode is at least C 23.
+
``c_function_prototypes``
Function prototypes, as defined in ``ISO/IEC 9899:1990``.
diff --git a/Help/prop_sf/COMPILE_FLAGS.rst b/Help/prop_sf/COMPILE_FLAGS.rst
index c211b89ac..eefe7bff3 100644
--- a/Help/prop_sf/COMPILE_FLAGS.rst
+++ b/Help/prop_sf/COMPILE_FLAGS.rst
@@ -4,8 +4,11 @@ COMPILE_FLAGS
Additional flags to be added when compiling this source file.
The ``COMPILE_FLAGS`` property, managed as a string, sets additional compiler
-flags used to build source files. Use :prop_sf:`COMPILE_DEFINITIONS` to pass
-additional preprocessor definitions.
+flags used that will be added to the list of compile flags when this source
+file builds. The flags will be added after target-wide flags (except in
+some cases not supported by the :generator:`Visual Studio 9 2008` generator).
+
+Use :prop_sf:`COMPILE_DEFINITIONS` to pass additional preprocessor definitions.
Contents of ``COMPILE_FLAGS`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
diff --git a/Help/prop_sf/COMPILE_OPTIONS.rst b/Help/prop_sf/COMPILE_OPTIONS.rst
index a694c3e61..84c543a2c 100644
--- a/Help/prop_sf/COMPILE_OPTIONS.rst
+++ b/Help/prop_sf/COMPILE_OPTIONS.rst
@@ -5,9 +5,10 @@ COMPILE_OPTIONS
List of additional options to pass to the compiler.
-This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
-and will be added to the list of compile flags when this
-source file builds.
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
+of options and will be added to the list of compile flags when this source
+file builds. The options will be added after target-wide options (except in
+some cases not supported by the :generator:`Visual Studio 9 2008` generator).
Contents of ``COMPILE_OPTIONS`` may use "generator expressions" with the
syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
diff --git a/Help/prop_sf/GENERATED.rst b/Help/prop_sf/GENERATED.rst
index 6ef458022..216dfe8da 100644
--- a/Help/prop_sf/GENERATED.rst
+++ b/Help/prop_sf/GENERATED.rst
@@ -32,9 +32,10 @@ The :ref:`Makefile Generators` will remove ``GENERATED`` files during
``make clean``.
Generated sources may be hidden in some IDE tools, while in others they might
-be shown. For the special case of sources generated by CMake's :prop_tgt:`AUTOMOC`
-or :prop_tgt:`AUTORCC` functionality, the :prop_gbl:`AUTOGEN_SOURCE_GROUP`,
-:prop_gbl:`AUTOMOC_SOURCE_GROUP` and :prop_gbl:`AUTORCC_SOURCE_GROUP` target
+be shown. For the special case of sources generated by CMake's :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTORCC` or :prop_tgt:`AUTOUIC` functionality, the
+:prop_gbl:`AUTOGEN_SOURCE_GROUP`, :prop_gbl:`AUTOMOC_SOURCE_GROUP`,
+:prop_gbl:`AUTORCC_SOURCE_GROUP` and :prop_gbl:`AUTOUIC_SOURCE_GROUP` target
properties may influence where the generated sources are grouped in the project's
file lists.
diff --git a/Help/prop_sf/LANGUAGE.rst b/Help/prop_sf/LANGUAGE.rst
index f14c176ca..a9b563870 100644
--- a/Help/prop_sf/LANGUAGE.rst
+++ b/Help/prop_sf/LANGUAGE.rst
@@ -6,8 +6,8 @@ Specify the programming language in which a source file is written.
A property that can be set to indicate what programming language the
source file is. If it is not set the language is determined based on
the file extension. Typical values are ``CXX`` (i.e. C++), ``C``,
-``CSharp``, ``CUDA``, ``Fortran``, ``ISPC``, and ``ASM``. Setting this
-property for a file means this file will be compiled. Do not set this
+``CSharp``, ``CUDA``, ``Fortran``, ``HIP``, ``ISPC``, and ``ASM``. Setting
+this property for a file means this file will be compiled. Do not set this
for headers or files that should not be compiled.
.. versionchanged:: 3.20
diff --git a/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst b/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst
index facf90255..1ec451760 100644
--- a/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst
+++ b/Help/prop_test/FAIL_REGULAR_EXPRESSION.rst
@@ -1,7 +1,8 @@
FAIL_REGULAR_EXPRESSION
-----------------------
-If the output matches this regular expression the test will fail.
+If the output matches this regular expression the test will fail,
+regardless of the process exit code.
If set, if the output matches one of specified regular expressions,
the test will fail. Example:
@@ -13,3 +14,6 @@ the test will fail. Example:
)
``FAIL_REGULAR_EXPRESSION`` expects a list of regular expressions.
+
+See also the :prop_test:`PASS_REGULAR_EXPRESSION` and
+:prop_test:`SKIP_REGULAR_EXPRESSION` test properties.
diff --git a/Help/prop_test/FIXTURES_REQUIRED.rst b/Help/prop_test/FIXTURES_REQUIRED.rst
index d92808a63..f85083069 100644
--- a/Help/prop_test/FIXTURES_REQUIRED.rst
+++ b/Help/prop_test/FIXTURES_REQUIRED.rst
@@ -35,9 +35,9 @@ The concept of a fixture is different to that of a resource specified by
set of tests which share setup and cleanup requirements, whereas a resource
lock has the effect of ensuring a particular set of tests do not run in
parallel. Some situations may need both, such as setting up a database,
-serialising test access to that database and deleting the database again at the
+serializing test access to that database and deleting the database again at the
end. For such cases, tests would populate both ``FIXTURES_REQUIRED`` and
-:prop_test:`RESOURCE_LOCK` to combine the two behaviours. Names used for
+:prop_test:`RESOURCE_LOCK` to combine the two behaviors. Names used for
:prop_test:`RESOURCE_LOCK` have no relationship with names of fixtures, so note
that a resource lock does not imply a fixture and vice versa.
diff --git a/Help/prop_test/PASS_REGULAR_EXPRESSION.rst b/Help/prop_test/PASS_REGULAR_EXPRESSION.rst
index 0cd621526..96468c02a 100644
--- a/Help/prop_test/PASS_REGULAR_EXPRESSION.rst
+++ b/Help/prop_test/PASS_REGULAR_EXPRESSION.rst
@@ -2,6 +2,7 @@ PASS_REGULAR_EXPRESSION
-----------------------
The output must match this regular expression for the test to pass.
+The process exit code is ignored.
If set, the test output will be checked against the specified regular
expressions and at least one of the regular expressions has to match,
@@ -14,3 +15,6 @@ otherwise the test will fail. Example:
)
``PASS_REGULAR_EXPRESSION`` expects a list of regular expressions.
+
+See also the :prop_test:`FAIL_REGULAR_EXPRESSION` and
+:prop_test:`SKIP_REGULAR_EXPRESSION` test properties.
diff --git a/Help/prop_test/SKIP_REGULAR_EXPRESSION.rst b/Help/prop_test/SKIP_REGULAR_EXPRESSION.rst
index 46c4363c4..60038e440 100644
--- a/Help/prop_test/SKIP_REGULAR_EXPRESSION.rst
+++ b/Help/prop_test/SKIP_REGULAR_EXPRESSION.rst
@@ -16,4 +16,6 @@ the test will be marked as skipped. Example:
``SKIP_REGULAR_EXPRESSION`` expects a list of regular expressions.
-See also the :prop_test:`SKIP_RETURN_CODE` property.
+See also the :prop_test:`SKIP_RETURN_CODE`,
+:prop_test:`PASS_REGULAR_EXPRESSION`, and :prop_test:`FAIL_REGULAR_EXPRESSION`
+test properties.
diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst
index 0cd683610..0fd6aac60 100644
--- a/Help/prop_tgt/COMPILE_OPTIONS.rst
+++ b/Help/prop_tgt/COMPILE_OPTIONS.rst
@@ -3,9 +3,13 @@ COMPILE_OPTIONS
List of options to pass to the compiler.
-This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
-specified so far for its target. Use the :command:`target_compile_options`
-command to append more options.
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
+of options specified so far for its target. Use the
+:command:`target_compile_options` command to append more options.
+The options will be added after after flags in the
+:variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>`
+variables, but before those propagated from dependencies by the
+:prop_tgt:`INTERFACE_COMPILE_OPTIONS` property.
This property is initialized by the :prop_dir:`COMPILE_OPTIONS` directory
property when a target is created, and is used by the generators to set
@@ -15,3 +19,5 @@ Contents of ``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)` manual
for more on defining buildsystem properties.
+
+.. include:: ../command/OPTIONS_SHELL.txt
diff --git a/Help/prop_tgt/CUDA_ARCHITECTURES.rst b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
index d56b76908..a3191e8e0 100644
--- a/Help/prop_tgt/CUDA_ARCHITECTURES.rst
+++ b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
@@ -25,7 +25,7 @@ Examples
.. code-block:: cmake
- set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 35 50 72)
+ set_target_properties(tgt PROPERTIES CUDA_ARCHITECTURES "35;50;72")
Generates code for real and virtual architectures ``30``, ``50`` and ``72``.
diff --git a/Help/prop_tgt/CUDA_STANDARD.rst b/Help/prop_tgt/CUDA_STANDARD.rst
index 6517035a2..5ef57be70 100644
--- a/Help/prop_tgt/CUDA_STANDARD.rst
+++ b/Help/prop_tgt/CUDA_STANDARD.rst
@@ -9,7 +9,29 @@ This property specifies the CUDA/C++ standard whose features are requested
to build this target. For some compilers, this results in adding a
flag such as ``-std=gnu++11`` to the compile line.
-Supported values are ``98``, ``03``, ``11``, ``14``, ``17``, ``20``, ``23``.
+Supported values are:
+
+``98``
+ CUDA C++98
+
+``11``
+ CUDA C++11
+
+``14``
+ CUDA C++14
+
+``17``
+ CUDA C++17
+
+``20``
+ .. versionadded:: 3.12
+
+ CUDA C++20
+
+``23``
+ .. versionadded:: 3.20
+
+ CUDA C++23
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst
index be0dab565..b10d20173 100644
--- a/Help/prop_tgt/CXX_STANDARD.rst
+++ b/Help/prop_tgt/CXX_STANDARD.rst
@@ -11,7 +11,31 @@ flag such as ``-std=gnu++11`` to the compile line. For compilers that
have no notion of a standard level, such as Microsoft Visual C++ before
2015 Update 3, this has no effect.
-Supported values are ``98``, ``11``, ``14``, ``17``, ``20``, ``23``.
+Supported values are:
+
+``98``
+ C++98
+
+``11``
+ C++11
+
+``14``
+ C++14
+
+``17``
+ .. versionadded:: 3.8
+
+ C++17
+
+``20``
+ .. versionadded:: 3.12
+
+ C++20
+
+``23``
+ .. versionadded:: 3.20
+
+ C++23
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
diff --git a/Help/prop_tgt/C_STANDARD.rst b/Help/prop_tgt/C_STANDARD.rst
index 3f0d242f4..ecba2a8f1 100644
--- a/Help/prop_tgt/C_STANDARD.rst
+++ b/Help/prop_tgt/C_STANDARD.rst
@@ -11,7 +11,26 @@ flag such as ``-std=gnu11`` to the compile line. For compilers that
have no notion of a C standard level, such as Microsoft Visual C++ before
VS 16.7, this property has no effect.
-Supported values are ``90``, ``99`` and ``11``.
+Supported values are:
+
+``90``
+ C89/C90
+
+``99``
+ C99
+
+``11``
+ C11
+
+``17``
+ .. versionadded:: 3.21
+
+ C17
+
+``23``
+ .. versionadded:: 3.21
+
+ C23
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
diff --git a/Help/prop_tgt/HIP_ARCHITECTURES.rst b/Help/prop_tgt/HIP_ARCHITECTURES.rst
new file mode 100644
index 000000000..06f956b18
--- /dev/null
+++ b/Help/prop_tgt/HIP_ARCHITECTURES.rst
@@ -0,0 +1,27 @@
+HIP_ARCHITECTURES
+-----------------
+
+.. versionadded:: 3.21
+
+List of AMD GPU architectures to generate device code for.
+
+A non-empty false value (e.g. ``OFF``) disables adding architectures.
+This is intended to support packagers and rare cases where full control
+over the passed flags is required.
+
+This property is initialized by the value of the :variable:`CMAKE_HIP_ARCHITECTURES`
+variable if it is set when a target is created.
+
+The HIP compilation model has two modes: whole and separable. Whole compilation
+generates device code at compile time. Separable compilation generates device
+code at link time. Therefore the ``HIP_ARCHITECTURES`` target property should
+be set on targets that compile or link with any HIP sources.
+
+Examples
+^^^^^^^^
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY HIP_ARCHITECTURES gfx801 gfx900)
+
+Generates code for both ``gfx801`` and ``gfx900``.
diff --git a/Help/prop_tgt/IMPORTED_OBJECTS.rst b/Help/prop_tgt/IMPORTED_OBJECTS.rst
index f3577eb99..d71c21999 100644
--- a/Help/prop_tgt/IMPORTED_OBJECTS.rst
+++ b/Help/prop_tgt/IMPORTED_OBJECTS.rst
@@ -68,26 +68,24 @@ architecture:
# /path/to/somewhere/objects-iphonesimulator/x86_64/func.o
In some cases, you may want to have configuration-specific object files
-as well. The :variable:`CMAKE_CFG_INTDIR` variable can be a convenient
-way of capturing this in combination with the SDK:
+as well. The ``$(CONFIGURATION)`` Xcode variable is often used for this and
+can be used in conjunction with the others mentioned above:
.. code-block:: cmake
add_library(someObjs OBJECT IMPORTED)
set_property(TARGET someObjs PROPERTY IMPORTED_OBJECTS
- "/path/to/somewhere/${CMAKE_CFG_INTDIR}/$(CURRENT_ARCH)/func.o"
+ "/path/to/somewhere/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/$(CURRENT_ARCH)/func.o"
)
# Example paths:
# /path/to/somewhere/Release-iphoneos/arm64/func.o
# /path/to/somewhere/Debug-iphonesimulator/x86_64/func.o
-When any Xcode variable or :variable:`CMAKE_CFG_INTDIR` is used, CMake is
-not able to fully evaluate the path(s) at configure time. One consequence
-of this is that the configuration-specific
-:prop_tgt:`IMPORTED_OBJECTS_<CONFIG>` properties cannot be used, since
-CMake cannot determine whether an object file exists at a particular
-``<CONFIG>`` location. The ``IMPORTED_OBJECTS`` property must be used for
-these situations and the configuration-specific aspects of the path must be
-handled by using :variable:`CMAKE_CFG_INTDIR` or with another Xcode variable
-``$(CONFIGURATION)``.
+When any Xcode variable is used, CMake is not able to fully evaluate the
+path(s) at configure time. One consequence of this is that the
+configuration-specific :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>` properties cannot
+be used, since CMake cannot determine whether an object file exists at a
+particular ``<CONFIG>`` location. The ``IMPORTED_OBJECTS`` property must be
+used for these situations and the configuration-specific aspects of the path
+should be handled by the ``$(CONFIGURATION)`` Xcode variable.
diff --git a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst
index 16be3cd1b..cba8ac98c 100644
--- a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst
+++ b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst
@@ -4,7 +4,7 @@
.. versionadded:: 3.4
This property is implemented only when ``<LANG>`` is ``C``, ``CXX``,
-``Fortran``, ``ISPC``, ``OBJC``, ``OBJCXX``, or ``CUDA``.
+``Fortran``, ``HIP``, ``ISPC``, ``OBJC``, ``OBJCXX``, or ``CUDA``.
Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command line
for a compiler launching tool. The :ref:`Makefile Generators` and the
diff --git a/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst b/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst
new file mode 100644
index 000000000..f6ca5ad43
--- /dev/null
+++ b/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst
@@ -0,0 +1,16 @@
+<LANG>_LINKER_LAUNCHER
+----------------------
+
+.. versionadded:: 3.21
+
+This property is implemented only when ``<LANG>`` is ``C``, ``CXX``,
+``OBJC``, or ``OBJCXX``
+
+Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a
+command line for a linker launching tool. The :ref:`Makefile Generators` and the
+:generator:`Ninja` generator will run this tool and pass the linker and its
+arguments to the tool. This is useful for tools such as static analyzers.
+
+This property is initialized by the value of the
+:variable:`CMAKE_<LANG>_LINKER_LAUNCHER` variable if it is set when a target is
+created.
diff --git a/Help/prop_tgt/LINK_DEPENDS_NO_SHARED.rst b/Help/prop_tgt/LINK_DEPENDS_NO_SHARED.rst
index 5c6778d24..dc2dc9e32 100644
--- a/Help/prop_tgt/LINK_DEPENDS_NO_SHARED.rst
+++ b/Help/prop_tgt/LINK_DEPENDS_NO_SHARED.rst
@@ -10,5 +10,6 @@ to re-link this target. Logical target-level dependencies will not be
affected so the linked shared libraries will still be brought up to
date before this target is built.
-This property is initialized by the value of the variable
-CMAKE_LINK_DEPENDS_NO_SHARED if it is set when a target is created.
+This property is initialized by the value of the
+:variable:`CMAKE_LINK_DEPENDS_NO_SHARED` variable if it is set when a
+target is created.
diff --git a/Help/prop_tgt/LINK_OPTIONS.rst b/Help/prop_tgt/LINK_OPTIONS.rst
index 8c0dfc426..27eadf92d 100644
--- a/Help/prop_tgt/LINK_OPTIONS.rst
+++ b/Help/prop_tgt/LINK_OPTIONS.rst
@@ -28,3 +28,9 @@ for more on defining buildsystem properties.
.. note::
This property must be used in preference to :prop_tgt:`LINK_FLAGS` property.
+
+.. include:: ../command/DEVICE_LINK_OPTIONS.txt
+
+.. include:: ../command/OPTIONS_SHELL.txt
+
+.. include:: ../command/LINK_OPTIONS_LINKER.txt
diff --git a/Help/prop_tgt/OBJCXX_STANDARD.rst b/Help/prop_tgt/OBJCXX_STANDARD.rst
index 96088af96..654e6877d 100644
--- a/Help/prop_tgt/OBJCXX_STANDARD.rst
+++ b/Help/prop_tgt/OBJCXX_STANDARD.rst
@@ -9,7 +9,27 @@ This property specifies the ObjC++ standard whose features are requested
to build this target. For some compilers, this results in adding a
flag such as ``-std=gnu++11`` to the compile line.
-Supported values are ``98``, ``11``, ``14``, ``17``, ``20``, ``23``.
+Supported values are:
+
+``98``
+ Objective C++98
+
+``11``
+ Objective C++11
+
+``14``
+ Objective C++14
+
+``17``
+ Objective C++17
+
+``20``
+ Objective C++20
+
+``23``
+ .. versionadded:: 3.20
+
+ Objective C++23
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
diff --git a/Help/prop_tgt/OBJC_STANDARD.rst b/Help/prop_tgt/OBJC_STANDARD.rst
index 2143ff92d..2d27bcf00 100644
--- a/Help/prop_tgt/OBJC_STANDARD.rst
+++ b/Help/prop_tgt/OBJC_STANDARD.rst
@@ -9,7 +9,16 @@ This property specifies the OBJC standard whose features are requested
to build this target. For some compilers, this results in adding a
flag such as ``-std=gnu11`` to the compile line.
-Supported values are ``90``, ``99`` and ``11``.
+Supported values are:
+
+``90``
+ Objective C89/C90
+
+``99``
+ Objective C99
+
+``11``
+ Objective C11
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
diff --git a/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst b/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst
index 2f4a3baab..f5d943723 100644
--- a/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst
+++ b/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst
@@ -20,3 +20,5 @@ for more on defining buildsystem properties.
This property must be used in preference to :prop_tgt:`STATIC_LIBRARY_FLAGS`
property.
+
+.. include:: ../command/OPTIONS_SHELL.txt
diff --git a/Help/prop_tgt/Swift_MODULE_DIRECTORY.rst b/Help/prop_tgt/Swift_MODULE_DIRECTORY.rst
index a6484f2fd..619377a11 100644
--- a/Help/prop_tgt/Swift_MODULE_DIRECTORY.rst
+++ b/Help/prop_tgt/Swift_MODULE_DIRECTORY.rst
@@ -9,4 +9,4 @@ If the target contains Swift source files, this specifies the directory in which
the modules will be placed. When this property is not set, the modules will be
placed in the build directory corresponding to the target's source directory.
If the variable :variable:`CMAKE_Swift_MODULE_DIRECTORY` is set when a target is
-created its value is used to initialise this property.
+created its value is used to initialize this property.
diff --git a/Help/prop_tgt/UNITY_BUILD_UNIQUE_ID.rst b/Help/prop_tgt/UNITY_BUILD_UNIQUE_ID.rst
index 2c95e027c..d288dd3b4 100644
--- a/Help/prop_tgt/UNITY_BUILD_UNIQUE_ID.rst
+++ b/Help/prop_tgt/UNITY_BUILD_UNIQUE_ID.rst
@@ -50,6 +50,6 @@ be used to avoid that with code like the following:
return MY_UNITY_ID::i;
}
-The pseudononymous namespace is used within a truly anonymous namespace.
+The pseudonymous namespace is used within a truly anonymous namespace.
On many platforms, this maintains the invariant that the symbols within
do not get external linkage when performing a unity build.
diff --git a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst
index 7b6812678..2a4d66672 100644
--- a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst
+++ b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst
@@ -6,3 +6,8 @@ XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY
Tell the :generator:`Xcode` generator to perform code signing for all the
frameworks and libraries that are embedded using the
:prop_tgt:`XCODE_EMBED_FRAMEWORKS <XCODE_EMBED_<type>>` property.
+
+.. versionadded:: 3.21
+
+This property was generalized to other types of embedded items. See
+:prop_tgt:`XCODE_EMBED_<type>_CODE_SIGN_ON_COPY` for the more general form.
diff --git a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst
index 29f8c5c03..04daa8559 100644
--- a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst
+++ b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst
@@ -6,3 +6,9 @@ XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY
Tell the :generator:`Xcode` generator to remove headers from all the
frameworks that are embedded using the
:prop_tgt:`XCODE_EMBED_FRAMEWORKS <XCODE_EMBED_<type>>` property.
+
+.. versionadded:: 3.21
+
+This property was generalized to other types of embedded items. See
+:prop_tgt:`XCODE_EMBED_<type>_REMOVE_HEADERS_ON_COPY` for the more
+general form.
diff --git a/Help/prop_tgt/XCODE_EMBED_type.rst b/Help/prop_tgt/XCODE_EMBED_type.rst
index 90c5bc787..a1af56f12 100644
--- a/Help/prop_tgt/XCODE_EMBED_type.rst
+++ b/Help/prop_tgt/XCODE_EMBED_type.rst
@@ -5,10 +5,20 @@ XCODE_EMBED_<type>
Tell the :generator:`Xcode` generator to embed the specified list of items into
the target bundle. ``<type>`` specifies the embed build phase to use.
+See the Xcode documentation for the base location of each ``<type>``.
+
+The supported values for ``<type>`` are:
+
+``FRAMEWORKS``
+ The specified items will be added to the ``Embed Frameworks`` build phase.
+ The items can be CMake target names or paths to frameworks or libraries.
+
+``APP_EXTENSIONS``
+ .. versionadded:: 3.21
+
+ The specified items will be added to the ``Embed App Extensions`` build phase.
+ They must be CMake target names.
-Currently, the only supported value for ``<type>`` is ``FRAMEWORKS``.
-The specified items will be added to the ``Embed Frameworks`` build phase.
-The items can be CMake target names or paths to frameworks or libraries.
See also :prop_tgt:`XCODE_EMBED_<type>_PATH`,
-:prop_tgt:`XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY` and
-:prop_tgt:`XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY`.
+:prop_tgt:`XCODE_EMBED_<type>_REMOVE_HEADERS_ON_COPY` and
+:prop_tgt:`XCODE_EMBED_<type>_CODE_SIGN_ON_COPY`.
diff --git a/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst
new file mode 100644
index 000000000..7ec03857b
--- /dev/null
+++ b/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst
@@ -0,0 +1,18 @@
+XCODE_EMBED_<type>_CODE_SIGN_ON_COPY
+------------------------------------
+
+.. versionadded:: 3.20
+
+Boolean property used only by the :generator:`Xcode` generator. It specifies
+whether to perform code signing for the items that are embedded using the
+:prop_tgt:`XCODE_EMBED_<type>` property.
+
+The supported values for ``<type>`` are:
+
+``FRAMEWORKS``
+
+``APP_EXTENSIONS``
+ .. versionadded:: 3.21
+
+If a ``XCODE_EMBED_<type>_CODE_SIGN_ON_COPY`` property is not defined on the
+target, no code signing on copy will be performed for that ``<type>``.
diff --git a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst
index 887cf5721..a6f980dcc 100644
--- a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst
+++ b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst
@@ -3,7 +3,16 @@ XCODE_EMBED_<type>_PATH
.. versionadded:: 3.20
-Tell the :generator:`Xcode` generator the relative path to use when embedding
-the items specified by :prop_tgt:`XCODE_EMBED_<type>`. The path is relative
+This property is used only by the :generator:`Xcode` generator. When defined,
+it specifies the relative path to use when embedding the items specified by
+:prop_tgt:`XCODE_EMBED_<type>`. The path is relative
to the base location of the ``Embed XXX`` build phase associated with
+``<type>``. See the Xcode documentation for the base location of each
``<type>``.
+
+The supported values for ``<type>`` are:
+
+``FRAMEWORKS``
+
+``APP_EXTENSIONS``
+ .. versionadded:: 3.21
diff --git a/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst
new file mode 100644
index 000000000..75c8eae13
--- /dev/null
+++ b/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst
@@ -0,0 +1,20 @@
+XCODE_EMBED_<type>_REMOVE_HEADERS_ON_COPY
+-----------------------------------------
+
+.. versionadded:: 3.20
+
+Boolean property used only by the :generator:`Xcode` generator. It specifies
+whether to remove headers from all the frameworks that are embedded using the
+:prop_tgt:`XCODE_EMBED_<type>` property.
+
+The supported values for ``<type>`` are:
+
+``FRAMEWORKS``
+ If the ``XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY`` property is not
+ defined, headers will not be removed on copy by default.
+
+``APP_EXTENSIONS``
+ .. versionadded:: 3.21
+
+ If the ``XCODE_EMBED_APP_EXTENSIONS_REMOVE_HEADERS_ON_COPY`` property is not
+ defined, headers WILL be removed on copy by default.
diff --git a/Help/release/3.15.rst b/Help/release/3.15.rst
index e68e7d38b..6b1a8007a 100644
--- a/Help/release/3.15.rst
+++ b/Help/release/3.15.rst
@@ -40,7 +40,7 @@ Languages
customize the Swift module name.
* The :prop_sf:`Swift_DIAGNOSTICS_FILE` source property was added to
- indicate where to write the serialised Swift diagnostics.
+ indicate where to write the serialized Swift diagnostics.
The Swift support is experimental, not considered stable, and may change
in future releases of CMake.
diff --git a/Help/release/3.16.rst b/Help/release/3.16.rst
index 84d96cdc8..28273a762 100644
--- a/Help/release/3.16.rst
+++ b/Help/release/3.16.rst
@@ -233,7 +233,7 @@ Deprecated and Removed Features
instead.
* The :module:`GetPrerequisites` module has been deprecated, as it has been
- superceded by :command:`file(GET_RUNTIME_DEPENDENCIES)`.
+ superseded by :command:`file(GET_RUNTIME_DEPENDENCIES)`.
* The ``CPACK_INSTALL_SCRIPT`` variable has been deprecated in favor of the
new, more accurately named :variable:`CPACK_INSTALL_SCRIPTS` variable.
diff --git a/Help/release/3.20.rst b/Help/release/3.20.rst
index 42e95beec..da27174d7 100644
--- a/Help/release/3.20.rst
+++ b/Help/release/3.20.rst
@@ -363,8 +363,8 @@ Changes made since CMake 3.20.0 include the following.
The oneAPI 2021.2 Fortran compiler defines the proper identification
macro and so is identified as ``IntelLLVM`` by all CMake 3.20 versions.
-3.20.3, 3.20.4, 3.20.5, 3.20.6
-------------------------------
+3.20.3, 3.20.4, 3.20.5
+----------------------
These versions made no changes to documented features or interfaces.
Some implementation updates were made to support ecosystem changes
diff --git a/Help/release/3.21.rst b/Help/release/3.21.rst
new file mode 100644
index 000000000..204880b7b
--- /dev/null
+++ b/Help/release/3.21.rst
@@ -0,0 +1,295 @@
+CMake 3.21 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.20 include the following.
+
+New Features
+============
+
+Presets
+-------
+
+* :manual:`cmake-presets(7)` gained support for specifying the install prefix
+ in a configure preset.
+
+* :manual:`cmake-presets(7)` gained support for conditional enabling of presets.
+
+* :manual:`cmake-presets(7)` gained support for a ``${hostSystemName}`` macro.
+
+* :manual:`cmake-presets(7)` gained support for omitting the ``generator`` and
+ ``binaryDir`` fields.
+
+Generators
+----------
+
+* The :generator:`Visual Studio 17 2022` generator was added. This is
+ experimental and based on "Visual Studio 2022 Preview 1.1" because this
+ version of VS has not been released.
+
+* The :ref:`Makefile Generators` and the :generator:`Ninja` generator
+ learned to add linker launcher tools along with the linker for ``C``,
+ ``CXX``, ``OBJC``, and ``OBJCXX`` languages.
+ See the :variable:`CMAKE_<LANG>_LINKER_LAUNCHER` variable
+ and :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property for details.
+
+Languages
+---------
+
+* CMake learned to support ``HIP`` as a first-class language that can be
+ enabled via the :command:`project` and :command:`enable_language` commands.
+
+* :prop_tgt:`C_STANDARD`, :prop_tgt:`OBJC_STANDARD`, and the
+ :manual:`Compile Features <cmake-compile-features(7)>` functionality gained
+ support for C17 and C23.
+
+* Source file extensions ``.ixx`` and ``.cppm`` are now treated as C++.
+
+Command-Line
+------------
+
+* :manual:`cmake(1)` gained the ``--install-prefix <dir>``
+ command-line option to specify the location of the install prefix.
+
+* :manual:`cmake(1)` gained the ``--toolchain <path/to/file>``
+ command-line option to specify a toolchain file.
+
+* :manual:`cmake(1)` ``-E capabilities`` output, for some generators,
+ may now contain a ``supportedPlatforms`` field listing platforms
+ known to be supported in :variable:`CMAKE_GENERATOR_PLATFORM`.
+
+* Messages printed to a terminal now may be colored by message type.
+
+Compilers
+---------
+
+* The Fujitsu compiler is now supported using compiler id ``Fujitsu``
+ in traditional (``Trad``) mode, and compiler id ``FujitsuClang``
+ in ``Clang`` mode.
+
+Platforms
+---------
+
+* CMake now supports the MSYS runtime environment, much like CYGWIN.
+
+File-Based API
+--------------
+
+* The :manual:`cmake-file-api(7)` "codemodel" version 2 ``version`` field
+ has been updated to 2.3.
+
+* The :manual:`cmake-file-api(7)` "codemodel" version 2 gained a
+ new "directory" object containing directory-level information.
+ This includes a list of installers generated by the :command:`install`
+ command.
+
+Commands
+--------
+
+* The :command:`add_custom_command` command ``DEPFILE`` option:
+
+ * may now use
+ :manual:`generator expressions <cmake-generator-expressions(7)>`,
+
+ * is now supported by :ref:`Visual Studio Generators` for VS 2012
+ and above, and
+
+ * is now supported by the :generator:`Xcode` generator.
+
+* The :command:`add_custom_command(TARGET)` command
+ (for :ref:`Build Events <add_custom_command(TARGET)>`)
+ gained support for resolving target-dependent generator expressions.
+
+* The :command:`build_command` command gained a ``PARALLEL_LEVEL`` option.
+
+* The :command:`file(COPY_FILE)` command was added to copy a single file.
+
+* The :command:`file(GET_RUNTIME_DEPENDENCIES)` command gained new
+ ``POST_INCLUDE_FILES`` and ``POST_EXCLUDE_FILES`` arguments.
+
+* The :command:`file(REAL_PATH)` command gained the option ``EXPAND_TILDE`` to
+ replace any leading tilde with the path to the user's home directory.
+
+* The :command:`file(RENAME)` command learned to optionally capture
+ failure in a result variable. It also gained a ``NO_REPLACE``
+ option to fail if the destination exists.
+
+* The :command:`install` command gained a new ``IMPORTED_RUNTIME_ARTIFACTS``
+ mode, which can be used to install the runtime artifacts of imported targets.
+
+* The :command:`install` command gained a new ``RUNTIME_DEPENDENCY_SET`` mode,
+ which can be used to install runtime dependencies using
+ :command:`file(GET_RUNTIME_DEPENDENCIES)`.
+
+* The :command:`install(TARGETS)` command gained new ``RUNTIME_DEPENDENCIES``
+ and ``RUNTIME_DEPENDENCY_SET`` arguments, which can be used to install
+ runtime dependencies using :command:`file(GET_RUNTIME_DEPENDENCIES)`.
+
+* The :command:`install(SCRIPT|CODE)` command
+ supports a new option ``ALL_COMPONENTS`` which allows
+ the corresponding code to run for every component of
+ a per component installation.
+
+* The :command:`project` command now sets variables
+ :variable:`PROJECT_IS_TOP_LEVEL` and :variable:`<PROJECT-NAME>_IS_TOP_LEVEL`
+ to indicate whether it was called in a top-level ``CMakeLists.txt`` file.
+
+Variables
+---------
+
+* The :envvar:`CMAKE_TOOLCHAIN_FILE` environment variable was added to
+ provide a default value for the :variable:`CMAKE_TOOLCHAIN_FILE` variable.
+
+Properties
+----------
+
+* The :prop_dir:`IMPORTED_TARGETS` directory property was added to
+ get a list of :ref:`Imported Targets` created in the current
+ directory.
+
+* The :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS <XCODE_EMBED_<type>>` target property
+ was added to tell the :generator:`Xcode` generator to embed app extensions
+ such as iMessage sticker packs.
+ Aspects of the embedding can be customized with the
+ :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_PATH <XCODE_EMBED_<type>>`,
+ :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_CODE_SIGN_ON_COPY <XCODE_EMBED_<type>_CODE_SIGN_ON_COPY>` and
+ :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_REMOVE_HEADERS_ON_COPY <XCODE_EMBED_<type>_REMOVE_HEADERS_ON_COPY>`
+ properties.
+
+Modules
+-------
+
+* The :module:`FindBLAS` and :module:`FindLAPACK` modules learned to support
+ the serial ``Fujitsu_SSL2`` and parallel ``Fujitsu_SSL2BLAMP`` libraries.
+
+* The :module:`FindDevIL` module now provides imported targets.
+
+* The :module:`FindIconv` module now has version support.
+
+* The :module:`FindIntl` module now has version support.
+
+* The :module:`FindMPI` module learned to support ``Fujitsu`` and
+ ``FujitsuClang`` in both host and cross compiling modes.
+
+* The :module:`FindMsys` module was added to find MSYS installations.
+ Like :module:`FindCygwin`, it is used automatically by some other
+ find modules to locate UNIX-style tools on Windows.
+
+* The :module:`FindOpenMP` module learned to support ``Fujitsu`` and
+ ``FujitsuClang``.
+
+* The :module:`FindVulkan` module gained imported targets
+ ``Vulkan::Headers`` and ``Vulkan::glslangValidator``.
+
+* The :module:`UseJava` module command ``add_jar`` gained a ``RESOURCES``
+ option to allow explicit naming of resources with non-optional namespace.
+
+* The :module:`UseSWIG` module use now standard library naming conventions
+ for the ``CSharp`` language. See policy :policy:`CMP0122`.
+
+* The :module:`UseSWIG` module now supports using the ``swig`` tool to
+ generate implicit dependencies with the :generator:`Xcode` generator.
+
+Generator Expressions
+---------------------
+
+* A new :genex:`TARGET_RUNTIME_DLLS` generator expression was added.
+
+CTest
+-----
+
+* :manual:`ctest(1)` gained documentation for its ability to capture
+ :ref:`Additional Test Measurements`.
+
+* :manual:`ctest(1)` learned to recognize files attached to a test at run time.
+ Previously it was only possible to attach files to tests at configure time
+ by using the :prop_test:`ATTACHED_FILES` or
+ :prop_test:`ATTACHED_FILES_ON_FAIL` test properties.
+ See :ref:`Additional Test Measurements` for more information.
+
+* :manual:`ctest(1)` gained a ``--output-junit`` option to write test results
+ to a JUnit XML file.
+
+* The :command:`ctest_build` command gained a ``PARALLEL_LEVEL`` option.
+
+CPack
+-----
+
+* The :cpack_gen:`CPack DragNDrop Generator` gained option
+ :variable:`CPACK_DMG_FILESYSTEM` to control the ``.dmg`` filesystem.
+
+* The :cpack_gen:`CPack IFW Generator` now supports hyphens in names
+ given to :command:`cpack_ifw_configure_component` or
+ :command:`cpack_ifw_configure_component_group` as ``DEPENDS`` or
+ ``DEPENDENCIES`` arguments. This requires QtIFW 3.1 or later.
+
+* The :cpack_gen:`CPack NSIS Generator` gained a new
+ :variable:`CPACK_NSIS_EXECUTABLE` variable to specify the ``makensis``
+ executable to use instead of the default one.
+
+* The :variable:`CPACK_CUSTOM_INSTALL_VARIABLES` variable was added to set
+ variables in ``cmake_install.cmake`` script invocations made by CPack.
+
+Deprecated and Removed Features
+===============================
+
+* Undocumented :variable:`CMAKE_SYSTEM_NAME` version-stripping behavior has
+ been removed entirely. If it is set by a ``-D`` flag or by a
+ :manual:`toolchain file <cmake-toolchains(7)>`, it is left unaltered,
+ even if it still contains a version number.
+ Similar :variable:`CMAKE_HOST_SYSTEM_NAME` version-stripping behavior,
+ also undocumented, has been moved earlier, before :command:`project` or
+ :command:`enable_language` is called.
+
+* ``ARMClang`` cpu/arch compile and link flags are no longer added
+ automatically based on the :variable:`CMAKE_SYSTEM_PROCESSOR`
+ variable or the undocumented ``CMAKE_SYSTEM_ARCH`` variable.
+ They must be specified explicitly. See policy :policy:`CMP0123`.
+
+Other Changes
+=============
+
+* The :command:`find_file`, :command:`find_path`, :command:`find_program`,
+ and :command:`find_library` commands handle cache variables in the same way
+ regardless how they are defined. See policy :policy:`CMP0125` for details.
+
+* The :command:`find_file`, :command:`find_path`, :command:`find_program`,
+ and :command:`find_library` commands gained the option ``NO_CACHE`` to store
+ find result in normal variable.
+
+* The :command:`foreach` command now isolates loop variables in the loop scope.
+ See policy :policy:`CMP0124` for details.
+
+* The :command:`list` command's ``GET``, ``INSERT``, ``SUBLIST``, and
+ ``REMOVE_AT`` subcommands now error with invalid (i.e., non-integer) values
+ are given as any of their index arguments based on the setting of policy
+ :policy:`CMP0121`.
+
+* The :command:`set(CACHE)` command no longer removes a normal variable
+ of the same name, if any. See policy :policy:`CMP0126`.
+
+* :command:`target_link_libraries` calls referencing object libraries
+ via the :genex:`TARGET_OBJECTS` generator expression now place the
+ object files before all libraries on the link line, regardless of
+ their specified order. See documentation on
+ :ref:`Linking Object Libraries via \$\<TARGET_OBJECTS\>` for details.
+
+* The :ref:`Ninja Generators` now pass source files and include directories
+ to the compiler using absolute paths. This makes diagnostic messages and
+ debug symbols more consistent, and matches the :ref:`Makefile Generators`.
+
+* The :generator:`NMake Makefiles` generator now encodes the generated
+ makefiles as UTF-8 with a BOM when using ``nmake`` from VS 9 or above.
+
+* The :ref:`Visual Studio Generators` for VS 2010 and above now place
+ per-source preprocessor definitions after target-wide preprocssor
+ definitions. This makes VS consistent with the :ref:`Ninja Generators`
+ and the :ref:`Makefile Generators`.
+
+* The precompiled binaries provided on
+ `cmake.org <https://cmake.org/download/>`_ now support
+ ``liblzma`` multi-threading. See the :variable:`CPACK_THREADS` and
+ :variable:`CPACK_ARCHIVE_THREADS` variables.
diff --git a/Help/release/3.6.rst b/Help/release/3.6.rst
index f0add07ff..b798f0d6e 100644
--- a/Help/release/3.6.rst
+++ b/Help/release/3.6.rst
@@ -170,7 +170,7 @@ CPack
is used for dependency auto detection.
* The :cpack_gen:`CPack DEB Generator` learned how to generate
- ``DEBIAN/shlibs`` contorl file when package contains shared libraries.
+ ``DEBIAN/shlibs`` control file when package contains shared libraries.
* The :cpack_gen:`CPack DEB Generator` learned how to generate
``DEBIAN/postinst`` and ``DEBIAN/postrm`` files if the package installs
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 95b41fb63..75667e54f 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -13,6 +13,7 @@ Releases
.. toctree::
:maxdepth: 1
+ 3.21 <3.21>
3.20 <3.20>
3.19 <3.19>
3.18 <3.18>
diff --git a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst
index 6c0c61b11..0b0b11414 100644
--- a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst
+++ b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst
@@ -8,7 +8,7 @@ Switch between strict and relaxed automoc mode.
By default, :prop_tgt:`AUTOMOC` behaves exactly as described in the
documentation of the :prop_tgt:`AUTOMOC` target property. When set to
``TRUE``, it accepts more input and tries to find the correct input file for
-``moc`` even if it differs from the documented behaviour. In this mode it
+``moc`` even if it differs from the documented behavior. In this mode it
e.g. also checks whether a header file is intended to be processed by moc
when a ``"foo.moc"`` file has been included.
diff --git a/Help/variable/CMAKE_CFG_INTDIR.rst b/Help/variable/CMAKE_CFG_INTDIR.rst
index 842654ec5..43668eaac 100644
--- a/Help/variable/CMAKE_CFG_INTDIR.rst
+++ b/Help/variable/CMAKE_CFG_INTDIR.rst
@@ -1,6 +1,12 @@
CMAKE_CFG_INTDIR
----------------
+.. deprecated:: 3.21
+
+ This variable has poor support on :generator:`Ninja Multi-Config`, and
+ predates the existence of the :genex:`$<CONFIG>` generator expression. Use
+ ``$<CONFIG>`` instead.
+
Build-time reference to per-configuration output subdirectory.
For native build systems supporting multiple configurations in the
@@ -19,11 +25,6 @@ Example values:
. = Ninja
${CONFIGURATION} = Ninja Multi-Config
-Note that this variable only has limited support on
-:generator:`Ninja Multi-Config`. It is recommended that you use the
-``$<CONFIG>`` :manual:`generator expression <cmake-generator-expressions(7)>`
-instead.
-
Since these values are evaluated by the native build system, this
variable is suitable only for use in command lines that will be
evaluated at build time. Example of intended usage:
diff --git a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
index 34e99ebf7..8fcc79869 100644
--- a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
+++ b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
@@ -6,5 +6,7 @@ Specifies the available build types on multi-config generators.
This specifies what build types (configurations) will be available
such as ``Debug``, ``Release``, ``RelWithDebInfo`` etc. This has reasonable
defaults on most platforms, but can be extended to provide other build
-types. See also :variable:`CMAKE_BUILD_TYPE` for details of managing
-configuration data, and :variable:`CMAKE_CFG_INTDIR`.
+types.
+
+See :variable:`CMAKE_BUILD_TYPE` for specifying the configuration with
+single-config generators.
diff --git a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst
index d5fcb7dbf..9817b1a12 100644
--- a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst
+++ b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst
@@ -23,3 +23,7 @@ is read-only and changes to it are undefined behavior.
:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``,
it does not make sense to set ``CMAKE_CUDA_HOST_COMPILER`` without also
setting ``CMAKE_CUDA_COMPILER`` to NVCC.
+
+.. note::
+
+ Ignored when using :ref:`Visual Studio Generators`.
diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
index 53ad2f3e7..45f2d3236 100644
--- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
+++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
@@ -63,3 +63,27 @@ Supported pairs are:
Specify an alternative ``VCTargetsPath`` value for Visual Studio
project files. This allows use of VS platform extension configuration
files (``.props`` and ``.targets``) that are not installed with VS.
+
+Visual Studio Toolset Customization
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+**These are unstable interfaces with no compatibility guarantees**
+because they hook into undocumented internal CMake implementation details.
+Institutions may use these to internally maintain support for non-public
+Visual Studio platforms and toolsets, but must accept responsibility to
+make updates as changes are made to CMake.
+
+Additional ``key=value`` pairs are available:
+
+``customFlagTableDir=<path>``
+ .. versionadded:: 3.21
+
+ Specify the absolute path to a directory from which to load custom
+ flag tables stored as JSON documents with file names of the form
+ ``<platform>_<toolset>_<tool>.json`` or ``<platform>_<tool>.json``,
+ where ``<platform>`` is the :variable:`CMAKE_VS_PLATFORM_NAME`,
+ ``<toolset>`` is the :variable:`CMAKE_VS_PLATFORM_TOOLSET`,
+ and ``<tool>`` is the tool for which the flag table is meant.
+ **This naming pattern is an internal CMake implementation detail.**
+ The ``<tool>`` names are undocumented. The format of the ``.json``
+ flag table files is undocumented.
diff --git a/Help/variable/CMAKE_HIP_ARCHITECTURES.rst b/Help/variable/CMAKE_HIP_ARCHITECTURES.rst
new file mode 100644
index 000000000..0cf020136
--- /dev/null
+++ b/Help/variable/CMAKE_HIP_ARCHITECTURES.rst
@@ -0,0 +1,11 @@
+CMAKE_HIP_ARCHITECTURES
+-----------------------
+
+.. versionadded:: 3.21
+
+Default value for :prop_tgt:`HIP_ARCHITECTURES` property of targets.
+
+This is initialized to the default architecture chosen by the compiler.
+
+This variable is used to initialize the :prop_tgt:`HIP_ARCHITECTURES` property
+on all targets. See the target property for additional information.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
index 89d9e2757..f23b7a214 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -19,6 +19,8 @@ include:
Cray = Cray Compiler (cray.com)
Embarcadero, Borland = Embarcadero (embarcadero.com)
Flang = Flang LLVM Fortran Compiler
+ Fujitsu = Fujitsu HPC compiler (Trad mode)
+ FujitsuClang = Fujitsu HPC compiler (Clang mode)
G95 = G95 Fortran (g95.org)
GNU = GNU Compiler Collection (gcc.gnu.org)
GHS = Green Hills Software (www.ghs.com)
@@ -32,6 +34,7 @@ include:
OpenWatcom = Open Watcom (openwatcom.org)
PGI = The Portland Group (pgroup.com)
PathScale = PathScale (pathscale.com)
+ ROCMClang = ROCm Toolkit Clang-based Compiler (rocmdocs.amd.com)
SDCC = Small Device C Compiler (sdcc.sourceforge.net)
SunPro = Oracle Solaris Studio (oracle.com)
TI = Texas Instruments (ti.com)
diff --git a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst
index 89fd7bcda..f16e59446 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst
@@ -6,7 +6,7 @@ CMAKE_<LANG>_COMPILER_LAUNCHER
Default value for :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property.
This variable is used to initialize the property on each target as it is
created. This is done only when ``<LANG>`` is ``C``, ``CXX``, ``Fortran``,
-``ISPC``, ``OBJC``, ``OBJCXX``, or ``CUDA``.
+``HIP``, ``ISPC``, ``OBJC``, ``OBJCXX``, or ``CUDA``.
This variable is initialized to the :envvar:`CMAKE_<LANG>_COMPILER_LAUNCHER`
environment variable if it is set.
diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst
index 14b2694ef..2784397ac 100644
--- a/Help/variable/CMAKE_LANG_FLAGS.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS.rst
@@ -15,3 +15,11 @@ This is initialized for each language from environment variables:
Initialized by the :envvar:`CUDAFLAGS` environment variable.
* ``CMAKE_Fortran_FLAGS``:
Initialized by the :envvar:`FFLAGS` environment variable.
+
+This value is a command-line string fragment. Therefore, multiple options
+should be separated by spaces, and options with spaces should be quoted.
+
+The flags in this variable will be passed to the compiler before those
+in the per-configuration :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variant,
+and before flags added by the :command:`add_compile_options` or
+:command:`target_compile_options` commands.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
index 628b62ba2..f0900fdc8 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
@@ -1,6 +1,9 @@
CMAKE_<LANG>_FLAGS_<CONFIG>
---------------------------
-.. versionadded:: 3.11
-
Flags for language ``<LANG>`` when building for the ``<CONFIG>`` configuration.
+
+The flags in this variable will be passed to the compiler after those
+in the :variable:`CMAKE_<LANG>_FLAGS` variable, but before flags added
+by the :command:`add_compile_options` or :command:`target_compile_options`
+commands.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst
index 67ff2cb3e..ca13a29a0 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst
@@ -12,6 +12,8 @@ the contents of a ``xxxFLAGS`` environment variable will be prepended,
where ``xxx`` will be language-specific but not necessarily the same as
``<LANG>`` (e.g. :envvar:`CXXFLAGS` for ``CXX``, :envvar:`FFLAGS` for
``Fortran``, and so on).
+This value is a command-line string fragment. Therefore, multiple options
+should be separated by spaces, and options with spaces should be quoted.
See also the configuration-specific
:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable.
diff --git a/Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst b/Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst
new file mode 100644
index 000000000..b76b9391b
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst
@@ -0,0 +1,11 @@
+CMAKE_<LANG>_LINKER_LAUNCHER
+----------------------------
+
+.. versionadded:: 3.21
+
+Default value for :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property. This
+variable is used to initialize the property on each target as it is created.
+This is done only when ``<LANG>`` is ``C``, ``CXX``, ``OBJC``, or ``OBJCXX``.
+
+This variable is initialized to the :envvar:`CMAKE_<LANG>_LINKER_LAUNCHER`
+environment variable if it is set.
diff --git a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst
index f466468d8..8d6b53369 100644
--- a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst
+++ b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst
@@ -2,4 +2,5 @@ CMAKE_MINIMUM_REQUIRED_VERSION
------------------------------
The ``<min>`` version of CMake given to the most recent call to the
-:command:`cmake_minimum_required(VERSION)` command.
+:command:`cmake_minimum_required(VERSION)` command in the current
+variable scope or any parent variable scope.
diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
index 9f68741a5..b991db2df 100644
--- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
+++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
@@ -29,6 +29,8 @@ warn by default:
policy :policy:`CMP0112`.
* ``CMAKE_POLICY_WARNING_CMP0116`` controls the warning for
policy :policy:`CMP0116`.
+* ``CMAKE_POLICY_WARNING_CMP0126`` controls the warning for
+ policy :policy:`CMP0126`.
This variable should not be set by a project in CMake code. Project
developers running CMake may set this variable in their cache to
diff --git a/Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst b/Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst
index 36949739f..6036c04bb 100644
--- a/Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst
+++ b/Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst
@@ -5,6 +5,6 @@ CMAKE_Swift_MODULE_DIRECTORY
Swift module output directory.
-This variable is used to initialise the :prop_tgt:`Swift_MODULE_DIRECTORY`
+This variable is used to initialize the :prop_tgt:`Swift_MODULE_DIRECTORY`
property on all the targets. See the target property for additional
information.
diff --git a/Help/variable/CMAKE_TLS_VERIFY.rst b/Help/variable/CMAKE_TLS_VERIFY.rst
new file mode 100644
index 000000000..24f8a256a
--- /dev/null
+++ b/Help/variable/CMAKE_TLS_VERIFY.rst
@@ -0,0 +1,17 @@
+CMAKE_TLS_VERIFY
+----------------
+
+Specify the default value for the :command:`file(DOWNLOAD)` and
+:command:`file(UPLOAD)` commands' ``TLS_VERIFY`` options.
+If not set, the default is *off*.
+
+This setting is also used by the :module:`ExternalProject` module
+for internal calls to :command:`file(DOWNLOAD)`.
+
+TLS verification can help provide confidence that one is connecting
+to the desired server. When downloading known content, one should
+also use file hashes to verify it.
+
+.. code-block:: cmake
+
+ set(CMAKE_TLS_VERIFY TRUE)
diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
index 168ee74c7..ff8d59a69 100644
--- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
+++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
@@ -7,3 +7,9 @@ This variable is specified on the command line when cross-compiling with CMake.
It is the path to a file which is read early in the CMake run and which
specifies locations for compilers and toolchain utilities, and other target
platform and compiler related information.
+
+Relative paths are allowed and are interpreted first as relative to the
+build directory, and if not found, relative to the source directory.
+
+This is initialized by the :envvar:`CMAKE_TOOLCHAIN_FILE` environment
+variable if it is set when a new build tree is first created.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
index 74db6b143..a19e7e148 100644
--- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
+++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
@@ -9,10 +9,9 @@ The :ref:`Visual Studio Generators` for VS 2010 and above support using
a standalone (non-installed) NVIDIA CUDA toolkit. The path
may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of
the form ``cuda=C:\path\to\cuda``. The given directory must at least
-contain a folder ``.\nvcc`` and must provide Visual Studio integration
-files in path ``.\CUDAVisualStudioIntegration\extras\
-visual_studio_integration\MSBuildExtensions\``. One can create a standalone
-CUDA toolkit directory by either opening a installer with 7zip or
-copying the files that are extracted by the running installer.
-The value may be empty if no path to a standalone CUDA Toolkit was
-specified.
+contain the nvcc compiler in path ``.\bin`` and must provide Visual Studio
+integration files in path ``.\extras\visual_studio_integration\
+MSBuildExtensions\``. One can create a standalone CUDA toolkit directory by
+either opening a installer with 7zip or copying the files that are extracted
+by the running installer. The value may be empty if no path to a standalone
+CUDA Toolkit was specified.
diff --git a/Help/variable/CPACK_CUSTOM_INSTALL_VARIABLES.rst b/Help/variable/CPACK_CUSTOM_INSTALL_VARIABLES.rst
new file mode 100644
index 000000000..1c070b8fa
--- /dev/null
+++ b/Help/variable/CPACK_CUSTOM_INSTALL_VARIABLES.rst
@@ -0,0 +1,44 @@
+CPACK_CUSTOM_INSTALL_VARIABLES
+------------------------------
+
+.. versionadded:: 3.21
+
+CPack variables (set via e.g. ``cpack -D``, ``CPackConfig.cmake`` or
+:variable:`CPACK_PROJECT_CONFIG_FILE` scripts) are not directly visible in
+installation scripts. Instead, one can pass a list of ``varName=value``
+pairs in the ``CPACK_CUSTOM_INSTALL_VARIABLES`` variable. At install time,
+each list item will result in a variable of the specified name (``varName``)
+being set to the given ``value``. The ``=`` can be omitted for an empty
+``value``.
+
+``CPACK_CUSTOM_INSTALL_VARIABLES`` allows the packaging installation to be
+influenced by the user or driving script at CPack runtime without having to
+regenerate the install scripts.
+
+Example
+"""""""
+
+.. code-block:: cmake
+
+ install(FILES large.txt DESTINATION data)
+
+ install(CODE [[
+ if(ENABLE_COMPRESSION)
+ # "run-compressor" is a fictional tool that produces
+ # large.txt.xz from large.txt and then removes the input file
+ execute_process(COMMAND run-compressor $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/large.txt)
+ endif()
+ ]])
+
+With the above example snippet, :manual:`cpack <cpack(1)>` will by default
+run the installation script with ``ENABLE_COMPRESSION`` unset, resulting in
+a package containing the uncompressed ``large.txt``. This can be overridden
+when invoking :manual:`cpack <cpack(1)>` like so:
+
+.. code-block:: shell
+
+ cpack -D "CPACK_CUSTOM_INSTALL_VARIABLES=ENABLE_COMPRESSION=TRUE"
+
+The installation script will then run with ``ENABLE_COMPRESSION`` set to
+``TRUE``, resulting in a package containing the compressed ``large.txt.xz``
+instead.
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
index 5aeae88a4..9f145c1a2 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
@@ -5,4 +5,7 @@ When saving a failing test's output, this is the maximum size, in bytes, that
will be collected by the :command:`ctest_test` command. Defaults to 307200
(300 KiB).
+If a test's output contains the literal string "CTEST_FULL_OUTPUT",
+the output will not be truncated and may exceed the maximum size.
+
.. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
index 1fbb8c53f..71ecf52bf 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
@@ -5,4 +5,7 @@ When saving a passing test's output, this is the maximum size, in bytes, that
will be collected by the :command:`ctest_test` command. Defaults to 1024
(1 KiB).
+If a test's output contains the literal string "CTEST_FULL_OUTPUT",
+the output will not be truncated and may exceed the maximum size.
+
.. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_SCRIPT_DIRECTORY.rst b/Help/variable/CTEST_SCRIPT_DIRECTORY.rst
new file mode 100644
index 000000000..77d4e58c9
--- /dev/null
+++ b/Help/variable/CTEST_SCRIPT_DIRECTORY.rst
@@ -0,0 +1,5 @@
+CTEST_SCRIPT_DIRECTORY
+----------------------
+
+The directory containing the top-level CTest script.
+The concept is similar to :variable:`CMAKE_SOURCE_DIR`.
diff --git a/Help/variable/EXECUTABLE_OUTPUT_PATH.rst b/Help/variable/EXECUTABLE_OUTPUT_PATH.rst
index 26d3e92a1..245b9eb26 100644
--- a/Help/variable/EXECUTABLE_OUTPUT_PATH.rst
+++ b/Help/variable/EXECUTABLE_OUTPUT_PATH.rst
@@ -3,6 +3,6 @@ EXECUTABLE_OUTPUT_PATH
Old executable location variable.
-The target property :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` supercedes this
+The target property :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` supersedes this
variable for a target if it is set. Executable targets are otherwise placed in
this directory.
diff --git a/Help/variable/MSVC_VERSION.rst b/Help/variable/MSVC_VERSION.rst
index 45df37fa0..241eb0384 100644
--- a/Help/variable/MSVC_VERSION.rst
+++ b/Help/variable/MSVC_VERSION.rst
@@ -20,5 +20,8 @@ Known version numbers are::
1910-1919 = VS 15.0 (v141 toolset)
1920-1929 = VS 16.0 (v142 toolset)
+..
+ 1930-1939 = VS 17.0 (v143 toolset)
+
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` and
:variable:`MSVC_TOOLSET_VERSION` variable.
diff --git a/Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst b/Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst
new file mode 100644
index 000000000..6718ecfd9
--- /dev/null
+++ b/Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst
@@ -0,0 +1,21 @@
+<PROJECT-NAME>_IS_TOP_LEVEL
+---------------------------
+
+.. versionadded:: 3.21
+
+A boolean variable indicating whether the named project was called in a top
+level ``CMakeLists.txt`` file.
+
+To obtain the value from the most recent call to :command:`project` in
+the current directory scope or above, see the
+:variable:`PROJECT_IS_TOP_LEVEL` variable.
+
+The variable value will be true in:
+
+* the top-level directory of the project
+* the top-level directory of an external project added by :module:`ExternalProject`
+
+The variable value will be false in:
+
+* a directory added by :command:`add_subdirectory`
+* a directory added by :module:`FetchContent`
diff --git a/Help/variable/PROJECT_IS_TOP_LEVEL.rst b/Help/variable/PROJECT_IS_TOP_LEVEL.rst
new file mode 100644
index 000000000..ad61fecc0
--- /dev/null
+++ b/Help/variable/PROJECT_IS_TOP_LEVEL.rst
@@ -0,0 +1,31 @@
+PROJECT_IS_TOP_LEVEL
+--------------------
+
+.. versionadded:: 3.21
+
+A boolean variable indicating whether :command:`project` was called in a top
+level ``CMakeLists.txt`` file.
+
+Some modules should only be included as part of the top level
+``CMakeLists.txt`` file to not cause unintended side effects in the build
+tree, and this variable can be used to conditionally execute such code. For
+example, consider the :module:`CTest` module, which creates targets and
+options:
+
+.. code-block:: cmake
+
+ project(MyProject)
+ ...
+ if(PROJECT_IS_TOP_LEVEL)
+ include(CTest)
+ endif()
+
+The variable value will be true in:
+
+* the top-level directory of the project
+* the top-level directory of an external project added by :module:`ExternalProject`
+
+The variable value will be false in:
+
+* a directory added by :command:`add_subdirectory`
+* a directory added by :module:`FetchContent`