Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- cmake/share/cmake-3.31/Help/command/DEPRECATED_POLICY_VERSIONS.txt +23 -0
- cmake/share/cmake-3.31/Help/command/DEVICE_LINK_OPTIONS.txt +12 -0
- cmake/share/cmake-3.31/Help/command/FIND_XXX.txt +253 -0
- cmake/share/cmake-3.31/Help/command/FIND_XXX_ORDER.txt +12 -0
- cmake/share/cmake-3.31/Help/command/FIND_XXX_REGISTRY_VIEW.txt +41 -0
- cmake/share/cmake-3.31/Help/command/FIND_XXX_ROOT.txt +29 -0
- cmake/share/cmake-3.31/Help/command/GENEX_NOTE.txt +6 -0
- cmake/share/cmake-3.31/Help/command/LINK_OPTIONS_LINKER.txt +25 -0
- cmake/share/cmake-3.31/Help/command/OPTIONS_SHELL.txt +15 -0
- cmake/share/cmake-3.31/Help/command/SUPPORTED_LANGUAGES.txt +25 -0
- cmake/share/cmake-3.31/Help/command/UNSET_NOTE.txt +9 -0
- cmake/share/cmake-3.31/Help/command/add_compile_definitions.rst +33 -0
- cmake/share/cmake-3.31/Help/command/add_compile_options.rst +67 -0
- cmake/share/cmake-3.31/Help/command/add_custom_command.rst +699 -0
- cmake/share/cmake-3.31/Help/command/add_custom_target.rst +211 -0
- cmake/share/cmake-3.31/Help/command/add_definitions.rst +38 -0
- cmake/share/cmake-3.31/Help/command/add_dependencies.rst +42 -0
- cmake/share/cmake-3.31/Help/command/add_executable.rst +123 -0
- cmake/share/cmake-3.31/Help/command/add_library.rst +302 -0
- cmake/share/cmake-3.31/Help/command/add_link_options.rst +44 -0
- cmake/share/cmake-3.31/Help/command/add_subdirectory.rst +32 -0
- cmake/share/cmake-3.31/Help/command/add_test.rst +117 -0
- cmake/share/cmake-3.31/Help/command/aux_source_directory.rst +24 -0
- cmake/share/cmake-3.31/Help/command/block.rst +77 -0
- cmake/share/cmake-3.31/Help/command/break.rst +12 -0
- cmake/share/cmake-3.31/Help/command/build_command.rst +51 -0
- cmake/share/cmake-3.31/Help/command/build_name.rst +15 -0
- cmake/share/cmake-3.31/Help/command/cmake_file_api.rst +78 -0
- cmake/share/cmake-3.31/Help/command/cmake_host_system_information.rst +403 -0
- cmake/share/cmake-3.31/Help/command/cmake_language.rst +536 -0
- cmake/share/cmake-3.31/Help/command/cmake_minimum_required.rst +88 -0
- cmake/share/cmake-3.31/Help/command/cmake_parse_arguments.rst +184 -0
- cmake/share/cmake-3.31/Help/command/cmake_path.rst +798 -0
- cmake/share/cmake-3.31/Help/command/cmake_pkg_config.rst +263 -0
- cmake/share/cmake-3.31/Help/command/cmake_policy.rst +159 -0
- cmake/share/cmake-3.31/Help/command/configure_file.rst +203 -0
- cmake/share/cmake-3.31/Help/command/continue.rst +16 -0
- cmake/share/cmake-3.31/Help/command/create_test_sourcelist.rst +62 -0
- cmake/share/cmake-3.31/Help/command/ctest_build.rst +93 -0
- cmake/share/cmake-3.31/Help/command/ctest_configure.rst +50 -0
- cmake/share/cmake-3.31/Help/command/ctest_coverage.rst +50 -0
- cmake/share/cmake-3.31/Help/command/ctest_empty_binary_directory.rst +12 -0
- cmake/share/cmake-3.31/Help/command/ctest_memcheck.rst +45 -0
- cmake/share/cmake-3.31/Help/command/ctest_read_custom_files.rst +14 -0
- cmake/share/cmake-3.31/Help/command/ctest_run_script.rst +15 -0
- cmake/share/cmake-3.31/Help/command/ctest_sleep.rst +16 -0
- cmake/share/cmake-3.31/Help/command/ctest_start.rst +88 -0
- cmake/share/cmake-3.31/Help/command/ctest_submit.rst +131 -0
- cmake/share/cmake-3.31/Help/command/ctest_test.rst +329 -0
- cmake/share/cmake-3.31/Help/command/ctest_update.rst +43 -0
cmake/share/cmake-3.31/Help/command/DEPRECATED_POLICY_VERSIONS.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. versionchanged:: 3.31
|
| 2 |
+
|
| 3 |
+
Compatibility with versions of CMake older than 3.10 is deprecated.
|
| 4 |
+
Calls to :command:`cmake_minimum_required(VERSION)` or
|
| 5 |
+
:command:`cmake_policy(VERSION)` that do not specify at least
|
| 6 |
+
3.10 as their policy version (optionally via ``...<max>``)
|
| 7 |
+
will produce a deprecation warning in CMake 3.31 and above.
|
| 8 |
+
|
| 9 |
+
.. versionchanged:: 3.27
|
| 10 |
+
|
| 11 |
+
Compatibility with versions of CMake older than 3.5 is deprecated.
|
| 12 |
+
Calls to :command:`cmake_minimum_required(VERSION)` or
|
| 13 |
+
:command:`cmake_policy(VERSION)` that do not specify at least
|
| 14 |
+
3.5 as their policy version (optionally via ``...<max>``)
|
| 15 |
+
will produce a deprecation warning in CMake 3.27 and above.
|
| 16 |
+
|
| 17 |
+
.. versionchanged:: 3.19
|
| 18 |
+
|
| 19 |
+
Compatibility with versions of CMake older than 2.8.12 is deprecated.
|
| 20 |
+
Calls to :command:`cmake_minimum_required(VERSION)` or
|
| 21 |
+
:command:`cmake_policy(VERSION)` that do not specify at least
|
| 22 |
+
2.8.12 as their policy version (optionally via ``...<max>``)
|
| 23 |
+
will produce a deprecation warning in CMake 3.19 and above.
|
cmake/share/cmake-3.31/Help/command/DEVICE_LINK_OPTIONS.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Host And Device Specific Link Options
|
| 2 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.18
|
| 5 |
+
When a device link step is involved, which is controlled by
|
| 6 |
+
:prop_tgt:`CUDA_SEPARABLE_COMPILATION` and
|
| 7 |
+
:prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` properties and policy :policy:`CMP0105`,
|
| 8 |
+
the raw options will be delivered to the host and device link steps (wrapped in
|
| 9 |
+
``-Xcompiler`` or equivalent for device link). Options wrapped with
|
| 10 |
+
:genex:`$<DEVICE_LINK:...>` generator expression will be used
|
| 11 |
+
only for the device link step. Options wrapped with :genex:`$<HOST_LINK:...>`
|
| 12 |
+
generator expression will be used only for the host link step.
|
cmake/share/cmake-3.31/Help/command/FIND_XXX.txt
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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S [path | ENV var]... ]
|
| 16 |
+
[REGISTRY_VIEW (64|32|64_32|32_64|HOST|TARGET|BOTH)]
|
| 17 |
+
[PATH_SUFFIXES suffix1 [suffix2 ...]]
|
| 18 |
+
[VALIDATOR function]
|
| 19 |
+
[DOC "cache documentation string"]
|
| 20 |
+
[NO_CACHE]
|
| 21 |
+
[REQUIRED]
|
| 22 |
+
[NO_DEFAULT_PATH]
|
| 23 |
+
[NO_PACKAGE_ROOT_PATH]
|
| 24 |
+
[NO_CMAKE_PATH]
|
| 25 |
+
[NO_CMAKE_ENVIRONMENT_PATH]
|
| 26 |
+
[NO_SYSTEM_ENVIRONMENT_PATH]
|
| 27 |
+
[NO_CMAKE_SYSTEM_PATH]
|
| 28 |
+
[NO_CMAKE_INSTALL_PREFIX]
|
| 29 |
+
[CMAKE_FIND_ROOT_PATH_BOTH |
|
| 30 |
+
ONLY_CMAKE_FIND_ROOT_PATH |
|
| 31 |
+
NO_CMAKE_FIND_ROOT_PATH]
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
This command is used to find a |SEARCH_XXX_DESC|.
|
| 35 |
+
A cache entry, or a normal variable if ``NO_CACHE`` is specified,
|
| 36 |
+
named by ``<VAR>`` is created to store the result of this command.
|
| 37 |
+
If the |SEARCH_XXX| is found the result is stored in the variable
|
| 38 |
+
and the search will not be repeated unless the variable is cleared.
|
| 39 |
+
If nothing is found, the result will be ``<VAR>-NOTFOUND``.
|
| 40 |
+
|
| 41 |
+
Options include:
|
| 42 |
+
|
| 43 |
+
``NAMES``
|
| 44 |
+
Specify one or more possible names for the |SEARCH_XXX|.
|
| 45 |
+
|
| 46 |
+
When using this to specify names with and without a version
|
| 47 |
+
suffix, we recommend specifying the unversioned name first
|
| 48 |
+
so that locally-built packages can be found before those
|
| 49 |
+
provided by distributions.
|
| 50 |
+
|
| 51 |
+
``HINTS``, ``PATHS``
|
| 52 |
+
Specify directories to search in addition to the default locations.
|
| 53 |
+
The ``ENV var`` sub-option reads paths from a system environment
|
| 54 |
+
variable.
|
| 55 |
+
|
| 56 |
+
.. versionchanged:: 3.24
|
| 57 |
+
On ``Windows`` platform, it is possible to include registry queries as part
|
| 58 |
+
of the directories, using a :ref:`dedicated syntax <Find Using Windows Registry>`.
|
| 59 |
+
Such specifications will be ignored on all other platforms.
|
| 60 |
+
|
| 61 |
+
``REGISTRY_VIEW``
|
| 62 |
+
.. versionadded:: 3.24
|
| 63 |
+
|
| 64 |
+
.. include:: FIND_XXX_REGISTRY_VIEW.txt
|
| 65 |
+
|
| 66 |
+
``PATH_SUFFIXES``
|
| 67 |
+
Specify additional subdirectories to check below each directory
|
| 68 |
+
location otherwise considered.
|
| 69 |
+
|
| 70 |
+
``VALIDATOR``
|
| 71 |
+
.. versionadded:: 3.25
|
| 72 |
+
|
| 73 |
+
Specify a :command:`function` to be called for each candidate item found
|
| 74 |
+
(a :command:`macro` cannot be provided, that will result in an error).
|
| 75 |
+
Two arguments will be passed to the validator function: the name of a
|
| 76 |
+
result variable, and the absolute path to the candidate item. The item
|
| 77 |
+
will be accepted and the search will end unless the function sets the
|
| 78 |
+
value in the result variable to false in the calling scope. The result
|
| 79 |
+
variable will hold a true value when the validator function is entered.
|
| 80 |
+
|
| 81 |
+
.. parsed-literal::
|
| 82 |
+
|
| 83 |
+
function(my_check validator_result_var item)
|
| 84 |
+
if(NOT item MATCHES ...)
|
| 85 |
+
set(${validator_result_var} FALSE PARENT_SCOPE)
|
| 86 |
+
endif()
|
| 87 |
+
endfunction()
|
| 88 |
+
|
| 89 |
+
|FIND_XXX| (result NAMES ... VALIDATOR my_check)
|
| 90 |
+
|
| 91 |
+
Note that if a cached result is used, the search is skipped and any
|
| 92 |
+
``VALIDATOR`` is ignored. The cached result is not required to pass the
|
| 93 |
+
validation function.
|
| 94 |
+
|
| 95 |
+
``DOC``
|
| 96 |
+
Specify the documentation string for the ``<VAR>`` cache entry.
|
| 97 |
+
|
| 98 |
+
``NO_CACHE``
|
| 99 |
+
.. versionadded:: 3.21
|
| 100 |
+
|
| 101 |
+
The result of the search will be stored in a normal variable rather than
|
| 102 |
+
a cache entry.
|
| 103 |
+
|
| 104 |
+
.. note::
|
| 105 |
+
|
| 106 |
+
If the variable is already set before the call (as a normal or cache
|
| 107 |
+
variable) then the search will not occur.
|
| 108 |
+
|
| 109 |
+
.. warning::
|
| 110 |
+
|
| 111 |
+
This option should be used with caution because it can greatly increase
|
| 112 |
+
the cost of repeated configure steps.
|
| 113 |
+
|
| 114 |
+
``REQUIRED``
|
| 115 |
+
.. versionadded:: 3.18
|
| 116 |
+
|
| 117 |
+
Stop processing with an error message if nothing is found, otherwise
|
| 118 |
+
the search will be attempted again the next time |FIND_XXX| is invoked
|
| 119 |
+
with the same variable.
|
| 120 |
+
|
| 121 |
+
If ``NO_DEFAULT_PATH`` is specified, then no additional paths are
|
| 122 |
+
added to the search.
|
| 123 |
+
If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
|
| 124 |
+
|
| 125 |
+
.. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR| replace::
|
| 126 |
+
|prefix_XXX_SUBDIR| for each ``<prefix>`` in the
|
| 127 |
+
:variable:`<PackageName>_ROOT` CMake variable and the
|
| 128 |
+
:envvar:`<PackageName>_ROOT` environment variable if
|
| 129 |
+
called from within a find module loaded by
|
| 130 |
+
:command:`find_package(<PackageName>)`
|
| 131 |
+
|
| 132 |
+
.. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace::
|
| 133 |
+
|prefix_XXX_SUBDIR| for each ``<prefix>`` in :variable:`CMAKE_PREFIX_PATH`
|
| 134 |
+
|
| 135 |
+
.. |ENV_CMAKE_PREFIX_PATH_XXX_SUBDIR| replace::
|
| 136 |
+
|prefix_XXX_SUBDIR| for each ``<prefix>`` in :envvar:`CMAKE_PREFIX_PATH`
|
| 137 |
+
|
| 138 |
+
.. |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR| replace::
|
| 139 |
+
|prefix_XXX_SUBDIR| for each ``<prefix>/[s]bin`` in ``PATH``, and
|
| 140 |
+
|entry_XXX_SUBDIR| for other entries in ``PATH``
|
| 141 |
+
|
| 142 |
+
.. |CMAKE_SYSTEM_PREFIX_PATH_XXX_SUBDIR| replace::
|
| 143 |
+
|prefix_XXX_SUBDIR| for each ``<prefix>`` in
|
| 144 |
+
:variable:`CMAKE_SYSTEM_PREFIX_PATH`
|
| 145 |
+
|
| 146 |
+
1. If called from within a find module or any other script loaded by a call to
|
| 147 |
+
:command:`find_package(<PackageName>)`, search prefixes unique to the
|
| 148 |
+
current package being found. See policy :policy:`CMP0074`.
|
| 149 |
+
|
| 150 |
+
.. versionadded:: 3.12
|
| 151 |
+
|
| 152 |
+
Specifically, search paths specified by the following variables, in order:
|
| 153 |
+
|
| 154 |
+
a. :variable:`<PackageName>_ROOT` CMake variable,
|
| 155 |
+
where ``<PackageName>`` is the case-preserved package name.
|
| 156 |
+
|
| 157 |
+
b. :variable:`<PACKAGENAME>_ROOT` CMake variable,
|
| 158 |
+
where ``<PACKAGENAME>`` is the upper-cased package name.
|
| 159 |
+
See policy :policy:`CMP0144`.
|
| 160 |
+
|
| 161 |
+
.. versionadded:: 3.27
|
| 162 |
+
|
| 163 |
+
c. :envvar:`<PackageName>_ROOT` environment variable,
|
| 164 |
+
where ``<PackageName>`` is the case-preserved package name.
|
| 165 |
+
|
| 166 |
+
d. :envvar:`<PACKAGENAME>_ROOT` environment variable,
|
| 167 |
+
where ``<PACKAGENAME>`` is the upper-cased package name.
|
| 168 |
+
See policy :policy:`CMP0144`.
|
| 169 |
+
|
| 170 |
+
.. versionadded:: 3.27
|
| 171 |
+
|
| 172 |
+
The package root variables are maintained as a stack, so if called from
|
| 173 |
+
nested find modules or config packages, root paths from the parent's find
|
| 174 |
+
module or config package will be searched after paths from the current
|
| 175 |
+
module or package. In other words, the search order would be
|
| 176 |
+
``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
|
| 177 |
+
``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
|
| 178 |
+
This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
|
| 179 |
+
the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
|
| 180 |
+
|
| 181 |
+
* |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX|
|
| 182 |
+
|
| 183 |
+
2. Search paths specified in cmake-specific cache variables.
|
| 184 |
+
These are intended to be used on the command line with a ``-DVAR=value``.
|
| 185 |
+
The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
|
| 186 |
+
This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
|
| 187 |
+
:variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``.
|
| 188 |
+
|
| 189 |
+
* |CMAKE_PREFIX_PATH_XXX|
|
| 190 |
+
* |CMAKE_XXX_PATH|
|
| 191 |
+
* |CMAKE_XXX_MAC_PATH|
|
| 192 |
+
|
| 193 |
+
3. Search paths specified in cmake-specific environment variables.
|
| 194 |
+
These are intended to be set in the user's shell configuration,
|
| 195 |
+
and therefore use the host's native path separator
|
| 196 |
+
(``;`` on Windows and ``:`` on UNIX).
|
| 197 |
+
This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or
|
| 198 |
+
by setting the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``.
|
| 199 |
+
|
| 200 |
+
* |ENV_CMAKE_PREFIX_PATH_XXX|
|
| 201 |
+
* |ENV_CMAKE_XXX_PATH|
|
| 202 |
+
* |ENV_CMAKE_XXX_MAC_PATH|
|
| 203 |
+
|
| 204 |
+
4. Search the paths specified by the ``HINTS`` option.
|
| 205 |
+
These should be paths computed by system introspection, such as a
|
| 206 |
+
hint provided by the location of another item already found.
|
| 207 |
+
Hard-coded guesses should be specified with the ``PATHS`` option.
|
| 208 |
+
|
| 209 |
+
5. Search the standard system environment variables.
|
| 210 |
+
This can be skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by
|
| 211 |
+
setting the :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``.
|
| 212 |
+
|
| 213 |
+
* |SYSTEM_ENVIRONMENT_PATH_XXX|
|
| 214 |
+
|
| 215 |
+
|SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX|
|
| 216 |
+
|
| 217 |
+
6. Search cmake variables defined in the Platform files
|
| 218 |
+
for the current system. The searching of ``CMAKE_INSTALL_PREFIX`` and
|
| 219 |
+
``CMAKE_STAGING_PREFIX`` can be
|
| 220 |
+
skipped if ``NO_CMAKE_INSTALL_PREFIX`` is passed or by setting the
|
| 221 |
+
:variable:`CMAKE_FIND_USE_INSTALL_PREFIX` to ``FALSE``. All these locations
|
| 222 |
+
can be skipped if ``NO_CMAKE_SYSTEM_PATH`` is passed or by setting the
|
| 223 |
+
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` to ``FALSE``.
|
| 224 |
+
|
| 225 |
+
* |CMAKE_SYSTEM_PREFIX_PATH_XXX|
|
| 226 |
+
* |CMAKE_SYSTEM_XXX_PATH|
|
| 227 |
+
* |CMAKE_SYSTEM_XXX_MAC_PATH|
|
| 228 |
+
|
| 229 |
+
The platform paths that these variables contain are locations that
|
| 230 |
+
typically include installed software. An example being ``/usr/local`` for
|
| 231 |
+
UNIX based platforms.
|
| 232 |
+
|
| 233 |
+
7. Search the paths specified by the PATHS option
|
| 234 |
+
or in the short-hand version of the command.
|
| 235 |
+
These are typically hard-coded guesses.
|
| 236 |
+
|
| 237 |
+
The :variable:`CMAKE_IGNORE_PATH`, :variable:`CMAKE_IGNORE_PREFIX_PATH`,
|
| 238 |
+
:variable:`CMAKE_SYSTEM_IGNORE_PATH` and
|
| 239 |
+
:variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` variables can also cause some
|
| 240 |
+
of the above locations to be ignored.
|
| 241 |
+
|
| 242 |
+
.. versionadded:: 3.16
|
| 243 |
+
Added ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable
|
| 244 |
+
various search locations.
|
| 245 |
+
|
| 246 |
+
.. |FIND_ARGS_XXX| replace:: <VAR> NAMES name
|
| 247 |
+
|
| 248 |
+
On macOS the :variable:`CMAKE_FIND_FRAMEWORK` and
|
| 249 |
+
:variable:`CMAKE_FIND_APPBUNDLE` variables determine the order of
|
| 250 |
+
preference between Apple-style and unix-style package components.
|
| 251 |
+
|
| 252 |
+
.. include:: FIND_XXX_ROOT.txt
|
| 253 |
+
.. include:: FIND_XXX_ORDER.txt
|
cmake/share/cmake-3.31/Help/command/FIND_XXX_ORDER.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The default search order is designed to be most-specific to
|
| 2 |
+
least-specific for common use cases.
|
| 3 |
+
Projects may override the order by simply calling the command
|
| 4 |
+
multiple times and using the ``NO_*`` options:
|
| 5 |
+
|
| 6 |
+
.. parsed-literal::
|
| 7 |
+
|
| 8 |
+
|FIND_XXX| (|FIND_ARGS_XXX| PATHS paths... NO_DEFAULT_PATH)
|
| 9 |
+
|FIND_XXX| (|FIND_ARGS_XXX|)
|
| 10 |
+
|
| 11 |
+
Once one of the calls succeeds the result variable will be set
|
| 12 |
+
and stored in the cache so that no call will search again.
|
cmake/share/cmake-3.31/Help/command/FIND_XXX_REGISTRY_VIEW.txt
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Specify which registry views must be queried. This option is only meaningful
|
| 2 |
+
on ``Windows`` platforms and will be ignored on other ones. When not
|
| 3 |
+
specified, the |FIND_XXX_REGISTRY_VIEW_DEFAULT| view is used when the
|
| 4 |
+
:policy:`CMP0134` policy is ``NEW``. Refer to :policy:`CMP0134` for the
|
| 5 |
+
default view when the policy is ``OLD``.
|
| 6 |
+
|
| 7 |
+
``64``
|
| 8 |
+
Query the 64-bit registry. On 32-bit Windows, it always returns the string
|
| 9 |
+
``/REGISTRY-NOTFOUND``.
|
| 10 |
+
|
| 11 |
+
``32``
|
| 12 |
+
Query the 32-bit registry.
|
| 13 |
+
|
| 14 |
+
``64_32``
|
| 15 |
+
Query both views (``64`` and ``32``) and generate a path for each.
|
| 16 |
+
|
| 17 |
+
``32_64``
|
| 18 |
+
Query both views (``32`` and ``64``) and generate a path for each.
|
| 19 |
+
|
| 20 |
+
``HOST``
|
| 21 |
+
Query the registry matching the architecture of the host: ``64`` on 64-bit
|
| 22 |
+
Windows and ``32`` on 32-bit Windows.
|
| 23 |
+
|
| 24 |
+
``TARGET``
|
| 25 |
+
Query the registry matching the architecture specified by the
|
| 26 |
+
:variable:`CMAKE_SIZEOF_VOID_P` variable. If not defined, fall back to
|
| 27 |
+
``HOST`` view.
|
| 28 |
+
|
| 29 |
+
``BOTH``
|
| 30 |
+
Query both views (``32`` and ``64``). The order depends on the following
|
| 31 |
+
rules: If the :variable:`CMAKE_SIZEOF_VOID_P` variable is defined, use the
|
| 32 |
+
following view depending on the content of this variable:
|
| 33 |
+
|
| 34 |
+
* ``8``: ``64_32``
|
| 35 |
+
* ``4``: ``32_64``
|
| 36 |
+
|
| 37 |
+
If the :variable:`CMAKE_SIZEOF_VOID_P` variable is not defined, rely on the
|
| 38 |
+
architecture of the host:
|
| 39 |
+
|
| 40 |
+
* 64-bit: ``64_32``
|
| 41 |
+
* 32-bit: ``32``
|
cmake/share/cmake-3.31/Help/command/FIND_XXX_ROOT.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The CMake variable :variable:`CMAKE_FIND_ROOT_PATH` specifies one or more
|
| 2 |
+
directories to be prepended to all other search directories. This
|
| 3 |
+
effectively "re-roots" the entire search under given locations.
|
| 4 |
+
Paths which are descendants of the :variable:`CMAKE_STAGING_PREFIX` are excluded
|
| 5 |
+
from this re-rooting, because that variable is always a path on the host system.
|
| 6 |
+
By default the :variable:`CMAKE_FIND_ROOT_PATH` is empty.
|
| 7 |
+
|
| 8 |
+
The :variable:`CMAKE_SYSROOT` variable can also be used to specify exactly one
|
| 9 |
+
directory to use as a prefix. Setting :variable:`CMAKE_SYSROOT` also has other
|
| 10 |
+
effects. See the documentation for that variable for more.
|
| 11 |
+
|
| 12 |
+
These variables are especially useful when cross-compiling to
|
| 13 |
+
point to the root directory of the target environment and CMake will
|
| 14 |
+
search there too. By default at first the directories listed in
|
| 15 |
+
:variable:`CMAKE_FIND_ROOT_PATH` are searched, then the :variable:`CMAKE_SYSROOT`
|
| 16 |
+
directory is searched, and then the non-rooted directories will be
|
| 17 |
+
searched. The default behavior can be adjusted by setting
|
| 18 |
+
|CMAKE_FIND_ROOT_PATH_MODE_XXX|. This behavior can be manually
|
| 19 |
+
overridden on a per-call basis using options:
|
| 20 |
+
|
| 21 |
+
``CMAKE_FIND_ROOT_PATH_BOTH``
|
| 22 |
+
Search in the order described above.
|
| 23 |
+
|
| 24 |
+
``NO_CMAKE_FIND_ROOT_PATH``
|
| 25 |
+
Do not use the :variable:`CMAKE_FIND_ROOT_PATH` variable.
|
| 26 |
+
|
| 27 |
+
``ONLY_CMAKE_FIND_ROOT_PATH``
|
| 28 |
+
Search only the re-rooted directories and directories below
|
| 29 |
+
:variable:`CMAKE_STAGING_PREFIX`.
|
cmake/share/cmake-3.31/Help/command/GENEX_NOTE.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. |more_see_also| replace:: See the :manual:`cmake-buildsystem(7)` manual
|
| 2 |
+
for more on defining buildsystem properties.
|
| 3 |
+
|
| 4 |
+
Arguments to |command_name| may use generator expressions
|
| 5 |
+
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
|
| 6 |
+
manual for available expressions. |more_see_also|
|
cmake/share/cmake-3.31/Help/command/LINK_OPTIONS_LINKER.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Handling Compiler Driver Differences
|
| 2 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 3 |
+
|
| 4 |
+
To pass options to the linker tool, each compiler driver has its own syntax.
|
| 5 |
+
The ``LINKER:`` prefix and ``,`` separator can be used to specify, in a portable
|
| 6 |
+
way, options to pass to the linker tool. ``LINKER:`` is replaced by the
|
| 7 |
+
appropriate driver option and ``,`` by the appropriate driver separator.
|
| 8 |
+
The driver prefix and driver separator are given by the values of the
|
| 9 |
+
:variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG` and
|
| 10 |
+
:variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG_SEP` variables.
|
| 11 |
+
|
| 12 |
+
For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for
|
| 13 |
+
``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``.
|
| 14 |
+
|
| 15 |
+
The ``LINKER:`` prefix can be specified as part of a ``SHELL:`` prefix
|
| 16 |
+
expression.
|
| 17 |
+
|
| 18 |
+
The ``LINKER:`` prefix supports, as an alternative syntax, specification of
|
| 19 |
+
arguments using the ``SHELL:`` prefix and space as separator. The previous
|
| 20 |
+
example then becomes ``"LINKER:SHELL:-z defs"``.
|
| 21 |
+
|
| 22 |
+
.. note::
|
| 23 |
+
|
| 24 |
+
Specifying the ``SHELL:`` prefix anywhere other than at the beginning of the
|
| 25 |
+
``LINKER:`` prefix is not supported.
|
cmake/share/cmake-3.31/Help/command/OPTIONS_SHELL.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Option De-duplication
|
| 2 |
+
^^^^^^^^^^^^^^^^^^^^^
|
| 3 |
+
|
| 4 |
+
The final set of options used for a target is constructed by
|
| 5 |
+
accumulating options from the current target and the usage requirements of
|
| 6 |
+
its dependencies. The set of options is de-duplicated to avoid repetition.
|
| 7 |
+
|
| 8 |
+
.. versionadded:: 3.12
|
| 9 |
+
While beneficial for individual options, the de-duplication step can break
|
| 10 |
+
up option groups. For example, ``-option A -option B`` becomes
|
| 11 |
+
``-option A B``. One may specify a group of options using shell-like
|
| 12 |
+
quoting along with a ``SHELL:`` prefix. The ``SHELL:`` prefix is dropped,
|
| 13 |
+
and the rest of the option string is parsed using the
|
| 14 |
+
:command:`separate_arguments` ``UNIX_COMMAND`` mode. For example,
|
| 15 |
+
``"SHELL:-option A" "SHELL:-option B"`` becomes ``-option A -option B``.
|
cmake/share/cmake-3.31/Help/command/SUPPORTED_LANGUAGES.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Supported languages are ``C``, ``CXX`` (i.e. C++), ``CSharp`` (i.e. C#), ``CUDA``,
|
| 3 |
+
``OBJC`` (i.e. Objective-C), ``OBJCXX`` (i.e. Objective-C++), ``Fortran``, ``HIP``,
|
| 4 |
+
``ISPC``, ``Swift``, ``ASM``, ``ASM_NASM``, ``ASM_MARMASM``, ``ASM_MASM``, and ``ASM-ATT``.
|
| 5 |
+
|
| 6 |
+
.. versionadded:: 3.8
|
| 7 |
+
Added ``CSharp`` and ``CUDA`` support.
|
| 8 |
+
|
| 9 |
+
.. versionadded:: 3.15
|
| 10 |
+
Added ``Swift`` support.
|
| 11 |
+
|
| 12 |
+
.. versionadded:: 3.16
|
| 13 |
+
Added ``OBJC`` and ``OBJCXX`` support.
|
| 14 |
+
|
| 15 |
+
.. versionadded:: 3.18
|
| 16 |
+
Added ``ISPC`` support.
|
| 17 |
+
|
| 18 |
+
.. versionadded:: 3.21
|
| 19 |
+
Added ``HIP`` support.
|
| 20 |
+
|
| 21 |
+
.. versionadded:: 3.26
|
| 22 |
+
Added ``ASM_MARMASM`` support.
|
| 23 |
+
|
| 24 |
+
If enabling ``ASM``, list it last so that CMake can check whether
|
| 25 |
+
compilers for other languages like ``C`` work for assembly too.
|
cmake/share/cmake-3.31/Help/command/UNSET_NOTE.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.. note::
|
| 2 |
+
|
| 3 |
+
When evaluating :ref:`Variable References` of the form ``${VAR}``, CMake
|
| 4 |
+
first searches for a normal variable with that name. If no such normal
|
| 5 |
+
variable exists, CMake will then search for a cache entry with that name.
|
| 6 |
+
Because of this, **unsetting a normal variable can expose a cache variable
|
| 7 |
+
that was previously hidden**. To force a variable reference of the form
|
| 8 |
+
``${VAR}`` to return an empty string, use ``set(<variable> "")``, which
|
| 9 |
+
clears the normal variable but leaves it defined.
|
cmake/share/cmake-3.31/Help/command/add_compile_definitions.rst
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_compile_definitions
|
| 2 |
+
-----------------------
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.12
|
| 5 |
+
|
| 6 |
+
Add preprocessor definitions to the compilation of source files.
|
| 7 |
+
|
| 8 |
+
.. code-block:: cmake
|
| 9 |
+
|
| 10 |
+
add_compile_definitions(<definition> ...)
|
| 11 |
+
|
| 12 |
+
Adds preprocessor definitions to the compiler command line.
|
| 13 |
+
|
| 14 |
+
The preprocessor definitions are added to the :prop_dir:`COMPILE_DEFINITIONS`
|
| 15 |
+
directory property for the current ``CMakeLists`` file. They are also added to
|
| 16 |
+
the :prop_tgt:`COMPILE_DEFINITIONS` target property for each target in the
|
| 17 |
+
current ``CMakeLists`` file.
|
| 18 |
+
|
| 19 |
+
Definitions are specified using the syntax ``VAR`` or ``VAR=value``.
|
| 20 |
+
Function-style definitions are not supported. CMake will automatically
|
| 21 |
+
escape the value correctly for the native build system (note that CMake
|
| 22 |
+
language syntax may require escapes to specify some values).
|
| 23 |
+
|
| 24 |
+
.. versionadded:: 3.26
|
| 25 |
+
Any leading ``-D`` on an item will be removed.
|
| 26 |
+
|
| 27 |
+
.. |command_name| replace:: ``add_compile_definitions``
|
| 28 |
+
.. include:: GENEX_NOTE.txt
|
| 29 |
+
|
| 30 |
+
See Also
|
| 31 |
+
^^^^^^^^
|
| 32 |
+
|
| 33 |
+
* The command :command:`target_compile_definitions` adds target-specific definitions.
|
cmake/share/cmake-3.31/Help/command/add_compile_options.rst
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_compile_options
|
| 2 |
+
-------------------
|
| 3 |
+
|
| 4 |
+
Add options to the compilation of source files.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
add_compile_options(<option> ...)
|
| 9 |
+
|
| 10 |
+
Adds options to the :prop_dir:`COMPILE_OPTIONS` directory property.
|
| 11 |
+
These options are used when compiling targets from the current
|
| 12 |
+
directory and below.
|
| 13 |
+
|
| 14 |
+
.. note::
|
| 15 |
+
|
| 16 |
+
These options are not used when linking.
|
| 17 |
+
See the :command:`add_link_options` command for that.
|
| 18 |
+
|
| 19 |
+
Arguments
|
| 20 |
+
^^^^^^^^^
|
| 21 |
+
|
| 22 |
+
.. |command_name| replace:: ``add_compile_options``
|
| 23 |
+
.. include:: GENEX_NOTE.txt
|
| 24 |
+
|
| 25 |
+
.. include:: OPTIONS_SHELL.txt
|
| 26 |
+
|
| 27 |
+
Example
|
| 28 |
+
^^^^^^^
|
| 29 |
+
|
| 30 |
+
Since different compilers support different options, a typical use of
|
| 31 |
+
this command is in a compiler-specific conditional clause:
|
| 32 |
+
|
| 33 |
+
.. code-block:: cmake
|
| 34 |
+
|
| 35 |
+
if (MSVC)
|
| 36 |
+
# warning level 4
|
| 37 |
+
add_compile_options(/W4)
|
| 38 |
+
else()
|
| 39 |
+
# additional warnings
|
| 40 |
+
add_compile_options(-Wall -Wextra -Wpedantic)
|
| 41 |
+
endif()
|
| 42 |
+
|
| 43 |
+
To set per-language options, use the :genex:`$<COMPILE_LANGUAGE>`
|
| 44 |
+
or :genex:`$<COMPILE_LANGUAGE:languages>` generator expressions.
|
| 45 |
+
|
| 46 |
+
See Also
|
| 47 |
+
^^^^^^^^
|
| 48 |
+
|
| 49 |
+
* This command can be used to add any options. However, for
|
| 50 |
+
adding preprocessor definitions and include directories it is recommended
|
| 51 |
+
to use the more specific commands :command:`add_compile_definitions`
|
| 52 |
+
and :command:`include_directories`.
|
| 53 |
+
|
| 54 |
+
* The command :command:`target_compile_options` adds target-specific options.
|
| 55 |
+
|
| 56 |
+
* This command adds compile options for all languages.
|
| 57 |
+
Use the :genex:`COMPILE_LANGUAGE` generator expression to specify
|
| 58 |
+
per-language compile options.
|
| 59 |
+
|
| 60 |
+
* The source file property :prop_sf:`COMPILE_OPTIONS` adds options to one
|
| 61 |
+
source file.
|
| 62 |
+
|
| 63 |
+
* :command:`add_link_options` adds options for linking.
|
| 64 |
+
|
| 65 |
+
* :variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>`
|
| 66 |
+
add language-wide flags passed to all invocations of the compiler.
|
| 67 |
+
This includes invocations that drive compiling and those that drive linking.
|
cmake/share/cmake-3.31/Help/command/add_custom_command.rst
ADDED
|
@@ -0,0 +1,699 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_custom_command
|
| 2 |
+
------------------
|
| 3 |
+
|
| 4 |
+
Add a custom build rule to the generated build system.
|
| 5 |
+
|
| 6 |
+
There are two main signatures for ``add_custom_command``.
|
| 7 |
+
|
| 8 |
+
.. _`add_custom_command(OUTPUT)`:
|
| 9 |
+
|
| 10 |
+
Generating Files
|
| 11 |
+
^^^^^^^^^^^^^^^^
|
| 12 |
+
|
| 13 |
+
The first signature is for adding a custom command to produce an output:
|
| 14 |
+
|
| 15 |
+
.. code-block:: cmake
|
| 16 |
+
|
| 17 |
+
add_custom_command(OUTPUT output1 [output2 ...]
|
| 18 |
+
COMMAND command1 [ARGS] [args1...]
|
| 19 |
+
[COMMAND command2 [ARGS] [args2...] ...]
|
| 20 |
+
[MAIN_DEPENDENCY depend]
|
| 21 |
+
[DEPENDS [depends...]]
|
| 22 |
+
[BYPRODUCTS [files...]]
|
| 23 |
+
[IMPLICIT_DEPENDS <lang1> depend1
|
| 24 |
+
[<lang2> depend2] ...]
|
| 25 |
+
[WORKING_DIRECTORY dir]
|
| 26 |
+
[COMMENT comment]
|
| 27 |
+
[DEPFILE depfile]
|
| 28 |
+
[JOB_POOL job_pool]
|
| 29 |
+
[JOB_SERVER_AWARE <bool>]
|
| 30 |
+
[VERBATIM] [APPEND] [USES_TERMINAL]
|
| 31 |
+
[CODEGEN]
|
| 32 |
+
[COMMAND_EXPAND_LISTS]
|
| 33 |
+
[DEPENDS_EXPLICIT_ONLY])
|
| 34 |
+
|
| 35 |
+
This defines a command to generate specified ``OUTPUT`` file(s).
|
| 36 |
+
A target created in the same directory (``CMakeLists.txt`` file)
|
| 37 |
+
that specifies any output of the custom command as a source file
|
| 38 |
+
is given a rule to generate the file using the command at build time.
|
| 39 |
+
|
| 40 |
+
Do not list the output in more than one independent target that
|
| 41 |
+
may build in parallel or the instances of the rule may conflict.
|
| 42 |
+
Instead, use the :command:`add_custom_target` command to drive the
|
| 43 |
+
command and make the other targets depend on that one. See the
|
| 44 |
+
`Example: Generating Files for Multiple Targets`_ below.
|
| 45 |
+
|
| 46 |
+
The options are:
|
| 47 |
+
|
| 48 |
+
``APPEND``
|
| 49 |
+
Append the ``COMMAND`` and ``DEPENDS`` option values to the custom
|
| 50 |
+
command for the first output specified. There must have already
|
| 51 |
+
been a previous call to this command with the same output.
|
| 52 |
+
|
| 53 |
+
If the previous call specified the output via a generator expression,
|
| 54 |
+
the output specified by the current call must match in at least one
|
| 55 |
+
configuration after evaluating generator expressions. In this case,
|
| 56 |
+
the appended commands and dependencies apply to all configurations.
|
| 57 |
+
|
| 58 |
+
The ``COMMENT``, ``MAIN_DEPENDENCY``, and ``WORKING_DIRECTORY``
|
| 59 |
+
options are currently ignored when ``APPEND`` is given, but may be
|
| 60 |
+
used in the future.
|
| 61 |
+
|
| 62 |
+
``BYPRODUCTS``
|
| 63 |
+
.. versionadded:: 3.2
|
| 64 |
+
|
| 65 |
+
Specify the files the command is expected to produce but whose
|
| 66 |
+
modification time may or may not be newer than the dependencies.
|
| 67 |
+
If a byproduct name is a relative path it will be interpreted
|
| 68 |
+
relative to the build tree directory corresponding to the
|
| 69 |
+
current source directory.
|
| 70 |
+
Each byproduct file will be marked with the :prop_sf:`GENERATED`
|
| 71 |
+
source file property automatically.
|
| 72 |
+
|
| 73 |
+
*See policy* :policy:`CMP0058` *for the motivation behind this feature.*
|
| 74 |
+
|
| 75 |
+
Explicit specification of byproducts is supported by the
|
| 76 |
+
:generator:`Ninja` generator to tell the ``ninja`` build tool
|
| 77 |
+
how to regenerate byproducts when they are missing. It is
|
| 78 |
+
also useful when other build rules (e.g. custom commands)
|
| 79 |
+
depend on the byproducts. Ninja requires a build rule for any
|
| 80 |
+
generated file on which another rule depends even if there are
|
| 81 |
+
order-only dependencies to ensure the byproducts will be
|
| 82 |
+
available before their dependents build.
|
| 83 |
+
|
| 84 |
+
The :ref:`Makefile Generators` will remove ``BYPRODUCTS`` and other
|
| 85 |
+
:prop_sf:`GENERATED` files during ``make clean``.
|
| 86 |
+
|
| 87 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 88 |
+
All byproducts must be set in the first call to
|
| 89 |
+
``add_custom_command(OUTPUT...)`` for the output files.
|
| 90 |
+
|
| 91 |
+
.. versionadded:: 3.20
|
| 92 |
+
Arguments to ``BYPRODUCTS`` may use a restricted set of
|
| 93 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 94 |
+
:ref:`Target-dependent expressions <Target-Dependent Expressions>`
|
| 95 |
+
are not permitted.
|
| 96 |
+
|
| 97 |
+
.. versionchanged:: 3.28
|
| 98 |
+
In targets using :ref:`file sets`, custom command byproducts are now
|
| 99 |
+
considered private unless they are listed in a non-private file set.
|
| 100 |
+
See policy :policy:`CMP0154`.
|
| 101 |
+
|
| 102 |
+
``COMMAND``
|
| 103 |
+
Specify the command-line(s) to execute at build time.
|
| 104 |
+
At least one ``COMMAND`` would normally be given, but certain patterns
|
| 105 |
+
may omit it, such as adding commands in separate calls using `APPEND`.
|
| 106 |
+
|
| 107 |
+
If more than one ``COMMAND`` is specified, they will be executed in order,
|
| 108 |
+
but *not* necessarily composed into a stateful shell or batch script.
|
| 109 |
+
To run a full script, use the :command:`configure_file` command or the
|
| 110 |
+
:command:`file(GENERATE)` command to create it, and then specify
|
| 111 |
+
a ``COMMAND`` to launch it.
|
| 112 |
+
|
| 113 |
+
The optional ``ARGS`` argument is for backward compatibility and
|
| 114 |
+
will be ignored.
|
| 115 |
+
|
| 116 |
+
If ``COMMAND`` specifies an executable target name (created by the
|
| 117 |
+
:command:`add_executable` command), it will automatically be replaced
|
| 118 |
+
by the location of the executable created at build time if either of
|
| 119 |
+
the following is true:
|
| 120 |
+
|
| 121 |
+
* The target is not being cross-compiled (i.e. the
|
| 122 |
+
:variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
|
| 123 |
+
* .. versionadded:: 3.6
|
| 124 |
+
The target is being cross-compiled and an emulator is provided (i.e.
|
| 125 |
+
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
|
| 126 |
+
In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
|
| 127 |
+
prepended to the command before the location of the target executable.
|
| 128 |
+
|
| 129 |
+
If neither of the above conditions are met, it is assumed that the
|
| 130 |
+
command name is a program to be found on the ``PATH`` at build time.
|
| 131 |
+
|
| 132 |
+
Arguments to ``COMMAND`` may use
|
| 133 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 134 |
+
Use the :genex:`TARGET_FILE` generator expression to refer to the location
|
| 135 |
+
of a target later in the command line (i.e. as a command argument rather
|
| 136 |
+
than as the command to execute).
|
| 137 |
+
|
| 138 |
+
Whenever one of the following target based generator expressions are used as
|
| 139 |
+
a command to execute or is mentioned in a command argument, a target-level
|
| 140 |
+
dependency will be added automatically so that the mentioned target will be
|
| 141 |
+
built before any target using this custom command
|
| 142 |
+
(see policy :policy:`CMP0112`).
|
| 143 |
+
|
| 144 |
+
* ``TARGET_FILE``
|
| 145 |
+
* ``TARGET_LINKER_FILE``
|
| 146 |
+
* ``TARGET_SONAME_FILE``
|
| 147 |
+
* ``TARGET_PDB_FILE``
|
| 148 |
+
|
| 149 |
+
This target-level dependency does NOT add a file-level dependency that would
|
| 150 |
+
cause the custom command to re-run whenever the executable is recompiled.
|
| 151 |
+
List target names with the ``DEPENDS`` option to add such file-level
|
| 152 |
+
dependencies.
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
``COMMENT``
|
| 156 |
+
Display the given message before the commands are executed at
|
| 157 |
+
build time. This will be ignored if ``APPEND`` is given, although a future
|
| 158 |
+
version may use it.
|
| 159 |
+
|
| 160 |
+
.. versionadded:: 3.26
|
| 161 |
+
Arguments to ``COMMENT`` may use
|
| 162 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 163 |
+
|
| 164 |
+
``DEPENDS``
|
| 165 |
+
Specify files on which the command depends. Each argument is converted
|
| 166 |
+
to a dependency as follows:
|
| 167 |
+
|
| 168 |
+
1. If the argument is the name of a target (created by the
|
| 169 |
+
:command:`add_custom_target`, :command:`add_executable`, or
|
| 170 |
+
:command:`add_library` command) a target-level dependency is
|
| 171 |
+
created to make sure the target is built before any target
|
| 172 |
+
using this custom command. Additionally, if the target is an
|
| 173 |
+
executable or library, a file-level dependency is created to
|
| 174 |
+
cause the custom command to re-run whenever the target is
|
| 175 |
+
recompiled.
|
| 176 |
+
|
| 177 |
+
2. If the argument is an absolute path, a file-level dependency
|
| 178 |
+
is created on that path.
|
| 179 |
+
|
| 180 |
+
3. If the argument is the name of a source file that has been
|
| 181 |
+
added to a target or on which a source file property has been set,
|
| 182 |
+
a file-level dependency is created on that source file.
|
| 183 |
+
|
| 184 |
+
4. If the argument is a relative path and it exists in the current
|
| 185 |
+
source directory, a file-level dependency is created on that
|
| 186 |
+
file in the current source directory.
|
| 187 |
+
|
| 188 |
+
5. Otherwise, a file-level dependency is created on that path relative
|
| 189 |
+
to the current binary directory.
|
| 190 |
+
|
| 191 |
+
If any dependency is an ``OUTPUT`` of another custom command in the same
|
| 192 |
+
directory (``CMakeLists.txt`` file), CMake automatically brings the other
|
| 193 |
+
custom command into the target in which this command is built.
|
| 194 |
+
|
| 195 |
+
.. versionadded:: 3.16
|
| 196 |
+
A target-level dependency is added if any dependency is listed as
|
| 197 |
+
``BYPRODUCTS`` of a target or any of its build events in the same
|
| 198 |
+
directory to ensure the byproducts will be available.
|
| 199 |
+
|
| 200 |
+
If ``DEPENDS`` is not specified, the command will run whenever
|
| 201 |
+
the ``OUTPUT`` is missing; if the command does not actually
|
| 202 |
+
create the ``OUTPUT``, the rule will always run.
|
| 203 |
+
|
| 204 |
+
.. versionadded:: 3.1
|
| 205 |
+
Arguments to ``DEPENDS`` may use
|
| 206 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 207 |
+
|
| 208 |
+
``COMMAND_EXPAND_LISTS``
|
| 209 |
+
.. versionadded:: 3.8
|
| 210 |
+
|
| 211 |
+
Lists in ``COMMAND`` arguments will be expanded, including those
|
| 212 |
+
created with
|
| 213 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`,
|
| 214 |
+
allowing ``COMMAND`` arguments such as
|
| 215 |
+
``${CC} "-I$<JOIN:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>,;-I>" foo.cc``
|
| 216 |
+
to be properly expanded.
|
| 217 |
+
|
| 218 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 219 |
+
If the appended commands need this option to be set, it must be set on the
|
| 220 |
+
first call to ``add_custom_command(OUTPUT...)`` for the output files.
|
| 221 |
+
|
| 222 |
+
``CODEGEN``
|
| 223 |
+
.. versionadded:: 3.31
|
| 224 |
+
|
| 225 |
+
Adds the custom command to a global ``codegen`` target that can be
|
| 226 |
+
used to execute the custom command while avoiding the majority of the
|
| 227 |
+
build graph.
|
| 228 |
+
|
| 229 |
+
This option is supported only by :ref:`Ninja Generators` and
|
| 230 |
+
:ref:`Makefile Generators`, and is ignored by other generators.
|
| 231 |
+
Furthermore, this option is allowed only if policy :policy:`CMP0171`
|
| 232 |
+
is set to ``NEW``.
|
| 233 |
+
|
| 234 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 235 |
+
It can only be set on the first call to ``add_custom_command(OUTPUT...)``
|
| 236 |
+
for the output files.
|
| 237 |
+
|
| 238 |
+
``IMPLICIT_DEPENDS``
|
| 239 |
+
Request scanning of implicit dependencies of an input file.
|
| 240 |
+
The language given specifies the programming language whose
|
| 241 |
+
corresponding dependency scanner should be used.
|
| 242 |
+
Currently only ``C`` and ``CXX`` language scanners are supported.
|
| 243 |
+
The language has to be specified for every file in the
|
| 244 |
+
``IMPLICIT_DEPENDS`` list. Dependencies discovered from the
|
| 245 |
+
scanning are added to those of the custom command at build time.
|
| 246 |
+
Note that the ``IMPLICIT_DEPENDS`` option is currently supported
|
| 247 |
+
only for Makefile generators and will be ignored by other generators.
|
| 248 |
+
|
| 249 |
+
.. note::
|
| 250 |
+
|
| 251 |
+
This option cannot be specified at the same time as ``DEPFILE`` option.
|
| 252 |
+
|
| 253 |
+
``JOB_POOL``
|
| 254 |
+
.. versionadded:: 3.15
|
| 255 |
+
|
| 256 |
+
Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
|
| 257 |
+
generator. Incompatible with ``USES_TERMINAL``, which implies
|
| 258 |
+
the ``console`` pool.
|
| 259 |
+
Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes
|
| 260 |
+
an error by ninja at build time.
|
| 261 |
+
|
| 262 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 263 |
+
Job pools can only be specified in the first call to
|
| 264 |
+
``add_custom_command(OUTPUT...)`` for the output files.
|
| 265 |
+
|
| 266 |
+
``JOB_SERVER_AWARE``
|
| 267 |
+
.. versionadded:: 3.28
|
| 268 |
+
|
| 269 |
+
Specify that the command is GNU Make job server aware.
|
| 270 |
+
|
| 271 |
+
For the :generator:`Unix Makefiles`, :generator:`MSYS Makefiles`, and
|
| 272 |
+
:generator:`MinGW Makefiles` generators this will add the ``+`` prefix to the
|
| 273 |
+
recipe line. See the `GNU Make Documentation`_ for more information.
|
| 274 |
+
|
| 275 |
+
This option is silently ignored by other generators.
|
| 276 |
+
|
| 277 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 278 |
+
Job server awareness can only be specified in the first call to
|
| 279 |
+
``add_custom_command(OUTPUT...)`` for the output files.
|
| 280 |
+
|
| 281 |
+
.. _`GNU Make Documentation`: https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html
|
| 282 |
+
|
| 283 |
+
``MAIN_DEPENDENCY``
|
| 284 |
+
Specify the primary input source file to the command. This is
|
| 285 |
+
treated just like any value given to the ``DEPENDS`` option
|
| 286 |
+
but also suggests to Visual Studio generators where to hang
|
| 287 |
+
the custom command. Each source file may have at most one command
|
| 288 |
+
specifying it as its main dependency. A compile command (i.e. for a
|
| 289 |
+
library or an executable) counts as an implicit main dependency which
|
| 290 |
+
gets silently overwritten by a custom command specification.
|
| 291 |
+
|
| 292 |
+
This option is currently ignored if ``APPEND`` is given, but a future
|
| 293 |
+
version may use it.
|
| 294 |
+
|
| 295 |
+
``OUTPUT``
|
| 296 |
+
Specify the output files the command is expected to produce.
|
| 297 |
+
Each output file will be marked with the :prop_sf:`GENERATED`
|
| 298 |
+
source file property automatically.
|
| 299 |
+
If the output of the custom command is not actually created
|
| 300 |
+
as a file on disk it should be marked with the :prop_sf:`SYMBOLIC`
|
| 301 |
+
source file property.
|
| 302 |
+
|
| 303 |
+
If an output file name is a relative path, its absolute path is
|
| 304 |
+
determined by interpreting it relative to:
|
| 305 |
+
|
| 306 |
+
1. the build directory corresponding to the current source directory
|
| 307 |
+
(:variable:`CMAKE_CURRENT_BINARY_DIR`), or
|
| 308 |
+
|
| 309 |
+
2. the current source directory (:variable:`CMAKE_CURRENT_SOURCE_DIR`).
|
| 310 |
+
|
| 311 |
+
The path in the build directory is preferred unless the path in the
|
| 312 |
+
source tree is mentioned as an absolute source file path elsewhere
|
| 313 |
+
in the current directory.
|
| 314 |
+
|
| 315 |
+
The output file path may not contain ``<`` or ``>`` characters.
|
| 316 |
+
|
| 317 |
+
.. versionadded:: 3.20
|
| 318 |
+
Arguments to ``OUTPUT`` may use a restricted set of
|
| 319 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 320 |
+
:ref:`Target-dependent expressions <Target-Dependent Expressions>`
|
| 321 |
+
are not permitted.
|
| 322 |
+
|
| 323 |
+
.. versionchanged:: 3.28
|
| 324 |
+
In targets using :ref:`file sets`, custom command outputs are now
|
| 325 |
+
considered private unless they are listed in a non-private file set.
|
| 326 |
+
See policy :policy:`CMP0154`.
|
| 327 |
+
|
| 328 |
+
.. versionchanged:: 3.30
|
| 329 |
+
The output file path may now use ``#`` characters, except
|
| 330 |
+
when using the :generator:`Borland Makefiles` generator.
|
| 331 |
+
|
| 332 |
+
``USES_TERMINAL``
|
| 333 |
+
.. versionadded:: 3.2
|
| 334 |
+
|
| 335 |
+
The command will be given direct access to the terminal if possible.
|
| 336 |
+
With the :generator:`Ninja` generator, this places the command in
|
| 337 |
+
the ``console`` :prop_gbl:`pool <JOB_POOLS>`.
|
| 338 |
+
|
| 339 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 340 |
+
If the appended commands need access to the terminal, it must be set on
|
| 341 |
+
the first call to ``add_custom_command(OUTPUT...)`` for the output files.
|
| 342 |
+
|
| 343 |
+
``VERBATIM``
|
| 344 |
+
All arguments to the commands will be escaped properly for the
|
| 345 |
+
build tool so that the invoked command receives each argument
|
| 346 |
+
unchanged. Note that one level of escapes is still used by the
|
| 347 |
+
CMake language processor before add_custom_command even sees the
|
| 348 |
+
arguments. Use of ``VERBATIM`` is recommended as it enables
|
| 349 |
+
correct behavior. When ``VERBATIM`` is not given the behavior
|
| 350 |
+
is platform specific because there is no protection of
|
| 351 |
+
tool-specific special characters.
|
| 352 |
+
|
| 353 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 354 |
+
If the appended commands need to be treated as ``VERBATIM``, it must be set
|
| 355 |
+
on the first call to ``add_custom_command(OUTPUT...)`` for the output files.
|
| 356 |
+
|
| 357 |
+
``WORKING_DIRECTORY``
|
| 358 |
+
Execute the command with the given current working directory.
|
| 359 |
+
If it is a relative path, it will be interpreted relative to the
|
| 360 |
+
build tree directory corresponding to the current source directory.
|
| 361 |
+
|
| 362 |
+
This option is currently ignored if ``APPEND`` is given, but a future
|
| 363 |
+
version may use it.
|
| 364 |
+
|
| 365 |
+
.. versionadded:: 3.13
|
| 366 |
+
Arguments to ``WORKING_DIRECTORY`` may use
|
| 367 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 368 |
+
|
| 369 |
+
``DEPFILE``
|
| 370 |
+
.. versionadded:: 3.7
|
| 371 |
+
|
| 372 |
+
Specify a depfile which holds dependencies for the custom command. It is
|
| 373 |
+
usually emitted by the custom command itself. This keyword may only be used
|
| 374 |
+
if the generator supports it, as detailed below.
|
| 375 |
+
|
| 376 |
+
The expected format, compatible with what is generated by ``gcc`` with the
|
| 377 |
+
option ``-M``, is independent of the generator or platform.
|
| 378 |
+
|
| 379 |
+
The formal syntax, as specified using
|
| 380 |
+
`BNF <https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form>`_ notation with
|
| 381 |
+
the regular extensions, is the following:
|
| 382 |
+
|
| 383 |
+
.. raw:: latex
|
| 384 |
+
|
| 385 |
+
\begin{small}
|
| 386 |
+
|
| 387 |
+
.. productionlist:: depfile
|
| 388 |
+
depfile: `rule`*
|
| 389 |
+
rule: `targets` (':' (`separator` `dependencies`?)?)? `eol`
|
| 390 |
+
targets: `target` (`separator` `target`)* `separator`*
|
| 391 |
+
target: `pathname`
|
| 392 |
+
dependencies: `dependency` (`separator` `dependency`)* `separator`*
|
| 393 |
+
dependency: `pathname`
|
| 394 |
+
separator: (`space` | `line_continue`)+
|
| 395 |
+
line_continue: '\' `eol`
|
| 396 |
+
space: ' ' | '\t'
|
| 397 |
+
pathname: `character`+
|
| 398 |
+
character: `std_character` | `dollar` | `hash` | `whitespace`
|
| 399 |
+
std_character: <any character except '$', '#' or ' '>
|
| 400 |
+
dollar: '$$'
|
| 401 |
+
hash: '\#'
|
| 402 |
+
whitespace: '\ '
|
| 403 |
+
eol: '\r'? '\n'
|
| 404 |
+
|
| 405 |
+
.. raw:: latex
|
| 406 |
+
|
| 407 |
+
\end{small}
|
| 408 |
+
|
| 409 |
+
.. note::
|
| 410 |
+
|
| 411 |
+
As part of ``pathname``, any slash and backslash is interpreted as
|
| 412 |
+
a directory separator.
|
| 413 |
+
|
| 414 |
+
.. versionadded:: 3.7
|
| 415 |
+
The :generator:`Ninja` generator supports ``DEPFILE`` since the keyword
|
| 416 |
+
was first added.
|
| 417 |
+
|
| 418 |
+
.. versionadded:: 3.17
|
| 419 |
+
Added the :generator:`Ninja Multi-Config` generator, which included
|
| 420 |
+
support for the ``DEPFILE`` keyword.
|
| 421 |
+
|
| 422 |
+
.. versionadded:: 3.20
|
| 423 |
+
Added support for :ref:`Makefile Generators`.
|
| 424 |
+
|
| 425 |
+
.. note::
|
| 426 |
+
|
| 427 |
+
``DEPFILE`` cannot be specified at the same time as the
|
| 428 |
+
``IMPLICIT_DEPENDS`` option for :ref:`Makefile Generators`.
|
| 429 |
+
|
| 430 |
+
.. versionadded:: 3.21
|
| 431 |
+
Added support for :ref:`Visual Studio Generators` with VS 2012 and above,
|
| 432 |
+
and for the :generator:`Xcode` generator. Support for
|
| 433 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>` was also
|
| 434 |
+
added.
|
| 435 |
+
|
| 436 |
+
.. versionadded:: 3.29
|
| 437 |
+
The :ref:`Ninja Generators` will now incorporate the dependencies into its
|
| 438 |
+
"deps log" database if the file is not listed in ``OUTPUTS`` or
|
| 439 |
+
``BYPRODUCTS``.
|
| 440 |
+
|
| 441 |
+
Using ``DEPFILE`` with generators other than those listed above is an error.
|
| 442 |
+
|
| 443 |
+
If the ``DEPFILE`` argument is relative, it should be relative to
|
| 444 |
+
:variable:`CMAKE_CURRENT_BINARY_DIR`, and any relative paths inside the
|
| 445 |
+
``DEPFILE`` should also be relative to :variable:`CMAKE_CURRENT_BINARY_DIR`.
|
| 446 |
+
See policy :policy:`CMP0116`, which is always ``NEW`` for
|
| 447 |
+
:ref:`Makefile Generators`, :ref:`Visual Studio Generators`,
|
| 448 |
+
and the :generator:`Xcode` generator.
|
| 449 |
+
|
| 450 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 451 |
+
Depfiles can only be set on the first call to
|
| 452 |
+
``add_custom_command(OUTPUT...)`` for the output files.
|
| 453 |
+
|
| 454 |
+
``DEPENDS_EXPLICIT_ONLY``
|
| 455 |
+
|
| 456 |
+
.. versionadded:: 3.27
|
| 457 |
+
|
| 458 |
+
Indicates that the command's ``DEPENDS`` argument represents all files
|
| 459 |
+
required by the command and implicit dependencies are not required.
|
| 460 |
+
|
| 461 |
+
Without this option, if any target uses the output of the custom command,
|
| 462 |
+
CMake will consider that target's dependencies as implicit dependencies for
|
| 463 |
+
the custom command in case this custom command requires files implicitly
|
| 464 |
+
created by those targets.
|
| 465 |
+
|
| 466 |
+
This option can be enabled on all custom commands by setting
|
| 467 |
+
:variable:`CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY` to ``ON``.
|
| 468 |
+
|
| 469 |
+
This keyword cannot be used with ``APPEND`` (see policy :policy:`CMP0175`).
|
| 470 |
+
It can only be set on the first call to ``add_custom_command(OUTPUT...)``
|
| 471 |
+
for the output files.
|
| 472 |
+
|
| 473 |
+
Only the :ref:`Ninja Generators` actually use this information to remove
|
| 474 |
+
unnecessary implicit dependencies.
|
| 475 |
+
|
| 476 |
+
See also the :prop_tgt:`OPTIMIZE_DEPENDENCIES` target property, which may
|
| 477 |
+
provide another way for reducing the impact of target dependencies in some
|
| 478 |
+
scenarios.
|
| 479 |
+
|
| 480 |
+
Examples: Generating Files
|
| 481 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 482 |
+
|
| 483 |
+
Custom commands may be used to generate source files.
|
| 484 |
+
For example, the code:
|
| 485 |
+
|
| 486 |
+
.. code-block:: cmake
|
| 487 |
+
|
| 488 |
+
add_custom_command(
|
| 489 |
+
OUTPUT out.c
|
| 490 |
+
COMMAND someTool -i ${CMAKE_CURRENT_SOURCE_DIR}/in.txt
|
| 491 |
+
-o out.c
|
| 492 |
+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/in.txt
|
| 493 |
+
VERBATIM)
|
| 494 |
+
add_library(myLib out.c)
|
| 495 |
+
|
| 496 |
+
adds a custom command to run ``someTool`` to generate ``out.c`` and then
|
| 497 |
+
compile the generated source as part of a library. The generation rule
|
| 498 |
+
will re-run whenever ``in.txt`` changes.
|
| 499 |
+
|
| 500 |
+
.. versionadded:: 3.20
|
| 501 |
+
One may use generator expressions to specify per-configuration outputs.
|
| 502 |
+
For example, the code:
|
| 503 |
+
|
| 504 |
+
.. code-block:: cmake
|
| 505 |
+
|
| 506 |
+
add_custom_command(
|
| 507 |
+
OUTPUT "out-$<CONFIG>.c"
|
| 508 |
+
COMMAND someTool -i ${CMAKE_CURRENT_SOURCE_DIR}/in.txt
|
| 509 |
+
-o "out-$<CONFIG>.c"
|
| 510 |
+
-c "$<CONFIG>"
|
| 511 |
+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/in.txt
|
| 512 |
+
VERBATIM)
|
| 513 |
+
add_library(myLib "out-$<CONFIG>.c")
|
| 514 |
+
|
| 515 |
+
adds a custom command to run ``someTool`` to generate ``out-<config>.c``,
|
| 516 |
+
where ``<config>`` is the build configuration, and then compile the generated
|
| 517 |
+
source as part of a library.
|
| 518 |
+
|
| 519 |
+
.. versionadded:: 3.31
|
| 520 |
+
Use the ``CODEGEN`` option to add a custom command's outputs to the builtin
|
| 521 |
+
``codegen`` target. This is useful to make generated code available for
|
| 522 |
+
static analysis without building the entire project. For example:
|
| 523 |
+
|
| 524 |
+
.. code-block:: cmake
|
| 525 |
+
|
| 526 |
+
add_executable(someTool someTool.c)
|
| 527 |
+
|
| 528 |
+
add_custom_command(
|
| 529 |
+
OUTPUT out.c
|
| 530 |
+
COMMAND someTool -o out.c
|
| 531 |
+
CODEGEN)
|
| 532 |
+
|
| 533 |
+
add_library(myLib out.c)
|
| 534 |
+
|
| 535 |
+
A user may build the ``codegen`` target to generate ``out.c``.
|
| 536 |
+
``someTool`` is built as dependency, but ``myLib`` is not built at all.
|
| 537 |
+
|
| 538 |
+
Example: Generating Files for Multiple Targets
|
| 539 |
+
""""""""""""""""""""""""""""""""""""""""""""""
|
| 540 |
+
|
| 541 |
+
If multiple independent targets need the same custom command output,
|
| 542 |
+
it must be attached to a single custom target on which they all depend.
|
| 543 |
+
Consider the following example:
|
| 544 |
+
|
| 545 |
+
.. code-block:: cmake
|
| 546 |
+
|
| 547 |
+
add_custom_command(
|
| 548 |
+
OUTPUT table.csv
|
| 549 |
+
COMMAND makeTable -i ${CMAKE_CURRENT_SOURCE_DIR}/input.dat
|
| 550 |
+
-o table.csv
|
| 551 |
+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/input.dat
|
| 552 |
+
VERBATIM)
|
| 553 |
+
add_custom_target(generate_table_csv DEPENDS table.csv)
|
| 554 |
+
|
| 555 |
+
add_custom_command(
|
| 556 |
+
OUTPUT foo.cxx
|
| 557 |
+
COMMAND genFromTable -i table.csv -case foo -o foo.cxx
|
| 558 |
+
DEPENDS table.csv # file-level dependency
|
| 559 |
+
generate_table_csv # target-level dependency
|
| 560 |
+
VERBATIM)
|
| 561 |
+
add_library(foo foo.cxx)
|
| 562 |
+
|
| 563 |
+
add_custom_command(
|
| 564 |
+
OUTPUT bar.cxx
|
| 565 |
+
COMMAND genFromTable -i table.csv -case bar -o bar.cxx
|
| 566 |
+
DEPENDS table.csv # file-level dependency
|
| 567 |
+
generate_table_csv # target-level dependency
|
| 568 |
+
VERBATIM)
|
| 569 |
+
add_library(bar bar.cxx)
|
| 570 |
+
|
| 571 |
+
Output ``foo.cxx`` is needed only by target ``foo`` and output ``bar.cxx``
|
| 572 |
+
is needed only by target ``bar``, but *both* targets need ``table.csv``,
|
| 573 |
+
transitively. Since ``foo`` and ``bar`` are independent targets that may
|
| 574 |
+
build concurrently, we prevent them from racing to generate ``table.csv``
|
| 575 |
+
by placing its custom command in a separate target, ``generate_table_csv``.
|
| 576 |
+
The custom commands generating ``foo.cxx`` and ``bar.cxx`` each specify a
|
| 577 |
+
target-level dependency on ``generate_table_csv``, so the targets using them,
|
| 578 |
+
``foo`` and ``bar``, will not build until after target ``generate_table_csv``
|
| 579 |
+
is built.
|
| 580 |
+
|
| 581 |
+
.. _`add_custom_command(TARGET)`:
|
| 582 |
+
|
| 583 |
+
Build Events
|
| 584 |
+
^^^^^^^^^^^^
|
| 585 |
+
|
| 586 |
+
The second signature adds a custom command to a target such as a
|
| 587 |
+
library or executable. This is useful for performing an operation
|
| 588 |
+
before or after building the target. The command becomes part of the
|
| 589 |
+
target and will only execute when the target itself is built. If the
|
| 590 |
+
target is already built, the command will not execute.
|
| 591 |
+
|
| 592 |
+
.. code-block:: cmake
|
| 593 |
+
|
| 594 |
+
add_custom_command(TARGET <target>
|
| 595 |
+
PRE_BUILD | PRE_LINK | POST_BUILD
|
| 596 |
+
COMMAND command1 [ARGS] [args1...]
|
| 597 |
+
[COMMAND command2 [ARGS] [args2...] ...]
|
| 598 |
+
[BYPRODUCTS [files...]]
|
| 599 |
+
[WORKING_DIRECTORY dir]
|
| 600 |
+
[COMMENT comment]
|
| 601 |
+
[VERBATIM]
|
| 602 |
+
[COMMAND_EXPAND_LISTS]
|
| 603 |
+
[USES_TERMINAL])
|
| 604 |
+
|
| 605 |
+
This defines a new command that will be associated with building the
|
| 606 |
+
specified ``<target>``. The ``<target>`` must be defined in the current
|
| 607 |
+
directory; targets defined in other directories may not be specified.
|
| 608 |
+
|
| 609 |
+
When the command will happen is determined by which
|
| 610 |
+
of the following is specified:
|
| 611 |
+
|
| 612 |
+
``PRE_BUILD``
|
| 613 |
+
This option has unique behavior for the :ref:`Visual Studio Generators`.
|
| 614 |
+
When using one of the Visual Studio generators, the command will run before
|
| 615 |
+
any other rules are executed within the target. With all other generators,
|
| 616 |
+
this option behaves the same as ``PRE_LINK`` instead. Because of this,
|
| 617 |
+
it is recommended to avoid using ``PRE_BUILD`` except when it is known that
|
| 618 |
+
a Visual Studio generator is being used.
|
| 619 |
+
``PRE_LINK``
|
| 620 |
+
Run after sources have been compiled but before linking the binary
|
| 621 |
+
or running the librarian or archiver tool of a static library.
|
| 622 |
+
This is not defined for targets created by the
|
| 623 |
+
:command:`add_custom_target` command.
|
| 624 |
+
``POST_BUILD``
|
| 625 |
+
Run after all other rules within the target have been executed.
|
| 626 |
+
|
| 627 |
+
Projects should always specify one of the above three keywords when using
|
| 628 |
+
the ``TARGET`` form. See policy :policy:`CMP0175`.
|
| 629 |
+
|
| 630 |
+
All other keywords shown in the signature above have the same meaning as they
|
| 631 |
+
do for the :command:`add_custom_command(OUTPUT)` form of the command.
|
| 632 |
+
At least one ``COMMAND`` must be given, see policy :policy:`CMP0175`.
|
| 633 |
+
|
| 634 |
+
.. note::
|
| 635 |
+
Because generator expressions can be used in custom commands,
|
| 636 |
+
it is possible to define ``COMMAND`` lines or whole custom commands
|
| 637 |
+
which evaluate to empty strings for certain configurations.
|
| 638 |
+
For :ref:`Visual Studio Generators` these command
|
| 639 |
+
lines or custom commands will be omitted for the specific
|
| 640 |
+
configuration and no "empty-string-command" will be added.
|
| 641 |
+
|
| 642 |
+
This allows adding individual build events for every configuration.
|
| 643 |
+
|
| 644 |
+
.. versionadded:: 3.21
|
| 645 |
+
Support for target-dependent generator expressions.
|
| 646 |
+
|
| 647 |
+
.. versionadded:: 3.29
|
| 648 |
+
The ``<target>`` may be an :ref:`ALIAS target <Alias Targets>`.
|
| 649 |
+
|
| 650 |
+
Examples: Build Events
|
| 651 |
+
^^^^^^^^^^^^^^^^^^^^^^
|
| 652 |
+
|
| 653 |
+
A ``POST_BUILD`` event may be used to post-process a binary after linking.
|
| 654 |
+
For example, the code:
|
| 655 |
+
|
| 656 |
+
.. code-block:: cmake
|
| 657 |
+
|
| 658 |
+
add_executable(myExe myExe.c)
|
| 659 |
+
add_custom_command(
|
| 660 |
+
TARGET myExe POST_BUILD
|
| 661 |
+
COMMAND someHasher -i "$<TARGET_FILE:myExe>"
|
| 662 |
+
-o "$<TARGET_FILE:myExe>.hash"
|
| 663 |
+
VERBATIM)
|
| 664 |
+
|
| 665 |
+
will run ``someHasher`` to produce a ``.hash`` file next to the executable
|
| 666 |
+
after linking.
|
| 667 |
+
|
| 668 |
+
.. versionadded:: 3.20
|
| 669 |
+
One may use generator expressions to specify per-configuration byproducts.
|
| 670 |
+
For example, the code:
|
| 671 |
+
|
| 672 |
+
.. code-block:: cmake
|
| 673 |
+
|
| 674 |
+
add_library(myPlugin MODULE myPlugin.c)
|
| 675 |
+
add_custom_command(
|
| 676 |
+
TARGET myPlugin POST_BUILD
|
| 677 |
+
COMMAND someHasher -i "$<TARGET_FILE:myPlugin>"
|
| 678 |
+
--as-code "myPlugin-hash-$<CONFIG>.c"
|
| 679 |
+
BYPRODUCTS "myPlugin-hash-$<CONFIG>.c"
|
| 680 |
+
VERBATIM)
|
| 681 |
+
add_executable(myExe myExe.c "myPlugin-hash-$<CONFIG>.c")
|
| 682 |
+
|
| 683 |
+
will run ``someHasher`` after linking ``myPlugin``, e.g. to produce a ``.c``
|
| 684 |
+
file containing code to check the hash of ``myPlugin`` that the ``myExe``
|
| 685 |
+
executable can use to verify it before loading.
|
| 686 |
+
|
| 687 |
+
Ninja Multi-Config
|
| 688 |
+
^^^^^^^^^^^^^^^^^^
|
| 689 |
+
|
| 690 |
+
.. versionadded:: 3.20
|
| 691 |
+
|
| 692 |
+
``add_custom_command`` supports the :generator:`Ninja Multi-Config`
|
| 693 |
+
generator's cross-config capabilities. See the generator documentation
|
| 694 |
+
for more information.
|
| 695 |
+
|
| 696 |
+
See Also
|
| 697 |
+
^^^^^^^^
|
| 698 |
+
|
| 699 |
+
* :command:`add_custom_target`
|
cmake/share/cmake-3.31/Help/command/add_custom_target.rst
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
add_custom_target(Name [ALL] [command1 [args1...]]
|
| 9 |
+
[COMMAND command2 [args2...] ...]
|
| 10 |
+
[DEPENDS depend depend depend ... ]
|
| 11 |
+
[BYPRODUCTS [files...]]
|
| 12 |
+
[WORKING_DIRECTORY dir]
|
| 13 |
+
[COMMENT comment]
|
| 14 |
+
[JOB_POOL job_pool]
|
| 15 |
+
[JOB_SERVER_AWARE <bool>]
|
| 16 |
+
[VERBATIM] [USES_TERMINAL]
|
| 17 |
+
[COMMAND_EXPAND_LISTS]
|
| 18 |
+
[SOURCES src1 [src2...]])
|
| 19 |
+
|
| 20 |
+
Adds a target with the given name that executes the given commands.
|
| 21 |
+
The target has no output file and is *always considered out of date*
|
| 22 |
+
even if the commands try to create a file with the name of the target.
|
| 23 |
+
Use the :command:`add_custom_command` command to generate a file with
|
| 24 |
+
dependencies. By default nothing depends on the custom target. Use
|
| 25 |
+
the :command:`add_dependencies` command to add dependencies to or
|
| 26 |
+
from other targets.
|
| 27 |
+
|
| 28 |
+
The options are:
|
| 29 |
+
|
| 30 |
+
``ALL``
|
| 31 |
+
Indicate that this target should be added to the default build
|
| 32 |
+
target so that it will be run every time (the command cannot be
|
| 33 |
+
called ``ALL``).
|
| 34 |
+
|
| 35 |
+
``BYPRODUCTS``
|
| 36 |
+
.. versionadded:: 3.2
|
| 37 |
+
|
| 38 |
+
Specify the files the command is expected to produce but whose
|
| 39 |
+
modification time may or may not be updated on subsequent builds.
|
| 40 |
+
If a byproduct name is a relative path it will be interpreted
|
| 41 |
+
relative to the build tree directory corresponding to the
|
| 42 |
+
current source directory.
|
| 43 |
+
Each byproduct file will be marked with the :prop_sf:`GENERATED`
|
| 44 |
+
source file property automatically.
|
| 45 |
+
|
| 46 |
+
*See policy* :policy:`CMP0058` *for the motivation behind this feature.*
|
| 47 |
+
|
| 48 |
+
Explicit specification of byproducts is supported by the
|
| 49 |
+
:generator:`Ninja` generator to tell the ``ninja`` build tool
|
| 50 |
+
how to regenerate byproducts when they are missing. It is
|
| 51 |
+
also useful when other build rules (e.g. custom commands)
|
| 52 |
+
depend on the byproducts. Ninja requires a build rule for any
|
| 53 |
+
generated file on which another rule depends even if there are
|
| 54 |
+
order-only dependencies to ensure the byproducts will be
|
| 55 |
+
available before their dependents build.
|
| 56 |
+
|
| 57 |
+
The :ref:`Makefile Generators` will remove ``BYPRODUCTS`` and other
|
| 58 |
+
:prop_sf:`GENERATED` files during ``make clean``.
|
| 59 |
+
|
| 60 |
+
.. versionadded:: 3.20
|
| 61 |
+
Arguments to ``BYPRODUCTS`` may use a restricted set of
|
| 62 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 63 |
+
:ref:`Target-dependent expressions <Target-Dependent Expressions>`
|
| 64 |
+
are not permitted.
|
| 65 |
+
|
| 66 |
+
.. versionchanged:: 3.28
|
| 67 |
+
In custom targets using :ref:`file sets`, byproducts are now
|
| 68 |
+
considered private unless they are listed in a non-private file set.
|
| 69 |
+
See policy :policy:`CMP0154`.
|
| 70 |
+
|
| 71 |
+
``COMMAND``
|
| 72 |
+
Specify the command-line(s) to execute at build time.
|
| 73 |
+
If more than one ``COMMAND`` is specified they will be executed in order,
|
| 74 |
+
but *not* necessarily composed into a stateful shell or batch script.
|
| 75 |
+
(To run a full script, use the :command:`configure_file` command or the
|
| 76 |
+
:command:`file(GENERATE)` command to create it, and then specify
|
| 77 |
+
a ``COMMAND`` to launch it.)
|
| 78 |
+
|
| 79 |
+
If ``COMMAND`` specifies an executable target name (created by the
|
| 80 |
+
:command:`add_executable` command), it will automatically be replaced
|
| 81 |
+
by the location of the executable created at build time if either of
|
| 82 |
+
the following is true:
|
| 83 |
+
|
| 84 |
+
* The target is not being cross-compiled (i.e. the
|
| 85 |
+
:variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
|
| 86 |
+
* .. versionadded:: 3.6
|
| 87 |
+
The target is being cross-compiled and an emulator is provided (i.e.
|
| 88 |
+
its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
|
| 89 |
+
In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
|
| 90 |
+
prepended to the command before the location of the target executable.
|
| 91 |
+
|
| 92 |
+
If neither of the above conditions are met, it is assumed that the
|
| 93 |
+
command name is a program to be found on the ``PATH`` at build time.
|
| 94 |
+
|
| 95 |
+
Arguments to ``COMMAND`` may use
|
| 96 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 97 |
+
Use the :genex:`TARGET_FILE` generator expression to refer to the location
|
| 98 |
+
of a target later in the command line (i.e. as a command argument rather
|
| 99 |
+
than as the command to execute).
|
| 100 |
+
|
| 101 |
+
Whenever one of the following target based generator expressions are used as
|
| 102 |
+
a command to execute or is mentioned in a command argument, a target-level
|
| 103 |
+
dependency will be added automatically so that the mentioned target will be
|
| 104 |
+
built before this custom target (see policy :policy:`CMP0112`).
|
| 105 |
+
|
| 106 |
+
* ``TARGET_FILE``
|
| 107 |
+
* ``TARGET_LINKER_FILE``
|
| 108 |
+
* ``TARGET_SONAME_FILE``
|
| 109 |
+
* ``TARGET_PDB_FILE``
|
| 110 |
+
|
| 111 |
+
The command and arguments are optional and if not specified an empty
|
| 112 |
+
target will be created.
|
| 113 |
+
|
| 114 |
+
``COMMENT``
|
| 115 |
+
Display the given message before the commands are executed at
|
| 116 |
+
build time.
|
| 117 |
+
|
| 118 |
+
.. versionadded:: 3.26
|
| 119 |
+
Arguments to ``COMMENT`` may use
|
| 120 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 121 |
+
|
| 122 |
+
``DEPENDS``
|
| 123 |
+
Reference files and outputs of custom commands created with
|
| 124 |
+
:command:`add_custom_command` command calls in the same directory
|
| 125 |
+
(``CMakeLists.txt`` file). They will be brought up to date when
|
| 126 |
+
the target is built.
|
| 127 |
+
|
| 128 |
+
.. versionchanged:: 3.16
|
| 129 |
+
A target-level dependency is added if any dependency is a byproduct
|
| 130 |
+
of a target or any of its build events in the same directory to ensure
|
| 131 |
+
the byproducts will be available before this target is built.
|
| 132 |
+
|
| 133 |
+
Use the :command:`add_dependencies` command to add dependencies
|
| 134 |
+
on other targets.
|
| 135 |
+
|
| 136 |
+
``COMMAND_EXPAND_LISTS``
|
| 137 |
+
.. versionadded:: 3.8
|
| 138 |
+
|
| 139 |
+
Lists in ``COMMAND`` arguments will be expanded, including those
|
| 140 |
+
created with
|
| 141 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`,
|
| 142 |
+
allowing ``COMMAND`` arguments such as
|
| 143 |
+
``${CC} "-I$<JOIN:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>,;-I>" foo.cc``
|
| 144 |
+
to be properly expanded.
|
| 145 |
+
|
| 146 |
+
``JOB_POOL``
|
| 147 |
+
.. versionadded:: 3.15
|
| 148 |
+
|
| 149 |
+
Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
|
| 150 |
+
generator. Incompatible with ``USES_TERMINAL``, which implies
|
| 151 |
+
the ``console`` pool.
|
| 152 |
+
Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes
|
| 153 |
+
an error by ninja at build time.
|
| 154 |
+
|
| 155 |
+
``JOB_SERVER_AWARE``
|
| 156 |
+
.. versionadded:: 3.28
|
| 157 |
+
|
| 158 |
+
Specify that the command is GNU Make job server aware.
|
| 159 |
+
|
| 160 |
+
For the :generator:`Unix Makefiles`, :generator:`MSYS Makefiles`, and
|
| 161 |
+
:generator:`MinGW Makefiles` generators this will add the ``+`` prefix to the
|
| 162 |
+
recipe line. See the `GNU Make Documentation`_ for more information.
|
| 163 |
+
|
| 164 |
+
This option is silently ignored by other generators.
|
| 165 |
+
|
| 166 |
+
.. _`GNU Make Documentation`: https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html
|
| 167 |
+
|
| 168 |
+
``SOURCES``
|
| 169 |
+
Specify additional source files to be included in the custom target.
|
| 170 |
+
Specified source files will be added to IDE project files for
|
| 171 |
+
convenience in editing even if they have no build rules.
|
| 172 |
+
|
| 173 |
+
``VERBATIM``
|
| 174 |
+
All arguments to the commands will be escaped properly for the
|
| 175 |
+
build tool so that the invoked command receives each argument
|
| 176 |
+
unchanged. Note that one level of escapes is still used by the
|
| 177 |
+
CMake language processor before ``add_custom_target`` even sees
|
| 178 |
+
the arguments. Use of ``VERBATIM`` is recommended as it enables
|
| 179 |
+
correct behavior. When ``VERBATIM`` is not given the behavior
|
| 180 |
+
is platform specific because there is no protection of
|
| 181 |
+
tool-specific special characters.
|
| 182 |
+
|
| 183 |
+
``USES_TERMINAL``
|
| 184 |
+
.. versionadded:: 3.2
|
| 185 |
+
|
| 186 |
+
The command will be given direct access to the terminal if possible.
|
| 187 |
+
With the :generator:`Ninja` generator, this places the command in
|
| 188 |
+
the ``console`` :prop_gbl:`pool <JOB_POOLS>`.
|
| 189 |
+
|
| 190 |
+
``WORKING_DIRECTORY``
|
| 191 |
+
Execute the command with the given current working directory.
|
| 192 |
+
If it is a relative path it will be interpreted relative to the
|
| 193 |
+
build tree directory corresponding to the current source directory.
|
| 194 |
+
|
| 195 |
+
.. versionadded:: 3.13
|
| 196 |
+
Arguments to ``WORKING_DIRECTORY`` may use
|
| 197 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 198 |
+
|
| 199 |
+
Ninja Multi-Config
|
| 200 |
+
^^^^^^^^^^^^^^^^^^
|
| 201 |
+
|
| 202 |
+
.. versionadded:: 3.20
|
| 203 |
+
|
| 204 |
+
``add_custom_target`` supports the :generator:`Ninja Multi-Config`
|
| 205 |
+
generator's cross-config capabilities. See the generator documentation
|
| 206 |
+
for more information.
|
| 207 |
+
|
| 208 |
+
See Also
|
| 209 |
+
^^^^^^^^
|
| 210 |
+
|
| 211 |
+
* :command:`add_custom_command`
|
cmake/share/cmake-3.31/Help/command/add_definitions.rst
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_definitions
|
| 2 |
+
---------------
|
| 3 |
+
|
| 4 |
+
Add ``-D`` define flags to the compilation of source files.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
add_definitions(-DFOO -DBAR ...)
|
| 9 |
+
|
| 10 |
+
Adds definitions to the compiler command line for targets in the current
|
| 11 |
+
directory, whether added before or after this command is invoked, and for
|
| 12 |
+
the ones in sub-directories added after. This command can be used to add any
|
| 13 |
+
flags, but it is intended to add preprocessor definitions.
|
| 14 |
+
|
| 15 |
+
.. note::
|
| 16 |
+
|
| 17 |
+
This command has been superseded by alternatives:
|
| 18 |
+
|
| 19 |
+
* Use :command:`add_compile_definitions` to add preprocessor definitions.
|
| 20 |
+
* Use :command:`include_directories` to add include directories.
|
| 21 |
+
* Use :command:`add_compile_options` to add other options.
|
| 22 |
+
|
| 23 |
+
Flags beginning in ``-D`` or ``/D`` that look like preprocessor definitions are
|
| 24 |
+
automatically added to the :prop_dir:`COMPILE_DEFINITIONS` directory
|
| 25 |
+
property for the current directory. Definitions with non-trivial values
|
| 26 |
+
may be left in the set of flags instead of being converted for reasons of
|
| 27 |
+
backwards compatibility. See documentation of the
|
| 28 |
+
:prop_dir:`directory <COMPILE_DEFINITIONS>`,
|
| 29 |
+
:prop_tgt:`target <COMPILE_DEFINITIONS>`,
|
| 30 |
+
:prop_sf:`source file <COMPILE_DEFINITIONS>` ``COMPILE_DEFINITIONS``
|
| 31 |
+
properties for details on adding preprocessor definitions to specific
|
| 32 |
+
scopes and configurations.
|
| 33 |
+
|
| 34 |
+
See Also
|
| 35 |
+
^^^^^^^^
|
| 36 |
+
|
| 37 |
+
* The :manual:`cmake-buildsystem(7)` manual for more on defining
|
| 38 |
+
buildsystem properties.
|
cmake/share/cmake-3.31/Help/command/add_dependencies.rst
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_dependencies
|
| 2 |
+
----------------
|
| 3 |
+
|
| 4 |
+
Add a dependency between top-level targets.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
add_dependencies(<target> [<target-dependency>]...)
|
| 9 |
+
|
| 10 |
+
Makes a top-level ``<target>`` depend on other top-level targets to
|
| 11 |
+
ensure that they build before ``<target>`` does. A top-level target
|
| 12 |
+
is one created by one of the :command:`add_executable`,
|
| 13 |
+
:command:`add_library`, or :command:`add_custom_target` commands
|
| 14 |
+
(but not targets generated by CMake like ``install``).
|
| 15 |
+
|
| 16 |
+
Dependencies added to an :ref:`imported target <Imported Targets>`
|
| 17 |
+
or an :ref:`interface library <Interface Libraries>` are followed
|
| 18 |
+
transitively in its place since the target itself does not build.
|
| 19 |
+
|
| 20 |
+
.. versionadded:: 3.3
|
| 21 |
+
Allow adding dependencies to interface libraries.
|
| 22 |
+
|
| 23 |
+
.. versionadded:: 3.8
|
| 24 |
+
Dependencies will populate the :prop_tgt:`MANUALLY_ADDED_DEPENDENCIES`
|
| 25 |
+
property of ``<target>``.
|
| 26 |
+
|
| 27 |
+
.. versionchanged:: 3.9
|
| 28 |
+
The :ref:`Ninja Generators` use weaker ordering than
|
| 29 |
+
other generators in order to improve available concurrency.
|
| 30 |
+
They only guarantee that the dependencies' custom commands are
|
| 31 |
+
finished before sources in ``<target>`` start compiling; this
|
| 32 |
+
ensures generated sources are available.
|
| 33 |
+
|
| 34 |
+
See Also
|
| 35 |
+
^^^^^^^^
|
| 36 |
+
|
| 37 |
+
* The ``DEPENDS`` option of :command:`add_custom_target` and
|
| 38 |
+
:command:`add_custom_command` commands for adding file-level
|
| 39 |
+
dependencies in custom rules.
|
| 40 |
+
|
| 41 |
+
* The :prop_sf:`OBJECT_DEPENDS` source file property to add
|
| 42 |
+
file-level dependencies to object files.
|
cmake/share/cmake-3.31/Help/command/add_executable.rst
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_executable
|
| 2 |
+
--------------
|
| 3 |
+
|
| 4 |
+
.. only:: html
|
| 5 |
+
|
| 6 |
+
.. contents::
|
| 7 |
+
|
| 8 |
+
Add an executable to the project using the specified source files.
|
| 9 |
+
|
| 10 |
+
Normal Executables
|
| 11 |
+
^^^^^^^^^^^^^^^^^^
|
| 12 |
+
|
| 13 |
+
.. signature::
|
| 14 |
+
add_executable(<name> <options>... <sources>...)
|
| 15 |
+
:target: normal
|
| 16 |
+
|
| 17 |
+
Add an executable target called ``<name>`` to be built from the source
|
| 18 |
+
files listed in the command invocation.
|
| 19 |
+
|
| 20 |
+
The options are:
|
| 21 |
+
|
| 22 |
+
``WIN32``
|
| 23 |
+
Set the :prop_tgt:`WIN32_EXECUTABLE` target property automatically.
|
| 24 |
+
See documentation of that target property for details.
|
| 25 |
+
|
| 26 |
+
``MACOSX_BUNDLE``
|
| 27 |
+
Set the :prop_tgt:`MACOSX_BUNDLE` target property automatically.
|
| 28 |
+
See documentation of that target property for details.
|
| 29 |
+
|
| 30 |
+
``EXCLUDE_FROM_ALL``
|
| 31 |
+
Set the :prop_tgt:`EXCLUDE_FROM_ALL` target property automatically.
|
| 32 |
+
See documentation of that target property for details.
|
| 33 |
+
|
| 34 |
+
The ``<name>`` corresponds to the logical target name and must be globally
|
| 35 |
+
unique within a project. The actual file name of the executable built is
|
| 36 |
+
constructed based on conventions of the native platform (such as
|
| 37 |
+
``<name>.exe`` or just ``<name>``).
|
| 38 |
+
|
| 39 |
+
.. versionadded:: 3.1
|
| 40 |
+
Source arguments to ``add_executable`` may use "generator expressions" with
|
| 41 |
+
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
|
| 42 |
+
manual for available expressions.
|
| 43 |
+
|
| 44 |
+
.. versionadded:: 3.11
|
| 45 |
+
The source files can be omitted if they are added later using
|
| 46 |
+
:command:`target_sources`.
|
| 47 |
+
|
| 48 |
+
By default the executable file will be created in the build tree
|
| 49 |
+
directory corresponding to the source tree directory in which the
|
| 50 |
+
command was invoked. See documentation of the
|
| 51 |
+
:prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` target property to change this
|
| 52 |
+
location. See documentation of the :prop_tgt:`OUTPUT_NAME` target property
|
| 53 |
+
to change the ``<name>`` part of the final file name.
|
| 54 |
+
|
| 55 |
+
See the :manual:`cmake-buildsystem(7)` manual for more on defining
|
| 56 |
+
buildsystem properties.
|
| 57 |
+
|
| 58 |
+
See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are
|
| 59 |
+
pre-processed, and you want to have the original sources reachable from
|
| 60 |
+
within IDE.
|
| 61 |
+
|
| 62 |
+
Imported Executables
|
| 63 |
+
^^^^^^^^^^^^^^^^^^^^
|
| 64 |
+
|
| 65 |
+
.. signature::
|
| 66 |
+
add_executable(<name> IMPORTED [GLOBAL])
|
| 67 |
+
:target: IMPORTED
|
| 68 |
+
|
| 69 |
+
Add an :ref:`IMPORTED executable target <Imported Targets>` to reference
|
| 70 |
+
an executable file located outside the project. The target name may be
|
| 71 |
+
referenced like any target built within the project, except that by
|
| 72 |
+
default it is visible only in the directory in which it is created,
|
| 73 |
+
and below.
|
| 74 |
+
|
| 75 |
+
The options are:
|
| 76 |
+
|
| 77 |
+
``GLOBAL``
|
| 78 |
+
Make the target name globally visible.
|
| 79 |
+
|
| 80 |
+
No rules are generated to build imported targets, and the :prop_tgt:`IMPORTED`
|
| 81 |
+
target property is ``True``. Imported executables are useful for convenient
|
| 82 |
+
reference from commands like :command:`add_custom_command`.
|
| 83 |
+
|
| 84 |
+
Details about the imported executable are specified by setting properties
|
| 85 |
+
whose names begin in ``IMPORTED_``. The most important such property is
|
| 86 |
+
:prop_tgt:`IMPORTED_LOCATION` (and its per-configuration version
|
| 87 |
+
:prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the location of
|
| 88 |
+
the main executable file on disk. See documentation of the ``IMPORTED_*``
|
| 89 |
+
properties for more information.
|
| 90 |
+
|
| 91 |
+
Alias Executables
|
| 92 |
+
^^^^^^^^^^^^^^^^^
|
| 93 |
+
|
| 94 |
+
.. signature::
|
| 95 |
+
add_executable(<name> ALIAS <target>)
|
| 96 |
+
:target: ALIAS
|
| 97 |
+
|
| 98 |
+
Creates an :ref:`Alias Target <Alias Targets>`, such that ``<name>`` can
|
| 99 |
+
be used to refer to ``<target>`` in subsequent commands. The ``<name>``
|
| 100 |
+
does not appear in the generated buildsystem as a make target. The
|
| 101 |
+
``<target>`` may not be an ``ALIAS``.
|
| 102 |
+
|
| 103 |
+
.. versionadded:: 3.11
|
| 104 |
+
An ``ALIAS`` can target a ``GLOBAL`` :ref:`Imported Target <Imported Targets>`
|
| 105 |
+
|
| 106 |
+
.. versionadded:: 3.18
|
| 107 |
+
An ``ALIAS`` can target a non-``GLOBAL`` Imported Target. Such alias is
|
| 108 |
+
scoped to the directory in which it is created and subdirectories.
|
| 109 |
+
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
|
| 110 |
+
alias is global or not.
|
| 111 |
+
|
| 112 |
+
``ALIAS`` targets can be used as targets to read properties
|
| 113 |
+
from, executables for custom commands and custom targets. They can also be
|
| 114 |
+
tested for existence with the regular :command:`if(TARGET)` subcommand.
|
| 115 |
+
The ``<name>`` may not be used to modify properties of ``<target>``, that
|
| 116 |
+
is, it may not be used as the operand of :command:`set_property`,
|
| 117 |
+
:command:`set_target_properties`, :command:`target_link_libraries` etc.
|
| 118 |
+
An ``ALIAS`` target may not be installed or exported.
|
| 119 |
+
|
| 120 |
+
See Also
|
| 121 |
+
^^^^^^^^
|
| 122 |
+
|
| 123 |
+
* :command:`add_library`
|
cmake/share/cmake-3.31/Help/command/add_library.rst
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_library
|
| 2 |
+
-----------
|
| 3 |
+
|
| 4 |
+
.. only:: html
|
| 5 |
+
|
| 6 |
+
.. contents::
|
| 7 |
+
|
| 8 |
+
Add a library to the project using the specified source files.
|
| 9 |
+
|
| 10 |
+
Normal Libraries
|
| 11 |
+
^^^^^^^^^^^^^^^^
|
| 12 |
+
|
| 13 |
+
.. signature::
|
| 14 |
+
add_library(<name> [<type>] [EXCLUDE_FROM_ALL] <sources>...)
|
| 15 |
+
:target: normal
|
| 16 |
+
|
| 17 |
+
Add a library target called ``<name>`` to be built from the source files
|
| 18 |
+
listed in the command invocation.
|
| 19 |
+
|
| 20 |
+
The optional ``<type>`` specifies the type of library to be created:
|
| 21 |
+
|
| 22 |
+
``STATIC``
|
| 23 |
+
An archive of object files for use when linking other targets.
|
| 24 |
+
|
| 25 |
+
``SHARED``
|
| 26 |
+
A dynamic library that may be linked by other targets and loaded
|
| 27 |
+
at runtime.
|
| 28 |
+
|
| 29 |
+
``MODULE``
|
| 30 |
+
A plugin that may not be linked by other targets, but may be
|
| 31 |
+
dynamically loaded at runtime using dlopen-like functionality.
|
| 32 |
+
|
| 33 |
+
If no ``<type>`` is given the default is ``STATIC`` or ``SHARED``
|
| 34 |
+
based on the value of the :variable:`BUILD_SHARED_LIBS` variable.
|
| 35 |
+
|
| 36 |
+
The options are:
|
| 37 |
+
|
| 38 |
+
``EXCLUDE_FROM_ALL``
|
| 39 |
+
Set the :prop_tgt:`EXCLUDE_FROM_ALL` target property automatically.
|
| 40 |
+
See documentation of that target property for details.
|
| 41 |
+
|
| 42 |
+
The ``<name>`` corresponds to the logical target name and must be globally
|
| 43 |
+
unique within a project. The actual file name of the library built is
|
| 44 |
+
constructed based on conventions of the native platform (such as
|
| 45 |
+
``lib<name>.a`` or ``<name>.lib``).
|
| 46 |
+
|
| 47 |
+
.. versionadded:: 3.1
|
| 48 |
+
Source arguments to ``add_library`` may use "generator expressions" with
|
| 49 |
+
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
|
| 50 |
+
manual for available expressions.
|
| 51 |
+
|
| 52 |
+
.. versionadded:: 3.11
|
| 53 |
+
The source files can be omitted if they are added later using
|
| 54 |
+
:command:`target_sources`.
|
| 55 |
+
|
| 56 |
+
For ``SHARED`` and ``MODULE`` libraries the
|
| 57 |
+
:prop_tgt:`POSITION_INDEPENDENT_CODE` target
|
| 58 |
+
property is set to ``ON`` automatically.
|
| 59 |
+
A ``SHARED`` library may be marked with the :prop_tgt:`FRAMEWORK`
|
| 60 |
+
target property to create an macOS Framework.
|
| 61 |
+
|
| 62 |
+
.. versionadded:: 3.8
|
| 63 |
+
A ``STATIC`` library may be marked with the :prop_tgt:`FRAMEWORK`
|
| 64 |
+
target property to create a static Framework.
|
| 65 |
+
|
| 66 |
+
If a library does not export any symbols, it must not be declared as a
|
| 67 |
+
``SHARED`` library. For example, a Windows resource DLL or a managed C++/CLI
|
| 68 |
+
DLL that exports no unmanaged symbols would need to be a ``MODULE`` library.
|
| 69 |
+
This is because CMake expects a ``SHARED`` library to always have an
|
| 70 |
+
associated import library on Windows.
|
| 71 |
+
|
| 72 |
+
By default the library file will be created in the build tree directory
|
| 73 |
+
corresponding to the source tree directory in which the command was
|
| 74 |
+
invoked. See documentation of the :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`,
|
| 75 |
+
:prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and
|
| 76 |
+
:prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` target properties to change this
|
| 77 |
+
location. See documentation of the :prop_tgt:`OUTPUT_NAME` target
|
| 78 |
+
property to change the ``<name>`` part of the final file name.
|
| 79 |
+
|
| 80 |
+
See the :manual:`cmake-buildsystem(7)` manual for more on defining
|
| 81 |
+
buildsystem properties.
|
| 82 |
+
|
| 83 |
+
See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are
|
| 84 |
+
pre-processed, and you want to have the original sources reachable from
|
| 85 |
+
within IDE.
|
| 86 |
+
|
| 87 |
+
.. versionchanged:: 3.30
|
| 88 |
+
|
| 89 |
+
On platforms that do not support shared libraries, ``add_library``
|
| 90 |
+
now fails on calls creating ``SHARED`` libraries instead of
|
| 91 |
+
automatically converting them to ``STATIC`` libraries as before.
|
| 92 |
+
See policy :policy:`CMP0164`.
|
| 93 |
+
|
| 94 |
+
Object Libraries
|
| 95 |
+
^^^^^^^^^^^^^^^^
|
| 96 |
+
|
| 97 |
+
.. signature::
|
| 98 |
+
add_library(<name> OBJECT <sources>...)
|
| 99 |
+
:target: OBJECT
|
| 100 |
+
|
| 101 |
+
Add an :ref:`Object Library <Object Libraries>` to compile source files
|
| 102 |
+
without archiving or linking their object files into a library.
|
| 103 |
+
|
| 104 |
+
Other targets created by ``add_library`` or :command:`add_executable`
|
| 105 |
+
may reference the objects using an expression of the
|
| 106 |
+
form :genex:`$\<TARGET_OBJECTS:objlib\> <TARGET_OBJECTS>` as a source, where
|
| 107 |
+
``objlib`` is the object library name. For example:
|
| 108 |
+
|
| 109 |
+
.. code-block:: cmake
|
| 110 |
+
|
| 111 |
+
add_library(... $<TARGET_OBJECTS:objlib> ...)
|
| 112 |
+
add_executable(... $<TARGET_OBJECTS:objlib> ...)
|
| 113 |
+
|
| 114 |
+
will include objlib's object files in a library and an executable
|
| 115 |
+
along with those compiled from their own sources. Object libraries
|
| 116 |
+
may contain only sources that compile, header files, and other files
|
| 117 |
+
that would not affect linking of a normal library (e.g. ``.txt``).
|
| 118 |
+
They may contain custom commands generating such sources, but not
|
| 119 |
+
``PRE_BUILD``, ``PRE_LINK``, or ``POST_BUILD`` commands. Some native build
|
| 120 |
+
systems (such as Xcode) may not like targets that have only object files, so
|
| 121 |
+
consider adding at least one real source file to any target that references
|
| 122 |
+
:genex:`$\<TARGET_OBJECTS:objlib\> <TARGET_OBJECTS>`.
|
| 123 |
+
|
| 124 |
+
.. versionadded:: 3.12
|
| 125 |
+
Object libraries can be linked to with :command:`target_link_libraries`.
|
| 126 |
+
|
| 127 |
+
Interface Libraries
|
| 128 |
+
^^^^^^^^^^^^^^^^^^^
|
| 129 |
+
|
| 130 |
+
.. signature::
|
| 131 |
+
add_library(<name> INTERFACE)
|
| 132 |
+
:target: INTERFACE
|
| 133 |
+
|
| 134 |
+
Add an :ref:`Interface Library <Interface Libraries>` target that may
|
| 135 |
+
specify usage requirements for dependents but does not compile sources
|
| 136 |
+
and does not produce a library artifact on disk.
|
| 137 |
+
|
| 138 |
+
An interface library with no source files is not included as a target
|
| 139 |
+
in the generated buildsystem. However, it may have
|
| 140 |
+
properties set on it and it may be installed and exported.
|
| 141 |
+
Typically, ``INTERFACE_*`` properties are populated on an interface
|
| 142 |
+
target using the commands:
|
| 143 |
+
|
| 144 |
+
* :command:`set_property`,
|
| 145 |
+
* :command:`target_link_libraries(INTERFACE)`,
|
| 146 |
+
* :command:`target_link_options(INTERFACE)`,
|
| 147 |
+
* :command:`target_include_directories(INTERFACE)`,
|
| 148 |
+
* :command:`target_compile_options(INTERFACE)`,
|
| 149 |
+
* :command:`target_compile_definitions(INTERFACE)`, and
|
| 150 |
+
* :command:`target_sources(INTERFACE)`,
|
| 151 |
+
|
| 152 |
+
and then it is used as an argument to :command:`target_link_libraries`
|
| 153 |
+
like any other target.
|
| 154 |
+
|
| 155 |
+
.. versionadded:: 3.15
|
| 156 |
+
An interface library can have :prop_tgt:`PUBLIC_HEADER` and
|
| 157 |
+
:prop_tgt:`PRIVATE_HEADER` properties. The headers specified by those
|
| 158 |
+
properties can be installed using the :command:`install(TARGETS)` command.
|
| 159 |
+
|
| 160 |
+
.. signature::
|
| 161 |
+
add_library(<name> INTERFACE [EXCLUDE_FROM_ALL] <sources>...)
|
| 162 |
+
:target: INTERFACE-with-sources
|
| 163 |
+
|
| 164 |
+
.. versionadded:: 3.19
|
| 165 |
+
|
| 166 |
+
Add an :ref:`Interface Library <Interface Libraries>` target with
|
| 167 |
+
source files (in addition to usage requirements and properties as
|
| 168 |
+
documented by the :command:`above signature <add_library(INTERFACE)>`).
|
| 169 |
+
Source files may be listed directly in the ``add_library`` call
|
| 170 |
+
or added later by calls to :command:`target_sources` with the
|
| 171 |
+
``PRIVATE`` or ``PUBLIC`` keywords.
|
| 172 |
+
|
| 173 |
+
If an interface library has source files (i.e. the :prop_tgt:`SOURCES`
|
| 174 |
+
target property is set), or header sets (i.e. the :prop_tgt:`HEADER_SETS`
|
| 175 |
+
target property is set), it will appear in the generated buildsystem
|
| 176 |
+
as a build target much like a target defined by the
|
| 177 |
+
:command:`add_custom_target` command. It does not compile any sources,
|
| 178 |
+
but does contain build rules for custom commands created by the
|
| 179 |
+
:command:`add_custom_command` command.
|
| 180 |
+
|
| 181 |
+
The options are:
|
| 182 |
+
|
| 183 |
+
``EXCLUDE_FROM_ALL``
|
| 184 |
+
Set the :prop_tgt:`EXCLUDE_FROM_ALL` target property automatically.
|
| 185 |
+
See documentation of that target property for details.
|
| 186 |
+
|
| 187 |
+
.. note::
|
| 188 |
+
In most command signatures where the ``INTERFACE`` keyword appears,
|
| 189 |
+
the items listed after it only become part of that target's usage
|
| 190 |
+
requirements and are not part of the target's own settings. However,
|
| 191 |
+
in this signature of ``add_library``, the ``INTERFACE`` keyword refers
|
| 192 |
+
to the library type only. Sources listed after it in the ``add_library``
|
| 193 |
+
call are ``PRIVATE`` to the interface library and do not appear in its
|
| 194 |
+
:prop_tgt:`INTERFACE_SOURCES` target property.
|
| 195 |
+
|
| 196 |
+
.. _`add_library imported libraries`:
|
| 197 |
+
|
| 198 |
+
Imported Libraries
|
| 199 |
+
^^^^^^^^^^^^^^^^^^
|
| 200 |
+
|
| 201 |
+
.. signature::
|
| 202 |
+
add_library(<name> <type> IMPORTED [GLOBAL])
|
| 203 |
+
:target: IMPORTED
|
| 204 |
+
|
| 205 |
+
Add an :ref:`IMPORTED library target <Imported Targets>` called ``<name>``.
|
| 206 |
+
The target name may be referenced like any target built within the project,
|
| 207 |
+
except that by default it is visible only in the directory in which it is
|
| 208 |
+
created, and below.
|
| 209 |
+
|
| 210 |
+
The ``<type>`` must be one of:
|
| 211 |
+
|
| 212 |
+
``STATIC``, ``SHARED``, ``MODULE``, ``UNKNOWN``
|
| 213 |
+
References a library file located outside the project. The
|
| 214 |
+
:prop_tgt:`IMPORTED_LOCATION` target property (or its per-configuration
|
| 215 |
+
variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) specifies the
|
| 216 |
+
location of the main library file on disk:
|
| 217 |
+
|
| 218 |
+
* For a ``SHARED`` library on most non-Windows platforms, the main library
|
| 219 |
+
file is the ``.so`` or ``.dylib`` file used by both linkers and dynamic
|
| 220 |
+
loaders. If the referenced library file has a ``SONAME`` (or on macOS,
|
| 221 |
+
has a ``LC_ID_DYLIB`` starting in ``@rpath/``), the value of that field
|
| 222 |
+
should be set in the :prop_tgt:`IMPORTED_SONAME` target property.
|
| 223 |
+
If the referenced library file does not have a ``SONAME``, but the
|
| 224 |
+
platform supports it, then the :prop_tgt:`IMPORTED_NO_SONAME` target
|
| 225 |
+
property should be set.
|
| 226 |
+
|
| 227 |
+
* For a ``SHARED`` library on Windows, the :prop_tgt:`IMPORTED_IMPLIB`
|
| 228 |
+
target property (or its per-configuration variant
|
| 229 |
+
:prop_tgt:`IMPORTED_IMPLIB_<CONFIG>`) specifies the location of the
|
| 230 |
+
DLL import library file (``.lib`` or ``.dll.a``) on disk, and the
|
| 231 |
+
``IMPORTED_LOCATION`` is the location of the ``.dll`` runtime
|
| 232 |
+
library (and is optional, but needed by the :genex:`TARGET_RUNTIME_DLLS`
|
| 233 |
+
generator expression).
|
| 234 |
+
|
| 235 |
+
Additional usage requirements may be specified in ``INTERFACE_*``
|
| 236 |
+
properties.
|
| 237 |
+
|
| 238 |
+
An ``UNKNOWN`` library type is typically only used in the implementation
|
| 239 |
+
of :ref:`Find Modules`. It allows the path to an imported library
|
| 240 |
+
(often found using the :command:`find_library` command) to be used
|
| 241 |
+
without having to know what type of library it is. This is especially
|
| 242 |
+
useful on Windows where a static library and a DLL's import library
|
| 243 |
+
both have the same file extension.
|
| 244 |
+
|
| 245 |
+
``OBJECT``
|
| 246 |
+
References a set of object files located outside the project.
|
| 247 |
+
The :prop_tgt:`IMPORTED_OBJECTS` target property (or its per-configuration
|
| 248 |
+
variant :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`) specifies the locations of
|
| 249 |
+
object files on disk.
|
| 250 |
+
Additional usage requirements may be specified in ``INTERFACE_*``
|
| 251 |
+
properties.
|
| 252 |
+
|
| 253 |
+
``INTERFACE``
|
| 254 |
+
Does not reference any library or object files on disk, but may
|
| 255 |
+
specify usage requirements in ``INTERFACE_*`` properties.
|
| 256 |
+
|
| 257 |
+
The options are:
|
| 258 |
+
|
| 259 |
+
``GLOBAL``
|
| 260 |
+
Make the target name globally visible.
|
| 261 |
+
|
| 262 |
+
No rules are generated to build imported targets, and the :prop_tgt:`IMPORTED`
|
| 263 |
+
target property is ``True``. Imported libraries are useful for convenient
|
| 264 |
+
reference from commands like :command:`target_link_libraries`.
|
| 265 |
+
|
| 266 |
+
Details about the imported library are specified by setting properties whose
|
| 267 |
+
names begin in ``IMPORTED_`` and ``INTERFACE_``. See documentation of
|
| 268 |
+
such properties for more information.
|
| 269 |
+
|
| 270 |
+
Alias Libraries
|
| 271 |
+
^^^^^^^^^^^^^^^
|
| 272 |
+
|
| 273 |
+
.. signature::
|
| 274 |
+
add_library(<name> ALIAS <target>)
|
| 275 |
+
:target: ALIAS
|
| 276 |
+
|
| 277 |
+
Creates an :ref:`Alias Target <Alias Targets>`, such that ``<name>`` can be
|
| 278 |
+
used to refer to ``<target>`` in subsequent commands. The ``<name>`` does
|
| 279 |
+
not appear in the generated buildsystem as a make target. The ``<target>``
|
| 280 |
+
may not be an ``ALIAS``.
|
| 281 |
+
|
| 282 |
+
.. versionadded:: 3.11
|
| 283 |
+
An ``ALIAS`` can target a ``GLOBAL`` :ref:`Imported Target <Imported Targets>`
|
| 284 |
+
|
| 285 |
+
.. versionadded:: 3.18
|
| 286 |
+
An ``ALIAS`` can target a non-``GLOBAL`` Imported Target. Such alias is
|
| 287 |
+
scoped to the directory in which it is created and below.
|
| 288 |
+
The :prop_tgt:`ALIAS_GLOBAL` target property can be used to check if the
|
| 289 |
+
alias is global or not.
|
| 290 |
+
|
| 291 |
+
``ALIAS`` targets can be used as linkable targets and as targets to
|
| 292 |
+
read properties from. They can also be tested for existence with the
|
| 293 |
+
regular :command:`if(TARGET)` subcommand. The ``<name>`` may not be used
|
| 294 |
+
to modify properties of ``<target>``, that is, it may not be used as the
|
| 295 |
+
operand of :command:`set_property`, :command:`set_target_properties`,
|
| 296 |
+
:command:`target_link_libraries` etc. An ``ALIAS`` target may not be
|
| 297 |
+
installed or exported.
|
| 298 |
+
|
| 299 |
+
See Also
|
| 300 |
+
^^^^^^^^
|
| 301 |
+
|
| 302 |
+
* :command:`add_executable`
|
cmake/share/cmake-3.31/Help/command/add_link_options.rst
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_link_options
|
| 2 |
+
----------------
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.13
|
| 5 |
+
|
| 6 |
+
Add options to the link step for executable, shared library or module
|
| 7 |
+
library targets in the current directory and below that are added after
|
| 8 |
+
this command is invoked.
|
| 9 |
+
|
| 10 |
+
.. code-block:: cmake
|
| 11 |
+
|
| 12 |
+
add_link_options(<option> ...)
|
| 13 |
+
|
| 14 |
+
This command can be used to add any link options, but alternative commands
|
| 15 |
+
exist to add libraries (:command:`target_link_libraries` or
|
| 16 |
+
:command:`link_libraries`). See documentation of the
|
| 17 |
+
:prop_dir:`directory <LINK_OPTIONS>` and
|
| 18 |
+
:prop_tgt:`target <LINK_OPTIONS>` ``LINK_OPTIONS`` properties.
|
| 19 |
+
|
| 20 |
+
.. note::
|
| 21 |
+
|
| 22 |
+
This command cannot be used to add options for static library targets,
|
| 23 |
+
since they do not use a linker. To add archiver or MSVC librarian flags,
|
| 24 |
+
see the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property.
|
| 25 |
+
|
| 26 |
+
.. |command_name| replace:: ``add_link_options``
|
| 27 |
+
.. include:: GENEX_NOTE.txt
|
| 28 |
+
|
| 29 |
+
.. include:: DEVICE_LINK_OPTIONS.txt
|
| 30 |
+
|
| 31 |
+
.. include:: OPTIONS_SHELL.txt
|
| 32 |
+
|
| 33 |
+
.. include:: LINK_OPTIONS_LINKER.txt
|
| 34 |
+
|
| 35 |
+
See Also
|
| 36 |
+
^^^^^^^^
|
| 37 |
+
|
| 38 |
+
* :command:`link_libraries`
|
| 39 |
+
* :command:`target_link_libraries`
|
| 40 |
+
* :command:`target_link_options`
|
| 41 |
+
|
| 42 |
+
* :variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>`
|
| 43 |
+
add language-wide flags passed to all invocations of the compiler.
|
| 44 |
+
This includes invocations that drive compiling and those that drive linking.
|
cmake/share/cmake-3.31/Help/command/add_subdirectory.rst
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_subdirectory
|
| 2 |
+
----------------
|
| 3 |
+
|
| 4 |
+
Add a subdirectory to the build.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL] [SYSTEM])
|
| 9 |
+
|
| 10 |
+
Adds a subdirectory to the build. The ``source_dir`` specifies the
|
| 11 |
+
directory in which the source ``CMakeLists.txt`` and code files are
|
| 12 |
+
located. If it is a relative path, it will be evaluated with respect
|
| 13 |
+
to the current directory (the typical usage), but it may also be an
|
| 14 |
+
absolute path. The ``binary_dir`` specifies the directory in which to
|
| 15 |
+
place the output files. If it is a relative path, it will be evaluated
|
| 16 |
+
with respect to the current output directory, but it may also be an
|
| 17 |
+
absolute path. If ``binary_dir`` is not specified, the value of
|
| 18 |
+
``source_dir``, before expanding any relative path, will be used (the
|
| 19 |
+
typical usage). The ``CMakeLists.txt`` file in the specified source
|
| 20 |
+
directory will be processed immediately by CMake before processing in
|
| 21 |
+
the current input file continues beyond this command.
|
| 22 |
+
|
| 23 |
+
If the ``EXCLUDE_FROM_ALL`` argument is provided then the
|
| 24 |
+
:prop_dir:`EXCLUDE_FROM_ALL` property will be set on the added directory.
|
| 25 |
+
This will exclude the directory from a default build. See the directory
|
| 26 |
+
property :prop_dir:`EXCLUDE_FROM_ALL` for full details.
|
| 27 |
+
|
| 28 |
+
.. versionadded:: 3.25
|
| 29 |
+
If the ``SYSTEM`` argument is provided, the :prop_dir:`SYSTEM` directory
|
| 30 |
+
property of the subdirectory will be set to true. This property is
|
| 31 |
+
used to initialize the :prop_tgt:`SYSTEM` property of each non-imported
|
| 32 |
+
target created in that subdirectory.
|
cmake/share/cmake-3.31/Help/command/add_test.rst
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
add_test
|
| 2 |
+
--------
|
| 3 |
+
|
| 4 |
+
Add a test to the project to be run by :manual:`ctest(1)`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
add_test(NAME <name> COMMAND <command> [<arg>...]
|
| 9 |
+
[CONFIGURATIONS <config>...]
|
| 10 |
+
[WORKING_DIRECTORY <dir>]
|
| 11 |
+
[COMMAND_EXPAND_LISTS])
|
| 12 |
+
|
| 13 |
+
Adds a test called ``<name>``. The test name may contain arbitrary
|
| 14 |
+
characters, expressed as a :ref:`Quoted Argument` or :ref:`Bracket Argument`
|
| 15 |
+
if necessary. See policy :policy:`CMP0110`.
|
| 16 |
+
|
| 17 |
+
CMake only generates tests if the :command:`enable_testing` command has been
|
| 18 |
+
invoked. The :module:`CTest` module invokes ``enable_testing`` automatically
|
| 19 |
+
unless ``BUILD_TESTING`` is set to ``OFF``.
|
| 20 |
+
|
| 21 |
+
Tests added with the ``add_test(NAME)`` signature support using
|
| 22 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`
|
| 23 |
+
in test properties set by :command:`set_property(TEST)` or
|
| 24 |
+
:command:`set_tests_properties`. Test properties may only be set in the
|
| 25 |
+
directory the test is created in.
|
| 26 |
+
|
| 27 |
+
``add_test`` options are:
|
| 28 |
+
|
| 29 |
+
``COMMAND``
|
| 30 |
+
Specify the test command-line.
|
| 31 |
+
|
| 32 |
+
If ``<command>`` specifies an executable target created by
|
| 33 |
+
:command:`add_executable`:
|
| 34 |
+
|
| 35 |
+
* It will automatically be replaced by the location of the executable
|
| 36 |
+
created at build time.
|
| 37 |
+
|
| 38 |
+
* .. versionadded:: 3.3
|
| 39 |
+
|
| 40 |
+
The target's :prop_tgt:`CROSSCOMPILING_EMULATOR`, if set, will be
|
| 41 |
+
used to run the command on the host::
|
| 42 |
+
|
| 43 |
+
<emulator> <command>
|
| 44 |
+
|
| 45 |
+
.. versionchanged:: 3.29
|
| 46 |
+
|
| 47 |
+
The emulator is used only when
|
| 48 |
+
:variable:`cross-compiling <CMAKE_CROSSCOMPILING>`.
|
| 49 |
+
See policy :policy:`CMP0158`.
|
| 50 |
+
|
| 51 |
+
* .. versionadded:: 3.29
|
| 52 |
+
|
| 53 |
+
The target's :prop_tgt:`TEST_LAUNCHER`, if set, will be
|
| 54 |
+
used to launch the command::
|
| 55 |
+
|
| 56 |
+
<launcher> <command>
|
| 57 |
+
|
| 58 |
+
If the :prop_tgt:`CROSSCOMPILING_EMULATOR` is also set, both are used::
|
| 59 |
+
|
| 60 |
+
<launcher> <emulator> <command>
|
| 61 |
+
|
| 62 |
+
The command may be specified using
|
| 63 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 64 |
+
|
| 65 |
+
``CONFIGURATIONS``
|
| 66 |
+
Restrict execution of the test only to the named configurations.
|
| 67 |
+
|
| 68 |
+
``WORKING_DIRECTORY``
|
| 69 |
+
Set the test property :prop_test:`WORKING_DIRECTORY` in which to execute the
|
| 70 |
+
test. If not specified, the test will be run in
|
| 71 |
+
:variable:`CMAKE_CURRENT_BINARY_DIR`. The working directory may be specified
|
| 72 |
+
using :manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 73 |
+
|
| 74 |
+
``COMMAND_EXPAND_LISTS``
|
| 75 |
+
.. versionadded:: 3.16
|
| 76 |
+
|
| 77 |
+
Lists in ``COMMAND`` arguments will be expanded, including those created with
|
| 78 |
+
:manual:`generator expressions <cmake-generator-expressions(7)>`.
|
| 79 |
+
|
| 80 |
+
If the test command exits with code ``0`` the test passes. Non-zero exit code
|
| 81 |
+
is a "failed" test. The test property :prop_test:`WILL_FAIL` inverts this
|
| 82 |
+
logic. Note that system-level test failures such as segmentation faults or
|
| 83 |
+
heap errors will still fail the test even if ``WILL_FAIL`` is true. Output
|
| 84 |
+
written to stdout or stderr is captured by :manual:`ctest(1)` and only
|
| 85 |
+
affects the pass/fail status via the :prop_test:`PASS_REGULAR_EXPRESSION`,
|
| 86 |
+
:prop_test:`FAIL_REGULAR_EXPRESSION`, or :prop_test:`SKIP_REGULAR_EXPRESSION`
|
| 87 |
+
test properties.
|
| 88 |
+
|
| 89 |
+
.. versionadded:: 3.16
|
| 90 |
+
Added :prop_test:`SKIP_REGULAR_EXPRESSION` property.
|
| 91 |
+
|
| 92 |
+
Example usage:
|
| 93 |
+
|
| 94 |
+
.. code-block:: cmake
|
| 95 |
+
|
| 96 |
+
add_test(NAME mytest
|
| 97 |
+
COMMAND testDriver --config $<CONFIG>
|
| 98 |
+
--exe $<TARGET_FILE:myexe>)
|
| 99 |
+
|
| 100 |
+
This creates a test ``mytest`` whose command runs a ``testDriver`` tool
|
| 101 |
+
passing the configuration name and the full path to the executable
|
| 102 |
+
file produced by target ``myexe``.
|
| 103 |
+
|
| 104 |
+
---------------------------------------------------------------------
|
| 105 |
+
|
| 106 |
+
The command syntax above is recommended over the older, less flexible form:
|
| 107 |
+
|
| 108 |
+
.. code-block:: cmake
|
| 109 |
+
|
| 110 |
+
add_test(<name> <command> [<arg>...])
|
| 111 |
+
|
| 112 |
+
Add a test called ``<name>`` with the given command-line.
|
| 113 |
+
|
| 114 |
+
Unlike the above ``NAME`` signature, target names are not supported
|
| 115 |
+
in the command-line. Furthermore, tests added with this signature do not
|
| 116 |
+
support :manual:`generator expressions <cmake-generator-expressions(7)>`
|
| 117 |
+
in the command-line or test properties.
|
cmake/share/cmake-3.31/Help/command/aux_source_directory.rst
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aux_source_directory
|
| 2 |
+
--------------------
|
| 3 |
+
|
| 4 |
+
Find all source files in a directory.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
aux_source_directory(<dir> <variable>)
|
| 9 |
+
|
| 10 |
+
Collects the names of all the source files in the specified directory
|
| 11 |
+
and stores the list in the ``<variable>`` provided. This command is
|
| 12 |
+
intended to be used by projects that use explicit template
|
| 13 |
+
instantiation. Template instantiation files can be stored in a
|
| 14 |
+
``Templates`` subdirectory and collected automatically using this
|
| 15 |
+
command to avoid manually listing all instantiations.
|
| 16 |
+
|
| 17 |
+
It is tempting to use this command to avoid writing the list of source
|
| 18 |
+
files for a library or executable target. While this seems to work,
|
| 19 |
+
there is no way for CMake to generate a build system that knows when a
|
| 20 |
+
new source file has been added. Normally the generated build system
|
| 21 |
+
knows when it needs to rerun CMake because the ``CMakeLists.txt`` file is
|
| 22 |
+
modified to add a new source. When the source is just added to the
|
| 23 |
+
directory without modifying this file, one would have to manually
|
| 24 |
+
rerun CMake to generate a build system incorporating the new file.
|
cmake/share/cmake-3.31/Help/command/block.rst
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
block
|
| 2 |
+
-----
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.25
|
| 5 |
+
|
| 6 |
+
Evaluate a group of commands with a dedicated variable and/or policy scope.
|
| 7 |
+
|
| 8 |
+
.. code-block:: cmake
|
| 9 |
+
|
| 10 |
+
block([SCOPE_FOR [POLICIES] [VARIABLES] ] [PROPAGATE <var-name>...])
|
| 11 |
+
<commands>
|
| 12 |
+
endblock()
|
| 13 |
+
|
| 14 |
+
All commands between ``block()`` and the matching :command:`endblock` are
|
| 15 |
+
recorded without being invoked. Once the :command:`endblock` is evaluated, the
|
| 16 |
+
recorded list of commands is invoked inside the requested scopes, then the
|
| 17 |
+
scopes created by the ``block()`` command are removed.
|
| 18 |
+
|
| 19 |
+
``SCOPE_FOR``
|
| 20 |
+
Specify which scopes must be created.
|
| 21 |
+
|
| 22 |
+
``POLICIES``
|
| 23 |
+
Create a new policy scope. This is equivalent to
|
| 24 |
+
:command:`cmake_policy(PUSH)` with an automatic
|
| 25 |
+
:command:`cmake_policy(POP)` when leaving the block scope.
|
| 26 |
+
|
| 27 |
+
``VARIABLES``
|
| 28 |
+
Create a new variable scope.
|
| 29 |
+
|
| 30 |
+
If ``SCOPE_FOR`` is not specified, this is equivalent to:
|
| 31 |
+
|
| 32 |
+
.. code-block:: cmake
|
| 33 |
+
|
| 34 |
+
block(SCOPE_FOR VARIABLES POLICIES)
|
| 35 |
+
|
| 36 |
+
``PROPAGATE``
|
| 37 |
+
When a variable scope is created by the :command:`block` command, this
|
| 38 |
+
option sets or unsets the specified variables in the parent scope. This is
|
| 39 |
+
equivalent to :command:`set(PARENT_SCOPE)` or :command:`unset(PARENT_SCOPE)`
|
| 40 |
+
commands.
|
| 41 |
+
|
| 42 |
+
.. code-block:: cmake
|
| 43 |
+
|
| 44 |
+
set(var1 "INIT1")
|
| 45 |
+
set(var2 "INIT2")
|
| 46 |
+
|
| 47 |
+
block(PROPAGATE var1 var2)
|
| 48 |
+
set(var1 "VALUE1")
|
| 49 |
+
unset(var2)
|
| 50 |
+
endblock()
|
| 51 |
+
|
| 52 |
+
# Now var1 holds VALUE1, and var2 is unset
|
| 53 |
+
|
| 54 |
+
This option is only allowed when a variable scope is created. An error will
|
| 55 |
+
be raised in the other cases.
|
| 56 |
+
|
| 57 |
+
When the ``block()`` is inside a :command:`foreach` or :command:`while`
|
| 58 |
+
command, the :command:`break` and :command:`continue` commands can be used
|
| 59 |
+
inside the block.
|
| 60 |
+
|
| 61 |
+
.. code-block:: cmake
|
| 62 |
+
|
| 63 |
+
while(TRUE)
|
| 64 |
+
block()
|
| 65 |
+
...
|
| 66 |
+
# the break() command will terminate the while() command
|
| 67 |
+
break()
|
| 68 |
+
endblock()
|
| 69 |
+
endwhile()
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
See Also
|
| 73 |
+
^^^^^^^^
|
| 74 |
+
|
| 75 |
+
* :command:`endblock`
|
| 76 |
+
* :command:`return`
|
| 77 |
+
* :command:`cmake_policy`
|
cmake/share/cmake-3.31/Help/command/break.rst
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
break
|
| 2 |
+
-----
|
| 3 |
+
|
| 4 |
+
Break from an enclosing foreach or while loop.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
break()
|
| 9 |
+
|
| 10 |
+
Breaks from an enclosing :command:`foreach` or :command:`while` loop.
|
| 11 |
+
|
| 12 |
+
See also the :command:`continue` command.
|
cmake/share/cmake-3.31/Help/command/build_command.rst
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
build_command
|
| 2 |
+
-------------
|
| 3 |
+
|
| 4 |
+
Get a command line to build the current project.
|
| 5 |
+
This is mainly intended for internal use by the :module:`CTest` module.
|
| 6 |
+
|
| 7 |
+
.. code-block:: cmake
|
| 8 |
+
|
| 9 |
+
build_command(<variable>
|
| 10 |
+
[CONFIGURATION <config>]
|
| 11 |
+
[PARALLEL_LEVEL <parallel>]
|
| 12 |
+
[TARGET <target>]
|
| 13 |
+
[PROJECT_NAME <projname>] # legacy, causes warning
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
Sets the given ``<variable>`` to a command-line string of the form::
|
| 17 |
+
|
| 18 |
+
<cmake> --build . [--config <config>] [--parallel <parallel>] [--target <target>...] [-- -i]
|
| 19 |
+
|
| 20 |
+
where ``<cmake>`` is the location of the :manual:`cmake(1)` command-line
|
| 21 |
+
tool, and ``<config>``, ``<parallel>`` and ``<target>`` are the values
|
| 22 |
+
provided to the ``CONFIGURATION``, ``PARALLEL_LEVEL`` and ``TARGET``
|
| 23 |
+
options, if any. The trailing ``-- -i`` option is added for
|
| 24 |
+
:ref:`Makefile Generators` if policy :policy:`CMP0061` is not set to
|
| 25 |
+
``NEW``.
|
| 26 |
+
|
| 27 |
+
When invoked, this :option:`cmake --build` command line will launch the
|
| 28 |
+
underlying build system tool.
|
| 29 |
+
|
| 30 |
+
.. versionadded:: 3.21
|
| 31 |
+
The ``PARALLEL_LEVEL`` argument can be used to set the
|
| 32 |
+
:option:`--parallel <cmake--build --parallel>` flag.
|
| 33 |
+
|
| 34 |
+
.. code-block:: cmake
|
| 35 |
+
|
| 36 |
+
build_command(<cachevariable> <makecommand>)
|
| 37 |
+
|
| 38 |
+
This second signature is deprecated, but still available for backwards
|
| 39 |
+
compatibility. Use the first signature instead.
|
| 40 |
+
|
| 41 |
+
It sets the given ``<cachevariable>`` to a command-line string as
|
| 42 |
+
above but without the :option:`--target <cmake--build --target>` option.
|
| 43 |
+
The ``<makecommand>`` is ignored but should be the full path to
|
| 44 |
+
devenv, nmake, make or one of the end user build tools
|
| 45 |
+
for legacy invocations.
|
| 46 |
+
|
| 47 |
+
.. note::
|
| 48 |
+
In CMake versions prior to 3.0 this command returned a command
|
| 49 |
+
line that directly invokes the native build tool for the current
|
| 50 |
+
generator. Their implementation of the ``PROJECT_NAME`` option
|
| 51 |
+
had no useful effects, so CMake now warns on use of the option.
|
cmake/share/cmake-3.31/Help/command/build_name.rst
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
build_name
|
| 2 |
+
----------
|
| 3 |
+
|
| 4 |
+
Disallowed since version 3.0. See CMake Policy :policy:`CMP0036`.
|
| 5 |
+
|
| 6 |
+
Use ``${CMAKE_SYSTEM}`` and ``${CMAKE_CXX_COMPILER}`` instead.
|
| 7 |
+
|
| 8 |
+
.. code-block:: cmake
|
| 9 |
+
|
| 10 |
+
build_name(variable)
|
| 11 |
+
|
| 12 |
+
Sets the specified variable to a string representing the platform and
|
| 13 |
+
compiler settings. These values are now available through the
|
| 14 |
+
:variable:`CMAKE_SYSTEM` and
|
| 15 |
+
:variable:`CMAKE_CXX_COMPILER <CMAKE_<LANG>_COMPILER>` variables.
|
cmake/share/cmake-3.31/Help/command/cmake_file_api.rst
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_file_api
|
| 2 |
+
--------------
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.27
|
| 5 |
+
|
| 6 |
+
Enables interacting with the :manual:`CMake file API <cmake-file-api(7)>`.
|
| 7 |
+
|
| 8 |
+
.. signature::
|
| 9 |
+
cmake_file_api(QUERY ...)
|
| 10 |
+
|
| 11 |
+
The ``QUERY`` subcommand adds a file API query for the current CMake
|
| 12 |
+
invocation.
|
| 13 |
+
|
| 14 |
+
.. code-block:: cmake
|
| 15 |
+
|
| 16 |
+
cmake_file_api(
|
| 17 |
+
QUERY
|
| 18 |
+
API_VERSION <version>
|
| 19 |
+
[CODEMODEL <versions>...]
|
| 20 |
+
[CACHE <versions>...]
|
| 21 |
+
[CMAKEFILES <versions>...]
|
| 22 |
+
[TOOLCHAINS <versions>...]
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
The ``API_VERSION`` must always be given. Currently, the only supported
|
| 26 |
+
value for ``<version>`` is 1. See :ref:`file-api v1` for details of the
|
| 27 |
+
reply content and location.
|
| 28 |
+
|
| 29 |
+
Each of the optional keywords ``CODEMODEL``, ``CACHE``, ``CMAKEFILES`` and
|
| 30 |
+
``TOOLCHAINS`` correspond to one of the object kinds that can be requested
|
| 31 |
+
by the project. The ``configureLog`` object kind cannot be set with this
|
| 32 |
+
command, since it must be set before CMake starts reading the top level
|
| 33 |
+
``CMakeLists.txt`` file.
|
| 34 |
+
|
| 35 |
+
For each of the optional keywords, the ``<versions>`` list must contain one
|
| 36 |
+
or more version values of the form ``major`` or ``major.minor``, where
|
| 37 |
+
``major`` and ``minor`` are integers. Projects should list the versions they
|
| 38 |
+
accept in their preferred order, as only the first supported value from the
|
| 39 |
+
list will be selected. The command will ignore versions with a ``major``
|
| 40 |
+
version higher than any major version it supports for that object kind.
|
| 41 |
+
It will raise an error if it encounters an invalid version number, or if none
|
| 42 |
+
of the requested versions is supported.
|
| 43 |
+
|
| 44 |
+
For each type of object kind requested, a query equivalent to a shared,
|
| 45 |
+
stateless query will be added internally. No query file will be created in
|
| 46 |
+
the file system. The reply *will* be written to the file system at
|
| 47 |
+
generation time.
|
| 48 |
+
|
| 49 |
+
It is not an error to add a query for the same thing more than once, whether
|
| 50 |
+
from query files or from multiple calls to ``cmake_file_api(QUERY)``.
|
| 51 |
+
The final set of queries will be a merged combination of all queries
|
| 52 |
+
specified on disk and queries submitted by the project.
|
| 53 |
+
|
| 54 |
+
Example
|
| 55 |
+
^^^^^^^
|
| 56 |
+
|
| 57 |
+
A project may want to use replies from the file API at build time to implement
|
| 58 |
+
some form of verification task. Instead of relying on something outside of
|
| 59 |
+
CMake to create a query file, the project can use ``cmake_file_api(QUERY)``
|
| 60 |
+
to request the required information for the current run. It can then create
|
| 61 |
+
a custom command to run at build time, knowing that the requested information
|
| 62 |
+
should always be available.
|
| 63 |
+
|
| 64 |
+
.. code-block:: cmake
|
| 65 |
+
|
| 66 |
+
cmake_file_api(
|
| 67 |
+
QUERY
|
| 68 |
+
API_VERSION 1
|
| 69 |
+
CODEMODEL 2.3
|
| 70 |
+
TOOLCHAINS 1
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
add_custom_target(verify_project
|
| 74 |
+
COMMAND ${CMAKE_COMMAND}
|
| 75 |
+
-D BUILD_DIR=${CMAKE_BINARY_DIR}
|
| 76 |
+
-D CONFIG=$<CONFIG>
|
| 77 |
+
-P ${CMAKE_CURRENT_SOURCE_DIR}/verify_project.cmake
|
| 78 |
+
)
|
cmake/share/cmake-3.31/Help/command/cmake_host_system_information.rst
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_host_system_information
|
| 2 |
+
-----------------------------
|
| 3 |
+
|
| 4 |
+
Query various host system information.
|
| 5 |
+
|
| 6 |
+
Synopsis
|
| 7 |
+
^^^^^^^^
|
| 8 |
+
|
| 9 |
+
.. parsed-literal::
|
| 10 |
+
|
| 11 |
+
`Query host system specific information`_
|
| 12 |
+
cmake_host_system_information(RESULT <variable> QUERY <key> ...)
|
| 13 |
+
|
| 14 |
+
`Query Windows registry`_
|
| 15 |
+
cmake_host_system_information(RESULT <variable> QUERY WINDOWS_REGISTRY <key> ...)
|
| 16 |
+
|
| 17 |
+
Query host system specific information
|
| 18 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 19 |
+
|
| 20 |
+
.. code-block:: cmake
|
| 21 |
+
|
| 22 |
+
cmake_host_system_information(RESULT <variable> QUERY <key> ...)
|
| 23 |
+
|
| 24 |
+
Queries system information of the host system on which cmake runs.
|
| 25 |
+
One or more ``<key>`` can be provided to select the information to be
|
| 26 |
+
queried. The list of queried values is stored in ``<variable>``.
|
| 27 |
+
|
| 28 |
+
``<key>`` can be one of the following values:
|
| 29 |
+
|
| 30 |
+
``NUMBER_OF_LOGICAL_CORES``
|
| 31 |
+
Number of logical cores
|
| 32 |
+
|
| 33 |
+
``NUMBER_OF_PHYSICAL_CORES``
|
| 34 |
+
Number of physical cores
|
| 35 |
+
|
| 36 |
+
``HOSTNAME``
|
| 37 |
+
Hostname
|
| 38 |
+
|
| 39 |
+
``FQDN``
|
| 40 |
+
Fully qualified domain name
|
| 41 |
+
|
| 42 |
+
``TOTAL_VIRTUAL_MEMORY``
|
| 43 |
+
Total virtual memory in MiB [#mebibytes]_
|
| 44 |
+
|
| 45 |
+
``AVAILABLE_VIRTUAL_MEMORY``
|
| 46 |
+
Available virtual memory in MiB [#mebibytes]_
|
| 47 |
+
|
| 48 |
+
``TOTAL_PHYSICAL_MEMORY``
|
| 49 |
+
Total physical memory in MiB [#mebibytes]_
|
| 50 |
+
|
| 51 |
+
``AVAILABLE_PHYSICAL_MEMORY``
|
| 52 |
+
Available physical memory in MiB [#mebibytes]_
|
| 53 |
+
|
| 54 |
+
``IS_64BIT``
|
| 55 |
+
.. versionadded:: 3.10
|
| 56 |
+
|
| 57 |
+
One if processor is 64Bit
|
| 58 |
+
|
| 59 |
+
``HAS_FPU``
|
| 60 |
+
.. versionadded:: 3.10
|
| 61 |
+
|
| 62 |
+
One if processor has floating point unit
|
| 63 |
+
|
| 64 |
+
``HAS_MMX``
|
| 65 |
+
.. versionadded:: 3.10
|
| 66 |
+
|
| 67 |
+
One if processor supports MMX instructions
|
| 68 |
+
|
| 69 |
+
``HAS_MMX_PLUS``
|
| 70 |
+
.. versionadded:: 3.10
|
| 71 |
+
|
| 72 |
+
One if processor supports Ext. MMX instructions
|
| 73 |
+
|
| 74 |
+
``HAS_SSE``
|
| 75 |
+
.. versionadded:: 3.10
|
| 76 |
+
|
| 77 |
+
One if processor supports SSE instructions
|
| 78 |
+
|
| 79 |
+
``HAS_SSE2``
|
| 80 |
+
.. versionadded:: 3.10
|
| 81 |
+
|
| 82 |
+
One if processor supports SSE2 instructions
|
| 83 |
+
|
| 84 |
+
``HAS_SSE_FP``
|
| 85 |
+
.. versionadded:: 3.10
|
| 86 |
+
|
| 87 |
+
One if processor supports SSE FP instructions
|
| 88 |
+
|
| 89 |
+
``HAS_SSE_MMX``
|
| 90 |
+
.. versionadded:: 3.10
|
| 91 |
+
|
| 92 |
+
One if processor supports SSE MMX instructions
|
| 93 |
+
|
| 94 |
+
``HAS_AMD_3DNOW``
|
| 95 |
+
.. versionadded:: 3.10
|
| 96 |
+
|
| 97 |
+
One if processor supports 3DNow instructions
|
| 98 |
+
|
| 99 |
+
``HAS_AMD_3DNOW_PLUS``
|
| 100 |
+
.. versionadded:: 3.10
|
| 101 |
+
|
| 102 |
+
One if processor supports 3DNow+ instructions
|
| 103 |
+
|
| 104 |
+
``HAS_IA64``
|
| 105 |
+
.. versionadded:: 3.10
|
| 106 |
+
|
| 107 |
+
One if IA64 processor emulating x86
|
| 108 |
+
|
| 109 |
+
``HAS_SERIAL_NUMBER``
|
| 110 |
+
.. versionadded:: 3.10
|
| 111 |
+
|
| 112 |
+
One if processor has serial number
|
| 113 |
+
|
| 114 |
+
``PROCESSOR_SERIAL_NUMBER``
|
| 115 |
+
.. versionadded:: 3.10
|
| 116 |
+
|
| 117 |
+
Processor serial number
|
| 118 |
+
|
| 119 |
+
``PROCESSOR_NAME``
|
| 120 |
+
.. versionadded:: 3.10
|
| 121 |
+
|
| 122 |
+
Human readable processor name
|
| 123 |
+
|
| 124 |
+
``PROCESSOR_DESCRIPTION``
|
| 125 |
+
.. versionadded:: 3.10
|
| 126 |
+
|
| 127 |
+
Human readable full processor description
|
| 128 |
+
|
| 129 |
+
``OS_NAME``
|
| 130 |
+
.. versionadded:: 3.10
|
| 131 |
+
|
| 132 |
+
See :variable:`CMAKE_HOST_SYSTEM_NAME`
|
| 133 |
+
|
| 134 |
+
``OS_RELEASE``
|
| 135 |
+
.. versionadded:: 3.10
|
| 136 |
+
|
| 137 |
+
The OS sub-type e.g. on Windows ``Professional``
|
| 138 |
+
|
| 139 |
+
``OS_VERSION``
|
| 140 |
+
.. versionadded:: 3.10
|
| 141 |
+
|
| 142 |
+
The OS build ID
|
| 143 |
+
|
| 144 |
+
``OS_PLATFORM``
|
| 145 |
+
.. versionadded:: 3.10
|
| 146 |
+
|
| 147 |
+
See :variable:`CMAKE_HOST_SYSTEM_PROCESSOR`
|
| 148 |
+
|
| 149 |
+
``MSYSTEM_PREFIX``
|
| 150 |
+
.. versionadded:: 3.28
|
| 151 |
+
|
| 152 |
+
Available only on Windows hosts. In a MSYS or MinGW development
|
| 153 |
+
environment that sets the ``MSYSTEM`` environment variable, this
|
| 154 |
+
is its installation prefix. Otherwise, this is the empty string.
|
| 155 |
+
|
| 156 |
+
``DISTRIB_INFO``
|
| 157 |
+
.. versionadded:: 3.22
|
| 158 |
+
|
| 159 |
+
Read :file:`/etc/os-release` file and define the given ``<variable>``
|
| 160 |
+
into a list of read variables
|
| 161 |
+
|
| 162 |
+
``DISTRIB_<name>``
|
| 163 |
+
.. versionadded:: 3.22
|
| 164 |
+
|
| 165 |
+
Get the ``<name>`` variable (see `man 5 os-release`_) if it exists in the
|
| 166 |
+
:file:`/etc/os-release` file
|
| 167 |
+
|
| 168 |
+
Example:
|
| 169 |
+
|
| 170 |
+
.. code-block:: cmake
|
| 171 |
+
|
| 172 |
+
cmake_host_system_information(RESULT PRETTY_NAME QUERY DISTRIB_PRETTY_NAME)
|
| 173 |
+
message(STATUS "${PRETTY_NAME}")
|
| 174 |
+
|
| 175 |
+
cmake_host_system_information(RESULT DISTRO QUERY DISTRIB_INFO)
|
| 176 |
+
|
| 177 |
+
foreach(VAR IN LISTS DISTRO)
|
| 178 |
+
message(STATUS "${VAR}=`${${VAR}}`")
|
| 179 |
+
endforeach()
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
Output::
|
| 183 |
+
|
| 184 |
+
-- Ubuntu 20.04.2 LTS
|
| 185 |
+
-- DISTRO_BUG_REPORT_URL=`https://bugs.launchpad.net/ubuntu/`
|
| 186 |
+
-- DISTRO_HOME_URL=`https://www.ubuntu.com/`
|
| 187 |
+
-- DISTRO_ID=`ubuntu`
|
| 188 |
+
-- DISTRO_ID_LIKE=`debian`
|
| 189 |
+
-- DISTRO_NAME=`Ubuntu`
|
| 190 |
+
-- DISTRO_PRETTY_NAME=`Ubuntu 20.04.2 LTS`
|
| 191 |
+
-- DISTRO_PRIVACY_POLICY_URL=`https://www.ubuntu.com/legal/terms-and-policies/privacy-policy`
|
| 192 |
+
-- DISTRO_SUPPORT_URL=`https://help.ubuntu.com/`
|
| 193 |
+
-- DISTRO_UBUNTU_CODENAME=`focal`
|
| 194 |
+
-- DISTRO_VERSION=`20.04.2 LTS (Focal Fossa)`
|
| 195 |
+
-- DISTRO_VERSION_CODENAME=`focal`
|
| 196 |
+
-- DISTRO_VERSION_ID=`20.04`
|
| 197 |
+
|
| 198 |
+
If :file:`/etc/os-release` file is not found, the command tries to gather OS
|
| 199 |
+
identification via fallback scripts. The fallback script can use `various
|
| 200 |
+
distribution-specific files`_ to collect OS identification data and map it
|
| 201 |
+
into `man 5 os-release`_ variables.
|
| 202 |
+
|
| 203 |
+
Fallback Interface Variables
|
| 204 |
+
""""""""""""""""""""""""""""
|
| 205 |
+
|
| 206 |
+
.. variable:: CMAKE_GET_OS_RELEASE_FALLBACK_SCRIPTS
|
| 207 |
+
|
| 208 |
+
In addition to the scripts shipped with CMake, a user may append full
|
| 209 |
+
paths to his script(s) to the this list. The script filename has the
|
| 210 |
+
following format: ``NNN-<name>.cmake``, where ``NNN`` is three digits
|
| 211 |
+
used to apply collected scripts in a specific order.
|
| 212 |
+
|
| 213 |
+
.. variable:: CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_<varname>
|
| 214 |
+
|
| 215 |
+
Variables collected by the user provided fallback script
|
| 216 |
+
ought to be assigned to CMake variables using this naming
|
| 217 |
+
convention. Example, the ``ID`` variable from the manual becomes
|
| 218 |
+
``CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID``.
|
| 219 |
+
|
| 220 |
+
.. variable:: CMAKE_GET_OS_RELEASE_FALLBACK_RESULT
|
| 221 |
+
|
| 222 |
+
The fallback script ought to store names of all assigned
|
| 223 |
+
``CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_<varname>`` variables in this list.
|
| 224 |
+
|
| 225 |
+
Example:
|
| 226 |
+
|
| 227 |
+
.. code-block:: cmake
|
| 228 |
+
|
| 229 |
+
# Try to detect some old distribution
|
| 230 |
+
# See also
|
| 231 |
+
# - http://linuxmafia.com/faq/Admin/release-files.html
|
| 232 |
+
#
|
| 233 |
+
if(NOT EXISTS "${CMAKE_SYSROOT}/etc/foobar-release")
|
| 234 |
+
return()
|
| 235 |
+
endif()
|
| 236 |
+
# Get the first string only
|
| 237 |
+
file(
|
| 238 |
+
STRINGS "${CMAKE_SYSROOT}/etc/foobar-release" CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT
|
| 239 |
+
LIMIT_COUNT 1
|
| 240 |
+
)
|
| 241 |
+
#
|
| 242 |
+
# Example:
|
| 243 |
+
#
|
| 244 |
+
# Foobar distribution release 1.2.3 (server)
|
| 245 |
+
#
|
| 246 |
+
if(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT MATCHES "Foobar distribution release ([0-9\.]+) .*")
|
| 247 |
+
set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME Foobar)
|
| 248 |
+
set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME "${CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT}")
|
| 249 |
+
set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID foobar)
|
| 250 |
+
set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION ${CMAKE_MATCH_1})
|
| 251 |
+
set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID ${CMAKE_MATCH_1})
|
| 252 |
+
list(
|
| 253 |
+
APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT
|
| 254 |
+
CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME
|
| 255 |
+
CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME
|
| 256 |
+
CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID
|
| 257 |
+
CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION
|
| 258 |
+
CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID
|
| 259 |
+
)
|
| 260 |
+
endif()
|
| 261 |
+
unset(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT)
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
.. rubric:: Footnotes
|
| 265 |
+
|
| 266 |
+
.. [#mebibytes] One MiB (mebibyte) is equal to 1024x1024 bytes.
|
| 267 |
+
|
| 268 |
+
.. _man 5 os-release: https://www.freedesktop.org/software/systemd/man/latest/os-release.html
|
| 269 |
+
.. _various distribution-specific files: http://linuxmafia.com/faq/Admin/release-files.html
|
| 270 |
+
|
| 271 |
+
.. _Query Windows registry:
|
| 272 |
+
|
| 273 |
+
Query Windows registry
|
| 274 |
+
^^^^^^^^^^^^^^^^^^^^^^
|
| 275 |
+
|
| 276 |
+
.. versionadded:: 3.24
|
| 277 |
+
|
| 278 |
+
::
|
| 279 |
+
|
| 280 |
+
cmake_host_system_information(RESULT <variable>
|
| 281 |
+
QUERY WINDOWS_REGISTRY <key> [VALUE_NAMES|SUBKEYS|VALUE <name>]
|
| 282 |
+
[VIEW (64|32|64_32|32_64|HOST|TARGET|BOTH)]
|
| 283 |
+
[SEPARATOR <separator>]
|
| 284 |
+
[ERROR_VARIABLE <result>])
|
| 285 |
+
|
| 286 |
+
Performs query operations on local computer registry subkey. Returns a list of
|
| 287 |
+
subkeys or value names that are located under the specified subkey in the
|
| 288 |
+
registry or the data of the specified value name. The result of the queried
|
| 289 |
+
entity is stored in ``<variable>``.
|
| 290 |
+
|
| 291 |
+
.. note::
|
| 292 |
+
|
| 293 |
+
Querying registry for any other platforms than ``Windows``, including
|
| 294 |
+
``CYGWIN``, will always returns an empty string and sets an error message in
|
| 295 |
+
the variable specified with sub-option ``ERROR_VARIABLE``.
|
| 296 |
+
|
| 297 |
+
``<key>`` specify the full path of a subkey on the local computer. The
|
| 298 |
+
``<key>`` must include a valid root key. Valid root keys for the local computer
|
| 299 |
+
are:
|
| 300 |
+
|
| 301 |
+
* ``HKLM`` or ``HKEY_LOCAL_MACHINE``
|
| 302 |
+
* ``HKCU`` or ``HKEY_CURRENT_USER``
|
| 303 |
+
* ``HKCR`` or ``HKEY_CLASSES_ROOT``
|
| 304 |
+
* ``HKU`` or ``HKEY_USERS``
|
| 305 |
+
* ``HKCC`` or ``HKEY_CURRENT_CONFIG``
|
| 306 |
+
|
| 307 |
+
And, optionally, the path to a subkey under the specified root key. The path
|
| 308 |
+
separator can be the slash or the backslash. ``<key>`` is not case sensitive.
|
| 309 |
+
For example:
|
| 310 |
+
|
| 311 |
+
.. code-block:: cmake
|
| 312 |
+
|
| 313 |
+
cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKLM")
|
| 314 |
+
cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Kitware")
|
| 315 |
+
cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU\\SOFTWARE\\Kitware")
|
| 316 |
+
|
| 317 |
+
``VALUE_NAMES``
|
| 318 |
+
Request the list of value names defined under ``<key>``. If a default value
|
| 319 |
+
is defined, it will be identified with the special name ``(default)``.
|
| 320 |
+
|
| 321 |
+
``SUBKEYS``
|
| 322 |
+
Request the list of subkeys defined under ``<key>``.
|
| 323 |
+
|
| 324 |
+
``VALUE <name>``
|
| 325 |
+
Request the data stored in value named ``<name>``. If ``VALUE`` is not
|
| 326 |
+
specified or argument is the special name ``(default)``, the content of the
|
| 327 |
+
default value, if any, will be returned.
|
| 328 |
+
|
| 329 |
+
.. code-block:: cmake
|
| 330 |
+
|
| 331 |
+
# query default value for HKLM/SOFTWARE/Kitware key
|
| 332 |
+
cmake_host_system_information(RESULT result
|
| 333 |
+
QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Kitware")
|
| 334 |
+
|
| 335 |
+
# query default value for HKLM/SOFTWARE/Kitware key using special value name
|
| 336 |
+
cmake_host_system_information(RESULT result
|
| 337 |
+
QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Kitware"
|
| 338 |
+
VALUE "(default)")
|
| 339 |
+
|
| 340 |
+
Supported types are:
|
| 341 |
+
|
| 342 |
+
* ``REG_SZ``.
|
| 343 |
+
* ``REG_EXPAND_SZ``. The returned data is expanded.
|
| 344 |
+
* ``REG_MULTI_SZ``. The returned is expressed as a CMake list. See also
|
| 345 |
+
``SEPARATOR`` sub-option.
|
| 346 |
+
* ``REG_DWORD``.
|
| 347 |
+
* ``REG_QWORD``.
|
| 348 |
+
|
| 349 |
+
For all other types, an empty string is returned.
|
| 350 |
+
|
| 351 |
+
``VIEW``
|
| 352 |
+
Specify which registry views must be queried. When not specified, ``BOTH``
|
| 353 |
+
view is used.
|
| 354 |
+
|
| 355 |
+
``64``
|
| 356 |
+
Query the 64bit registry. On ``32bit Windows``, returns always an empty
|
| 357 |
+
string.
|
| 358 |
+
|
| 359 |
+
``32``
|
| 360 |
+
Query the 32bit registry.
|
| 361 |
+
|
| 362 |
+
``64_32``
|
| 363 |
+
For ``VALUE`` sub-option or default value, query the registry using view
|
| 364 |
+
``64``, and if the request failed, query the registry using view ``32``.
|
| 365 |
+
For ``VALUE_NAMES`` and ``SUBKEYS`` sub-options, query both views (``64``
|
| 366 |
+
and ``32``) and merge the results (sorted and duplicates removed).
|
| 367 |
+
|
| 368 |
+
``32_64``
|
| 369 |
+
For ``VALUE`` sub-option or default value, query the registry using view
|
| 370 |
+
``32``, and if the request failed, query the registry using view ``64``.
|
| 371 |
+
For ``VALUE_NAMES`` and ``SUBKEYS`` sub-options, query both views (``32``
|
| 372 |
+
and ``64``) and merge the results (sorted and duplicates removed).
|
| 373 |
+
|
| 374 |
+
``HOST``
|
| 375 |
+
Query the registry matching the architecture of the host: ``64`` on ``64bit
|
| 376 |
+
Windows`` and ``32`` on ``32bit Windows``.
|
| 377 |
+
|
| 378 |
+
``TARGET``
|
| 379 |
+
Query the registry matching the architecture specified by
|
| 380 |
+
:variable:`CMAKE_SIZEOF_VOID_P` variable. If not defined, fallback to
|
| 381 |
+
``HOST`` view.
|
| 382 |
+
|
| 383 |
+
``BOTH``
|
| 384 |
+
Query both views (``32`` and ``64``). The order depends of the following
|
| 385 |
+
rules: If :variable:`CMAKE_SIZEOF_VOID_P` variable is defined. Use the
|
| 386 |
+
following view depending of the content of this variable:
|
| 387 |
+
|
| 388 |
+
* ``8``: ``64_32``
|
| 389 |
+
* ``4``: ``32_64``
|
| 390 |
+
|
| 391 |
+
If :variable:`CMAKE_SIZEOF_VOID_P` variable is not defined, rely on
|
| 392 |
+
architecture of the host:
|
| 393 |
+
|
| 394 |
+
* ``64bit``: ``64_32``
|
| 395 |
+
* ``32bit``: ``32``
|
| 396 |
+
|
| 397 |
+
``SEPARATOR``
|
| 398 |
+
Specify the separator character for ``REG_MULTI_SZ`` type. When not
|
| 399 |
+
specified, the character ``\0`` is used.
|
| 400 |
+
|
| 401 |
+
``ERROR_VARIABLE <result>``
|
| 402 |
+
Returns any error raised during query operation. In case of success, the
|
| 403 |
+
variable holds an empty string.
|
cmake/share/cmake-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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_language
|
| 2 |
+
--------------
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.18
|
| 5 |
+
|
| 6 |
+
Call meta-operations on CMake commands.
|
| 7 |
+
|
| 8 |
+
Synopsis
|
| 9 |
+
^^^^^^^^
|
| 10 |
+
|
| 11 |
+
.. parsed-literal::
|
| 12 |
+
|
| 13 |
+
cmake_language(`CALL`_ <command> [<arg>...])
|
| 14 |
+
cmake_language(`EVAL`_ CODE <code>...)
|
| 15 |
+
cmake_language(`DEFER`_ <options>... CALL <command> [<arg>...])
|
| 16 |
+
cmake_language(`SET_DEPENDENCY_PROVIDER`_ <command> SUPPORTED_METHODS <methods>...)
|
| 17 |
+
cmake_language(`GET_MESSAGE_LOG_LEVEL`_ <out-var>)
|
| 18 |
+
cmake_language(`EXIT`_ <exit-code>)
|
| 19 |
+
|
| 20 |
+
Introduction
|
| 21 |
+
^^^^^^^^^^^^
|
| 22 |
+
|
| 23 |
+
This command will call meta-operations on built-in CMake commands or
|
| 24 |
+
those created via the :command:`macro` or :command:`function` commands.
|
| 25 |
+
|
| 26 |
+
``cmake_language`` does not introduce a new variable or policy scope.
|
| 27 |
+
|
| 28 |
+
Calling Commands
|
| 29 |
+
^^^^^^^^^^^^^^^^
|
| 30 |
+
|
| 31 |
+
.. signature::
|
| 32 |
+
cmake_language(CALL <command> [<arg>...])
|
| 33 |
+
|
| 34 |
+
Calls the named ``<command>`` with the given arguments (if any).
|
| 35 |
+
For example, the code:
|
| 36 |
+
|
| 37 |
+
.. code-block:: cmake
|
| 38 |
+
|
| 39 |
+
set(message_command "message")
|
| 40 |
+
cmake_language(CALL ${message_command} STATUS "Hello World!")
|
| 41 |
+
|
| 42 |
+
is equivalent to
|
| 43 |
+
|
| 44 |
+
.. code-block:: cmake
|
| 45 |
+
|
| 46 |
+
message(STATUS "Hello World!")
|
| 47 |
+
|
| 48 |
+
.. note::
|
| 49 |
+
To ensure consistency of the code, the following commands are not allowed:
|
| 50 |
+
|
| 51 |
+
* ``if`` / ``elseif`` / ``else`` / ``endif``
|
| 52 |
+
* ``block`` / ``endblock``
|
| 53 |
+
* ``while`` / ``endwhile``
|
| 54 |
+
* ``foreach`` / ``endforeach``
|
| 55 |
+
* ``function`` / ``endfunction``
|
| 56 |
+
* ``macro`` / ``endmacro``
|
| 57 |
+
|
| 58 |
+
Evaluating Code
|
| 59 |
+
^^^^^^^^^^^^^^^
|
| 60 |
+
|
| 61 |
+
.. signature::
|
| 62 |
+
cmake_language(EVAL CODE <code>...)
|
| 63 |
+
:target: EVAL
|
| 64 |
+
|
| 65 |
+
Evaluates the ``<code>...`` as CMake code.
|
| 66 |
+
|
| 67 |
+
For example, the code:
|
| 68 |
+
|
| 69 |
+
.. code-block:: cmake
|
| 70 |
+
|
| 71 |
+
set(A TRUE)
|
| 72 |
+
set(B TRUE)
|
| 73 |
+
set(C TRUE)
|
| 74 |
+
set(condition "(A AND B) OR C")
|
| 75 |
+
|
| 76 |
+
cmake_language(EVAL CODE "
|
| 77 |
+
if (${condition})
|
| 78 |
+
message(STATUS TRUE)
|
| 79 |
+
else()
|
| 80 |
+
message(STATUS FALSE)
|
| 81 |
+
endif()"
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
is equivalent to
|
| 85 |
+
|
| 86 |
+
.. code-block:: cmake
|
| 87 |
+
|
| 88 |
+
set(A TRUE)
|
| 89 |
+
set(B TRUE)
|
| 90 |
+
set(C TRUE)
|
| 91 |
+
set(condition "(A AND B) OR C")
|
| 92 |
+
|
| 93 |
+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/eval.cmake "
|
| 94 |
+
if (${condition})
|
| 95 |
+
message(STATUS TRUE)
|
| 96 |
+
else()
|
| 97 |
+
message(STATUS FALSE)
|
| 98 |
+
endif()"
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
include(${CMAKE_CURRENT_BINARY_DIR}/eval.cmake)
|
| 102 |
+
|
| 103 |
+
Deferring Calls
|
| 104 |
+
^^^^^^^^^^^^^^^
|
| 105 |
+
|
| 106 |
+
.. versionadded:: 3.19
|
| 107 |
+
|
| 108 |
+
.. signature::
|
| 109 |
+
cmake_language(DEFER <options>... CALL <command> [<arg>...])
|
| 110 |
+
|
| 111 |
+
Schedules a call to the named ``<command>`` with the given arguments (if any)
|
| 112 |
+
to occur at a later time. By default, deferred calls are executed as if
|
| 113 |
+
written at the end of the current directory's ``CMakeLists.txt`` file,
|
| 114 |
+
except that they run even after a :command:`return` call. Variable
|
| 115 |
+
references in arguments are evaluated at the time the deferred call is
|
| 116 |
+
executed.
|
| 117 |
+
|
| 118 |
+
The options are:
|
| 119 |
+
|
| 120 |
+
``DIRECTORY <dir>``
|
| 121 |
+
Schedule the call for the end of the given directory instead of the
|
| 122 |
+
current directory. The ``<dir>`` may reference either a source
|
| 123 |
+
directory or its corresponding binary directory. Relative paths are
|
| 124 |
+
treated as relative to the current source directory.
|
| 125 |
+
|
| 126 |
+
The given directory must be known to CMake, being either the top-level
|
| 127 |
+
directory or one added by :command:`add_subdirectory`. Furthermore,
|
| 128 |
+
the given directory must not yet be finished processing. This means
|
| 129 |
+
it can be the current directory or one of its ancestors.
|
| 130 |
+
|
| 131 |
+
``ID <id>``
|
| 132 |
+
Specify an identification for the deferred call.
|
| 133 |
+
The ``<id>`` may not be empty and may not begin with a capital letter ``A-Z``.
|
| 134 |
+
The ``<id>`` may begin with an underscore (``_``) only if it was generated
|
| 135 |
+
automatically by an earlier call that used ``ID_VAR`` to get the id.
|
| 136 |
+
|
| 137 |
+
``ID_VAR <var>``
|
| 138 |
+
Specify a variable in which to store the identification for the
|
| 139 |
+
deferred call. If ``ID <id>`` is not given, a new identification
|
| 140 |
+
will be generated and the generated id will start with an underscore (``_``).
|
| 141 |
+
|
| 142 |
+
The currently scheduled list of deferred calls may be retrieved:
|
| 143 |
+
|
| 144 |
+
.. code-block:: cmake
|
| 145 |
+
|
| 146 |
+
cmake_language(DEFER [DIRECTORY <dir>] GET_CALL_IDS <var>)
|
| 147 |
+
|
| 148 |
+
This will store in ``<var>`` a :ref:`semicolon-separated list <CMake Language
|
| 149 |
+
Lists>` of deferred call ids. The ids are for the directory scope in which
|
| 150 |
+
the calls have been deferred to (i.e. where they will be executed), which can
|
| 151 |
+
be different to the scope in which they were created. The ``DIRECTORY``
|
| 152 |
+
option can be used to specify the scope for which to retrieve the call ids.
|
| 153 |
+
If that option is not given, the call ids for the current directory scope
|
| 154 |
+
will be returned.
|
| 155 |
+
|
| 156 |
+
Details of a specific call may be retrieved from its id:
|
| 157 |
+
|
| 158 |
+
.. code-block:: cmake
|
| 159 |
+
|
| 160 |
+
cmake_language(DEFER [DIRECTORY <dir>] GET_CALL <id> <var>)
|
| 161 |
+
|
| 162 |
+
This will store in ``<var>`` a :ref:`semicolon-separated list <CMake Language
|
| 163 |
+
Lists>` in which the first element is the name of the command to be
|
| 164 |
+
called, and the remaining elements are its unevaluated arguments (any
|
| 165 |
+
contained ``;`` characters are included literally and cannot be distinguished
|
| 166 |
+
from multiple arguments). If multiple calls are scheduled with the same id,
|
| 167 |
+
this retrieves the first one. If no call is scheduled with the given id in
|
| 168 |
+
the specified ``DIRECTORY`` scope (or the current directory scope if no
|
| 169 |
+
``DIRECTORY`` option is given), this stores an empty string in the variable.
|
| 170 |
+
|
| 171 |
+
Deferred calls may be canceled by their id:
|
| 172 |
+
|
| 173 |
+
.. code-block:: cmake
|
| 174 |
+
|
| 175 |
+
cmake_language(DEFER [DIRECTORY <dir>] CANCEL_CALL <id>...)
|
| 176 |
+
|
| 177 |
+
This cancels all deferred calls matching any of the given ids in the specified
|
| 178 |
+
``DIRECTORY`` scope (or the current directory scope if no ``DIRECTORY`` option
|
| 179 |
+
is given). Unknown ids are silently ignored.
|
| 180 |
+
|
| 181 |
+
Deferred Call Examples
|
| 182 |
+
""""""""""""""""""""""
|
| 183 |
+
|
| 184 |
+
For example, the code:
|
| 185 |
+
|
| 186 |
+
.. code-block:: cmake
|
| 187 |
+
|
| 188 |
+
cmake_language(DEFER CALL message "${deferred_message}")
|
| 189 |
+
cmake_language(DEFER ID_VAR id CALL message "Canceled Message")
|
| 190 |
+
cmake_language(DEFER CANCEL_CALL ${id})
|
| 191 |
+
message("Immediate Message")
|
| 192 |
+
set(deferred_message "Deferred Message")
|
| 193 |
+
|
| 194 |
+
prints::
|
| 195 |
+
|
| 196 |
+
Immediate Message
|
| 197 |
+
Deferred Message
|
| 198 |
+
|
| 199 |
+
The ``Canceled Message`` is never printed because its command is
|
| 200 |
+
canceled. The ``deferred_message`` variable reference is not evaluated
|
| 201 |
+
until the call site, so it can be set after the deferred call is scheduled.
|
| 202 |
+
|
| 203 |
+
In order to evaluate variable references immediately when scheduling a
|
| 204 |
+
deferred call, wrap it using ``cmake_language(EVAL)``. However, note that
|
| 205 |
+
arguments will be re-evaluated in the deferred call, though that can be
|
| 206 |
+
avoided by using bracket arguments. For example:
|
| 207 |
+
|
| 208 |
+
.. code-block:: cmake
|
| 209 |
+
|
| 210 |
+
set(deferred_message "Deferred Message 1")
|
| 211 |
+
set(re_evaluated [[${deferred_message}]])
|
| 212 |
+
cmake_language(EVAL CODE "
|
| 213 |
+
cmake_language(DEFER CALL message [[${deferred_message}]])
|
| 214 |
+
cmake_language(DEFER CALL message \"${re_evaluated}\")
|
| 215 |
+
")
|
| 216 |
+
message("Immediate Message")
|
| 217 |
+
set(deferred_message "Deferred Message 2")
|
| 218 |
+
|
| 219 |
+
also prints::
|
| 220 |
+
|
| 221 |
+
Immediate Message
|
| 222 |
+
Deferred Message 1
|
| 223 |
+
Deferred Message 2
|
| 224 |
+
|
| 225 |
+
.. _dependency_providers:
|
| 226 |
+
|
| 227 |
+
Dependency Providers
|
| 228 |
+
^^^^^^^^^^^^^^^^^^^^
|
| 229 |
+
|
| 230 |
+
.. versionadded:: 3.24
|
| 231 |
+
|
| 232 |
+
.. note:: A high-level introduction to this feature can be found in the
|
| 233 |
+
:ref:`Using Dependencies Guide <dependency_providers_overview>`.
|
| 234 |
+
|
| 235 |
+
.. signature::
|
| 236 |
+
cmake_language(SET_DEPENDENCY_PROVIDER <command>
|
| 237 |
+
SUPPORTED_METHODS <methods>...)
|
| 238 |
+
|
| 239 |
+
When a call is made to :command:`find_package` or
|
| 240 |
+
:command:`FetchContent_MakeAvailable`, the call may be forwarded to a
|
| 241 |
+
dependency provider which then has the opportunity to fulfill the request.
|
| 242 |
+
If the request is for one of the ``<methods>`` specified when the provider
|
| 243 |
+
was set, CMake calls the provider's ``<command>`` with a set of
|
| 244 |
+
method-specific arguments. If the provider does not fulfill the request,
|
| 245 |
+
or if the provider doesn't support the request's method, or no provider
|
| 246 |
+
is set, the built-in :command:`find_package` or
|
| 247 |
+
:command:`FetchContent_MakeAvailable` implementation is used to fulfill
|
| 248 |
+
the request in the usual way.
|
| 249 |
+
|
| 250 |
+
One or more of the following values can be specified for the ``<methods>``
|
| 251 |
+
when setting the provider:
|
| 252 |
+
|
| 253 |
+
``FIND_PACKAGE``
|
| 254 |
+
The provider command accepts :command:`find_package` requests.
|
| 255 |
+
|
| 256 |
+
``FETCHCONTENT_MAKEAVAILABLE_SERIAL``
|
| 257 |
+
The provider command accepts :command:`FetchContent_MakeAvailable`
|
| 258 |
+
requests. It expects each dependency to be fed to the provider command
|
| 259 |
+
one at a time, not the whole list in one go.
|
| 260 |
+
|
| 261 |
+
Only one provider can be set at any point in time. If a provider is already
|
| 262 |
+
set when ``cmake_language(SET_DEPENDENCY_PROVIDER)`` is called, the new
|
| 263 |
+
provider replaces the previously set one. The specified ``<command>`` must
|
| 264 |
+
already exist when ``cmake_language(SET_DEPENDENCY_PROVIDER)`` is called.
|
| 265 |
+
As a special case, providing an empty string for the ``<command>`` and no
|
| 266 |
+
``<methods>`` will discard any previously set provider.
|
| 267 |
+
|
| 268 |
+
The dependency provider can only be set while processing one of the files
|
| 269 |
+
specified by the :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variable.
|
| 270 |
+
Thus, dependency providers can only be set as part of the first call to
|
| 271 |
+
:command:`project`. Calling ``cmake_language(SET_DEPENDENCY_PROVIDER)``
|
| 272 |
+
outside of that context will result in an error.
|
| 273 |
+
|
| 274 |
+
.. versionadded:: 3.30
|
| 275 |
+
The :prop_gbl:`PROPAGATE_TOP_LEVEL_INCLUDES_TO_TRY_COMPILE` global
|
| 276 |
+
property can be set if the dependency provider also wants to be enabled
|
| 277 |
+
in whole-project calls to :command:`try_compile`.
|
| 278 |
+
|
| 279 |
+
.. note::
|
| 280 |
+
The choice of dependency provider should always be under the user's control.
|
| 281 |
+
As a convenience, a project may choose to provide a file that users can
|
| 282 |
+
list in their :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variable, but
|
| 283 |
+
the use of such a file should always be the user's choice.
|
| 284 |
+
|
| 285 |
+
Provider commands
|
| 286 |
+
"""""""""""""""""
|
| 287 |
+
|
| 288 |
+
Providers define a single ``<command>`` to accept requests. The name of
|
| 289 |
+
the command should be specific to that provider, not something overly
|
| 290 |
+
generic that another provider might also use. This enables users to compose
|
| 291 |
+
different providers in their own custom provider. The recommended form is
|
| 292 |
+
``xxx_provide_dependency()``, where ``xxx`` is the provider-specific part
|
| 293 |
+
(e.g. ``vcpkg_provide_dependency()``, ``conan_provide_dependency()``,
|
| 294 |
+
``ourcompany_provide_dependency()``, and so on).
|
| 295 |
+
|
| 296 |
+
.. code-block:: cmake
|
| 297 |
+
|
| 298 |
+
xxx_provide_dependency(<method> [<method-specific-args>...])
|
| 299 |
+
|
| 300 |
+
Because some methods expect certain variables to be set in the calling scope,
|
| 301 |
+
the provider command should typically be implemented as a macro rather than a
|
| 302 |
+
function. This ensures it does not introduce a new variable scope.
|
| 303 |
+
|
| 304 |
+
The arguments CMake passes to the dependency provider depend on the type of
|
| 305 |
+
request. The first argument is always the method, and it will only ever
|
| 306 |
+
be one of the ``<methods>`` that was specified when setting the provider.
|
| 307 |
+
|
| 308 |
+
``FIND_PACKAGE``
|
| 309 |
+
The ``<method-specific-args>`` will be everything passed to the
|
| 310 |
+
:command:`find_package` call that requested the dependency. The first of
|
| 311 |
+
these ``<method-specific-args>`` will therefore always be the name of the
|
| 312 |
+
dependency. Dependency names are case-sensitive for this method because
|
| 313 |
+
:command:`find_package` treats them case-sensitively too.
|
| 314 |
+
|
| 315 |
+
If the provider command fulfills the request, it must set the same variable
|
| 316 |
+
that :command:`find_package` expects to be set. For a dependency named
|
| 317 |
+
``depName``, the provider must set ``depName_FOUND`` to true if it fulfilled
|
| 318 |
+
the request. If the provider returns without setting this variable, CMake
|
| 319 |
+
will assume the request was not fulfilled and will fall back to the
|
| 320 |
+
built-in implementation.
|
| 321 |
+
|
| 322 |
+
If the provider needs to call the built-in :command:`find_package`
|
| 323 |
+
implementation as part of its processing, it can do so by including the
|
| 324 |
+
``BYPASS_PROVIDER`` keyword as one of the arguments.
|
| 325 |
+
|
| 326 |
+
``FETCHCONTENT_MAKEAVAILABLE_SERIAL``
|
| 327 |
+
The ``<method-specific-args>`` will be everything passed to the
|
| 328 |
+
:command:`FetchContent_Declare` call that corresponds to the requested
|
| 329 |
+
dependency, with the following exceptions:
|
| 330 |
+
|
| 331 |
+
* If ``SOURCE_DIR`` or ``BINARY_DIR`` were not part of the original
|
| 332 |
+
declared arguments, they will be added with their default values.
|
| 333 |
+
* If :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE` is set to ``NEVER``,
|
| 334 |
+
any ``FIND_PACKAGE_ARGS`` will be omitted.
|
| 335 |
+
* The ``OVERRIDE_FIND_PACKAGE`` keyword is always omitted.
|
| 336 |
+
|
| 337 |
+
The first of the ``<method-specific-args>`` will always be the name of the
|
| 338 |
+
dependency. Dependency names are case-insensitive for this method because
|
| 339 |
+
:module:`FetchContent` also treats them case-insensitively.
|
| 340 |
+
|
| 341 |
+
If the provider fulfills the request, it should call
|
| 342 |
+
:command:`FetchContent_SetPopulated`, passing the name of the dependency as
|
| 343 |
+
the first argument. The ``SOURCE_DIR`` and ``BINARY_DIR`` arguments to that
|
| 344 |
+
command should only be given if the provider makes the dependency's source
|
| 345 |
+
and build directories available in exactly the same way as the built-in
|
| 346 |
+
:command:`FetchContent_MakeAvailable` command.
|
| 347 |
+
|
| 348 |
+
If the provider returns without calling :command:`FetchContent_SetPopulated`
|
| 349 |
+
for the named dependency, CMake will assume the request was not fulfilled
|
| 350 |
+
and will fall back to the built-in implementation.
|
| 351 |
+
|
| 352 |
+
Note that empty arguments may be significant for this method (e.g. an empty
|
| 353 |
+
string following a ``GIT_SUBMODULES`` keyword). Therefore, if forwarding
|
| 354 |
+
these arguments on to another command, extra care must be taken to avoid such
|
| 355 |
+
arguments being silently dropped.
|
| 356 |
+
|
| 357 |
+
If ``FETCHCONTENT_SOURCE_DIR_<uppercaseDepName>`` is set, then the
|
| 358 |
+
dependency provider will never see requests for the ``<depName>`` dependency
|
| 359 |
+
for this method. When the user sets such a variable, they are explicitly
|
| 360 |
+
overriding where to get that dependency from and are taking on the
|
| 361 |
+
responsibility that their overriding version meets any requirements for that
|
| 362 |
+
dependency and is compatible with whatever else in the project uses it.
|
| 363 |
+
Depending on the value of :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE`
|
| 364 |
+
and whether the ``OVERRIDE_FIND_PACKAGE`` option was given to
|
| 365 |
+
:command:`FetchContent_Declare`, having
|
| 366 |
+
``FETCHCONTENT_SOURCE_DIR_<uppercaseDepName>`` set may also prevent the
|
| 367 |
+
dependency provider from seeing requests for a ``find_package(depName)``
|
| 368 |
+
call too.
|
| 369 |
+
|
| 370 |
+
Provider Examples
|
| 371 |
+
"""""""""""""""""
|
| 372 |
+
|
| 373 |
+
This first example only intercepts :command:`find_package` calls. The
|
| 374 |
+
provider command runs an external tool which copies the relevant artifacts
|
| 375 |
+
into a provider-specific directory, if that tool knows about the dependency.
|
| 376 |
+
It then relies on the built-in implementation to then find those artifacts.
|
| 377 |
+
:command:`FetchContent_MakeAvailable` calls would not go through the provider.
|
| 378 |
+
|
| 379 |
+
.. code-block:: cmake
|
| 380 |
+
:caption: mycomp_provider.cmake
|
| 381 |
+
|
| 382 |
+
# Always ensure we have the policy settings this provider expects
|
| 383 |
+
cmake_minimum_required(VERSION 3.24)
|
| 384 |
+
|
| 385 |
+
set(MYCOMP_PROVIDER_INSTALL_DIR ${CMAKE_BINARY_DIR}/mycomp_packages
|
| 386 |
+
CACHE PATH "The directory this provider installs packages to"
|
| 387 |
+
)
|
| 388 |
+
# Tell the built-in implementation to look in our area first, unless
|
| 389 |
+
# the find_package() call uses NO_..._PATH options to exclude it
|
| 390 |
+
list(APPEND CMAKE_MODULE_PATH ${MYCOMP_PROVIDER_INSTALL_DIR}/cmake)
|
| 391 |
+
list(APPEND CMAKE_PREFIX_PATH ${MYCOMP_PROVIDER_INSTALL_DIR})
|
| 392 |
+
|
| 393 |
+
macro(mycomp_provide_dependency method package_name)
|
| 394 |
+
execute_process(
|
| 395 |
+
COMMAND some_tool ${package_name} --installdir ${MYCOMP_PROVIDER_INSTALL_DIR}
|
| 396 |
+
COMMAND_ERROR_IS_FATAL ANY
|
| 397 |
+
)
|
| 398 |
+
endmacro()
|
| 399 |
+
|
| 400 |
+
cmake_language(
|
| 401 |
+
SET_DEPENDENCY_PROVIDER mycomp_provide_dependency
|
| 402 |
+
SUPPORTED_METHODS FIND_PACKAGE
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
The user would then typically use the above file like so::
|
| 406 |
+
|
| 407 |
+
cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/path/to/mycomp_provider.cmake ...
|
| 408 |
+
|
| 409 |
+
The next example demonstrates a provider that accepts both methods, but
|
| 410 |
+
only handles one specific dependency. It enforces providing Google Test
|
| 411 |
+
using :module:`FetchContent`, but leaves all other dependencies to be
|
| 412 |
+
fulfilled by CMake's built-in implementation. It accepts a few different
|
| 413 |
+
names, which demonstrates one way of working around projects that hard-code
|
| 414 |
+
an unusual or undesirable way of adding this particular dependency to the
|
| 415 |
+
build. The example also demonstrates how to use the :command:`list` command
|
| 416 |
+
to preserve variables that may be overwritten by a call to
|
| 417 |
+
:command:`FetchContent_MakeAvailable`.
|
| 418 |
+
|
| 419 |
+
.. code-block:: cmake
|
| 420 |
+
:caption: mycomp_provider.cmake
|
| 421 |
+
|
| 422 |
+
cmake_minimum_required(VERSION 3.24)
|
| 423 |
+
|
| 424 |
+
# Because we declare this very early, it will take precedence over any
|
| 425 |
+
# details the project might declare later for the same thing
|
| 426 |
+
include(FetchContent)
|
| 427 |
+
FetchContent_Declare(
|
| 428 |
+
googletest
|
| 429 |
+
GIT_REPOSITORY https://github.com/google/googletest.git
|
| 430 |
+
GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release-1.11.0
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
# Both FIND_PACKAGE and FETCHCONTENT_MAKEAVAILABLE_SERIAL methods provide
|
| 434 |
+
# the package or dependency name as the first method-specific argument.
|
| 435 |
+
macro(mycomp_provide_dependency method dep_name)
|
| 436 |
+
if("${dep_name}" MATCHES "^(gtest|googletest)$")
|
| 437 |
+
# Save our current command arguments in case we are called recursively
|
| 438 |
+
list(APPEND mycomp_provider_args ${method} ${dep_name})
|
| 439 |
+
|
| 440 |
+
# This will forward to the built-in FetchContent implementation,
|
| 441 |
+
# which detects a recursive call for the same thing and avoids calling
|
| 442 |
+
# the provider again if dep_name is the same as the current call.
|
| 443 |
+
FetchContent_MakeAvailable(googletest)
|
| 444 |
+
|
| 445 |
+
# Restore our command arguments
|
| 446 |
+
list(POP_BACK mycomp_provider_args dep_name method)
|
| 447 |
+
|
| 448 |
+
# Tell the caller we fulfilled the request
|
| 449 |
+
if("${method}" STREQUAL "FIND_PACKAGE")
|
| 450 |
+
# We need to set this if we got here from a find_package() call
|
| 451 |
+
# since we used a different method to fulfill the request.
|
| 452 |
+
# This example assumes projects only use the gtest targets,
|
| 453 |
+
# not any of the variables the FindGTest module may define.
|
| 454 |
+
set(${dep_name}_FOUND TRUE)
|
| 455 |
+
elseif(NOT "${dep_name}" STREQUAL "googletest")
|
| 456 |
+
# We used the same method, but were given a different name to the
|
| 457 |
+
# one we populated with. Tell the caller about the name it used.
|
| 458 |
+
FetchContent_SetPopulated(${dep_name}
|
| 459 |
+
SOURCE_DIR "${googletest_SOURCE_DIR}"
|
| 460 |
+
BINARY_DIR "${googletest_BINARY_DIR}"
|
| 461 |
+
)
|
| 462 |
+
endif()
|
| 463 |
+
endif()
|
| 464 |
+
endmacro()
|
| 465 |
+
|
| 466 |
+
cmake_language(
|
| 467 |
+
SET_DEPENDENCY_PROVIDER mycomp_provide_dependency
|
| 468 |
+
SUPPORTED_METHODS
|
| 469 |
+
FIND_PACKAGE
|
| 470 |
+
FETCHCONTENT_MAKEAVAILABLE_SERIAL
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
The final example demonstrates how to modify arguments to a
|
| 474 |
+
:command:`find_package` call. It forces all such calls to have the
|
| 475 |
+
``QUIET`` keyword. It uses the ``BYPASS_PROVIDER`` keyword to prevent
|
| 476 |
+
calling the provider command recursively for the same dependency.
|
| 477 |
+
|
| 478 |
+
.. code-block:: cmake
|
| 479 |
+
:caption: mycomp_provider.cmake
|
| 480 |
+
|
| 481 |
+
cmake_minimum_required(VERSION 3.24)
|
| 482 |
+
|
| 483 |
+
macro(mycomp_provide_dependency method)
|
| 484 |
+
find_package(${ARGN} BYPASS_PROVIDER QUIET)
|
| 485 |
+
endmacro()
|
| 486 |
+
|
| 487 |
+
cmake_language(
|
| 488 |
+
SET_DEPENDENCY_PROVIDER mycomp_provide_dependency
|
| 489 |
+
SUPPORTED_METHODS FIND_PACKAGE
|
| 490 |
+
)
|
| 491 |
+
|
| 492 |
+
Getting current message log level
|
| 493 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 494 |
+
|
| 495 |
+
.. versionadded:: 3.25
|
| 496 |
+
|
| 497 |
+
.. _query_message_log_level:
|
| 498 |
+
|
| 499 |
+
.. signature::
|
| 500 |
+
cmake_language(GET_MESSAGE_LOG_LEVEL <output_variable>)
|
| 501 |
+
|
| 502 |
+
Writes the current :command:`message` logging level
|
| 503 |
+
into the given ``<output_variable>``.
|
| 504 |
+
|
| 505 |
+
See :command:`message` for the possible logging levels.
|
| 506 |
+
|
| 507 |
+
The current message logging level can be set either using the
|
| 508 |
+
:option:`--log-level <cmake --log-level>`
|
| 509 |
+
command line option of the :manual:`cmake(1)` program or using
|
| 510 |
+
the :variable:`CMAKE_MESSAGE_LOG_LEVEL` variable.
|
| 511 |
+
|
| 512 |
+
If both the command line option and the variable are set, the command line
|
| 513 |
+
option takes precedence. If neither are set, the default logging level
|
| 514 |
+
is returned.
|
| 515 |
+
|
| 516 |
+
Terminating Scripts
|
| 517 |
+
^^^^^^^^^^^^^^^^^^^
|
| 518 |
+
|
| 519 |
+
.. versionadded:: 3.29
|
| 520 |
+
|
| 521 |
+
.. signature::
|
| 522 |
+
cmake_language(EXIT <exit-code>)
|
| 523 |
+
|
| 524 |
+
Terminate the current :option:`cmake -P` script and exit with ``<exit-code>``.
|
| 525 |
+
|
| 526 |
+
This command works only in :ref:`script mode <Script Processing Mode>`.
|
| 527 |
+
If used outside of that context, it will cause a fatal error.
|
| 528 |
+
|
| 529 |
+
The ``<exit-code>`` should be non-negative.
|
| 530 |
+
If ``<exit-code>`` is negative, then the behavior
|
| 531 |
+
is unspecified (e.g., on Windows the error code -1
|
| 532 |
+
becomes ``0xffffffff``, and on Linux it becomes 255).
|
| 533 |
+
Exit codes above 255 may not be supported by the underlying
|
| 534 |
+
shell or platform, and some shells may interpret values
|
| 535 |
+
above 125 specially. Therefore, it is advisable to only
|
| 536 |
+
specify an ``<exit-code>`` in the range 0 to 125.
|
cmake/share/cmake-3.31/Help/command/cmake_minimum_required.rst
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_minimum_required
|
| 2 |
+
----------------------
|
| 3 |
+
|
| 4 |
+
Require a minimum version of cmake.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
cmake_minimum_required(VERSION <min>[...<policy_max>] [FATAL_ERROR])
|
| 9 |
+
|
| 10 |
+
.. versionadded:: 3.12
|
| 11 |
+
The optional ``<policy_max>`` version.
|
| 12 |
+
|
| 13 |
+
Sets the minimum required version of cmake for a project.
|
| 14 |
+
Also updates the policy settings as explained below.
|
| 15 |
+
|
| 16 |
+
``<min>`` and the optional ``<policy_max>`` are each CMake versions of the
|
| 17 |
+
form ``major.minor[.patch[.tweak]]``, and the ``...`` is literal.
|
| 18 |
+
|
| 19 |
+
If the running version of CMake is lower than the ``<min>`` required
|
| 20 |
+
version it will stop processing the project and report an error.
|
| 21 |
+
The optional ``<policy_max>`` version, if specified, must be at least the
|
| 22 |
+
``<min>`` version and affects policy settings as described in `Policy Settings`_.
|
| 23 |
+
If the running version of CMake is older than 3.12, the extra ``...``
|
| 24 |
+
dots will be seen as version component separators, resulting in the
|
| 25 |
+
``...<max>`` part being ignored and preserving the pre-3.12 behavior
|
| 26 |
+
of basing policies on ``<min>``.
|
| 27 |
+
|
| 28 |
+
This command will set the value of the
|
| 29 |
+
:variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable to ``<min>``.
|
| 30 |
+
|
| 31 |
+
The ``FATAL_ERROR`` option is accepted but ignored by CMake 2.6 and
|
| 32 |
+
higher. It should be specified so CMake versions 2.4 and lower fail
|
| 33 |
+
with an error instead of just a warning.
|
| 34 |
+
|
| 35 |
+
.. note::
|
| 36 |
+
Call the ``cmake_minimum_required()`` command at the beginning of
|
| 37 |
+
the top-level ``CMakeLists.txt`` file even before calling the
|
| 38 |
+
:command:`project` command. It is important to establish version
|
| 39 |
+
and policy settings before invoking other commands whose behavior
|
| 40 |
+
they may affect. See also policy :policy:`CMP0000`.
|
| 41 |
+
|
| 42 |
+
Calling ``cmake_minimum_required()`` inside a :command:`function`
|
| 43 |
+
limits some effects to the function scope when invoked. For example,
|
| 44 |
+
the :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable won't be set
|
| 45 |
+
in the calling scope. Functions do not introduce their own policy
|
| 46 |
+
scope though, so policy settings of the caller *will* be affected
|
| 47 |
+
(see below). Due to this mix of things that do and do not affect the
|
| 48 |
+
calling scope, calling ``cmake_minimum_required()`` inside a function
|
| 49 |
+
is generally discouraged.
|
| 50 |
+
|
| 51 |
+
.. _`Policy Settings`:
|
| 52 |
+
|
| 53 |
+
Policy Settings
|
| 54 |
+
^^^^^^^^^^^^^^^
|
| 55 |
+
|
| 56 |
+
The ``cmake_minimum_required(VERSION)`` command implicitly invokes the
|
| 57 |
+
:command:`cmake_policy(VERSION)` command to specify that the current
|
| 58 |
+
project code is written for the given range of CMake versions.
|
| 59 |
+
All policies known to the running version of CMake and introduced
|
| 60 |
+
in the ``<min>`` (or ``<max>``, if specified) version or earlier will
|
| 61 |
+
be set to use ``NEW`` behavior. All policies introduced in later
|
| 62 |
+
versions will be unset. This effectively requests behavior preferred
|
| 63 |
+
as of a given CMake version and tells newer CMake versions to warn
|
| 64 |
+
about their new policies.
|
| 65 |
+
|
| 66 |
+
When a ``<min>`` version higher than 2.4 is specified the command
|
| 67 |
+
implicitly invokes
|
| 68 |
+
|
| 69 |
+
.. code-block:: cmake
|
| 70 |
+
|
| 71 |
+
cmake_policy(VERSION <min>[...<max>])
|
| 72 |
+
|
| 73 |
+
which sets CMake policies based on the range of versions specified.
|
| 74 |
+
When a ``<min>`` version 2.4 or lower is given the command implicitly
|
| 75 |
+
invokes
|
| 76 |
+
|
| 77 |
+
.. code-block:: cmake
|
| 78 |
+
|
| 79 |
+
cmake_policy(VERSION 2.4[...<max>])
|
| 80 |
+
|
| 81 |
+
which enables compatibility features for CMake 2.4 and lower.
|
| 82 |
+
|
| 83 |
+
.. include:: DEPRECATED_POLICY_VERSIONS.txt
|
| 84 |
+
|
| 85 |
+
See Also
|
| 86 |
+
^^^^^^^^
|
| 87 |
+
|
| 88 |
+
* :command:`cmake_policy`
|
cmake/share/cmake-3.31/Help/command/cmake_parse_arguments.rst
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_parse_arguments
|
| 2 |
+
---------------------
|
| 3 |
+
|
| 4 |
+
Parse function or macro arguments.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
cmake_parse_arguments(<prefix> <options> <one_value_keywords>
|
| 9 |
+
<multi_value_keywords> <args>...)
|
| 10 |
+
|
| 11 |
+
cmake_parse_arguments(PARSE_ARGV <N> <prefix> <options>
|
| 12 |
+
<one_value_keywords> <multi_value_keywords>)
|
| 13 |
+
|
| 14 |
+
.. versionadded:: 3.5
|
| 15 |
+
This command is implemented natively. Previously, it has been defined in the
|
| 16 |
+
module :module:`CMakeParseArguments`.
|
| 17 |
+
|
| 18 |
+
This command is for use in macros or functions.
|
| 19 |
+
It processes the arguments given to that macro or function,
|
| 20 |
+
and defines a set of variables which hold the values of the
|
| 21 |
+
respective options.
|
| 22 |
+
|
| 23 |
+
The first signature reads arguments passed in the ``<args>...``.
|
| 24 |
+
This may be used in either a :command:`macro` or a :command:`function`.
|
| 25 |
+
|
| 26 |
+
.. versionadded:: 3.7
|
| 27 |
+
The ``PARSE_ARGV`` signature is only for use in a :command:`function`
|
| 28 |
+
body. In this case, the arguments that are parsed come from the
|
| 29 |
+
``ARGV#`` variables of the calling function. The parsing starts with
|
| 30 |
+
the ``<N>``-th argument, where ``<N>`` is an unsigned integer.
|
| 31 |
+
This allows for the values to have special characters like ``;`` in them.
|
| 32 |
+
|
| 33 |
+
The ``<options>`` argument contains all options for the respective function
|
| 34 |
+
or macro. These are keywords that have no value following them, like the
|
| 35 |
+
``OPTIONAL`` keyword of the :command:`install` command.
|
| 36 |
+
|
| 37 |
+
The ``<one_value_keywords>`` argument contains all keywords for this function
|
| 38 |
+
or macro which are followed by one value, like the ``DESTINATION`` keyword of
|
| 39 |
+
the :command:`install` command.
|
| 40 |
+
|
| 41 |
+
The ``<multi_value_keywords>`` argument contains all keywords for this
|
| 42 |
+
function or macro which can be followed by more than one value, like the
|
| 43 |
+
``TARGETS`` or ``FILES`` keywords of the :command:`install` command.
|
| 44 |
+
|
| 45 |
+
.. versionchanged:: 3.5
|
| 46 |
+
All keywords must be unique. Each keyword can only be specified
|
| 47 |
+
once in any of the ``<options>``, ``<one_value_keywords>``, or
|
| 48 |
+
``<multi_value_keywords>``. A warning will be emitted if uniqueness is
|
| 49 |
+
violated.
|
| 50 |
+
|
| 51 |
+
When done, ``cmake_parse_arguments`` will consider for each of the
|
| 52 |
+
keywords listed in ``<options>``, ``<one_value_keywords>``, and
|
| 53 |
+
``<multi_value_keywords>``, a variable composed of the given ``<prefix>``
|
| 54 |
+
followed by ``"_"`` and the name of the respective keyword. For
|
| 55 |
+
``<one_value_keywords>`` and ``<multi_value_keywords>``, these variables
|
| 56 |
+
will then hold the respective value(s) from the argument list, or be undefined
|
| 57 |
+
if the associated keyword was not given (policy :policy:`CMP0174` can also
|
| 58 |
+
affect the behavior for ``<one_value_keywords>``). For the ``<options>``
|
| 59 |
+
keywords, these variables will always be defined, and they will be set to
|
| 60 |
+
``TRUE`` if the keyword is present, or ``FALSE`` if it is not.
|
| 61 |
+
|
| 62 |
+
All remaining arguments are collected in a variable
|
| 63 |
+
``<prefix>_UNPARSED_ARGUMENTS`` that will be undefined if all arguments
|
| 64 |
+
were recognized. This can be checked afterwards to see
|
| 65 |
+
whether your macro or function was called with unrecognized parameters.
|
| 66 |
+
|
| 67 |
+
.. versionadded:: 3.15
|
| 68 |
+
``<one_value_keywords>`` and ``<multi_value_keywords>`` that were given no
|
| 69 |
+
values at all are collected in a variable
|
| 70 |
+
``<prefix>_KEYWORDS_MISSING_VALUES`` that will be undefined if all keywords
|
| 71 |
+
received values. This can be checked to see if there were keywords without
|
| 72 |
+
any values given.
|
| 73 |
+
|
| 74 |
+
.. versionchanged:: 3.31
|
| 75 |
+
If a ``<one_value_keyword>`` is followed by an empty string as its value,
|
| 76 |
+
policy :policy:`CMP0174` controls whether a corresponding
|
| 77 |
+
``<prefix>_<keyword>`` variable is defined or not.
|
| 78 |
+
|
| 79 |
+
Choose a ``<prefix>`` carefully to avoid clashing with existing variable names.
|
| 80 |
+
When used inside a function, it is usually suitable to use the prefix ``arg``.
|
| 81 |
+
There is a very strong convention that all keywords are fully uppercase, so
|
| 82 |
+
this prefix results in variables of the form ``arg_SOME_KEYWORD``. This makes
|
| 83 |
+
the code more readable, and it minimizes the chance of clashing with cache
|
| 84 |
+
variables, which also have a strong convention of being all uppercase.
|
| 85 |
+
|
| 86 |
+
.. code-block:: cmake
|
| 87 |
+
|
| 88 |
+
function(my_install)
|
| 89 |
+
set(options OPTIONAL FAST)
|
| 90 |
+
set(oneValueArgs DESTINATION RENAME)
|
| 91 |
+
set(multiValueArgs TARGETS CONFIGURATIONS)
|
| 92 |
+
cmake_parse_arguments(PARSE_ARGV 0 arg
|
| 93 |
+
"${options}" "${oneValueArgs}" "${multiValueArgs}"
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
# The above will set or unset variables with the following names:
|
| 97 |
+
# arg_OPTIONAL
|
| 98 |
+
# arg_FAST
|
| 99 |
+
# arg_DESTINATION
|
| 100 |
+
# arg_RENAME
|
| 101 |
+
# arg_TARGETS
|
| 102 |
+
# arg_CONFIGURATIONS
|
| 103 |
+
#
|
| 104 |
+
# The following will also be set or unset:
|
| 105 |
+
# arg_UNPARSED_ARGUMENTS
|
| 106 |
+
# arg_KEYWORDS_MISSING_VALUES
|
| 107 |
+
|
| 108 |
+
When used inside a macro, ``arg`` might not be a suitable prefix because the
|
| 109 |
+
code will affect the calling scope. If another macro also called in the same
|
| 110 |
+
scope were to use ``arg`` in its own call to ``cmake_parse_arguments()``,
|
| 111 |
+
and if there are any common keywords between the two macros, the later call's
|
| 112 |
+
variables can overwrite or remove those of the earlier macro's call.
|
| 113 |
+
Therefore, it is advisable to incorporate something unique from the macro name
|
| 114 |
+
in the ``<prefix>``, such as ``arg_lowercase_macro_name``.
|
| 115 |
+
|
| 116 |
+
.. code-block:: cmake
|
| 117 |
+
|
| 118 |
+
macro(my_install)
|
| 119 |
+
set(options OPTIONAL FAST)
|
| 120 |
+
set(oneValueArgs DESTINATION RENAME)
|
| 121 |
+
set(multiValueArgs TARGETS CONFIGURATIONS)
|
| 122 |
+
cmake_parse_arguments(arg_my_install
|
| 123 |
+
"${options}" "${oneValueArgs}" "${multiValueArgs}"
|
| 124 |
+
${ARGN}
|
| 125 |
+
)
|
| 126 |
+
# ...
|
| 127 |
+
endmacro()
|
| 128 |
+
|
| 129 |
+
macro(my_special_install)
|
| 130 |
+
# NOTE: Has the same keywords as my_install()
|
| 131 |
+
set(options OPTIONAL FAST)
|
| 132 |
+
set(oneValueArgs DESTINATION RENAME)
|
| 133 |
+
set(multiValueArgs TARGETS CONFIGURATIONS)
|
| 134 |
+
cmake_parse_arguments(arg_my_special_install
|
| 135 |
+
"${options}" "${oneValueArgs}" "${multiValueArgs}"
|
| 136 |
+
${ARGN}
|
| 137 |
+
)
|
| 138 |
+
# ...
|
| 139 |
+
endmacro()
|
| 140 |
+
|
| 141 |
+
Suppose the above macros are called one after the other, like so:
|
| 142 |
+
|
| 143 |
+
.. code-block:: cmake
|
| 144 |
+
|
| 145 |
+
my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub CONFIGURATIONS)
|
| 146 |
+
my_special_install(TARGETS barry DESTINATION sbin RENAME FAST)
|
| 147 |
+
|
| 148 |
+
After these two calls, the following describes the variables that will be
|
| 149 |
+
set or unset::
|
| 150 |
+
|
| 151 |
+
arg_my_install_OPTIONAL = TRUE
|
| 152 |
+
arg_my_install_FAST = FALSE # was not present in call to my_install
|
| 153 |
+
arg_my_install_DESTINATION = "bin"
|
| 154 |
+
arg_my_install_RENAME <UNSET> # was not present
|
| 155 |
+
arg_my_install_TARGETS = "foo;bar"
|
| 156 |
+
arg_my_install_CONFIGURATIONS <UNSET> # was not present
|
| 157 |
+
arg_my_install_UNPARSED_ARGUMENTS = "blub" # nothing expected after "OPTIONAL"
|
| 158 |
+
arg_my_install_KEYWORDS_MISSING_VALUES = "CONFIGURATIONS" # value was missing
|
| 159 |
+
|
| 160 |
+
arg_my_special_install_OPTIONAL = FALSE # was not present
|
| 161 |
+
arg_my_special_install_FAST = TRUE
|
| 162 |
+
arg_my_special_install_DESTINATION = "sbin"
|
| 163 |
+
arg_my_special_install_RENAME <UNSET> # value was missing
|
| 164 |
+
arg_my_special_install_TARGETS = "barry"
|
| 165 |
+
arg_my_special_install_CONFIGURATIONS <UNSET> # was not present
|
| 166 |
+
arg_my_special_install_UNPARSED_ARGUMENTS <UNSET>
|
| 167 |
+
arg_my_special_install_KEYWORDS_MISSING_VALUES = "RENAME"
|
| 168 |
+
|
| 169 |
+
Keywords terminate lists of values. If a keyword is given directly after a
|
| 170 |
+
``<one_value_keyword>``, that preceding ``<one_value_keyword>`` receives no
|
| 171 |
+
value and the keyword is added to the ``<prefix>_KEYWORDS_MISSING_VALUES``
|
| 172 |
+
variable. In the above example, the call to ``my_special_install()`` contains
|
| 173 |
+
the ``RENAME`` keyword immediately followed by the ``FAST`` keyword.
|
| 174 |
+
In this case, ``FAST`` terminates processing of the ``RENAME`` keyword.
|
| 175 |
+
``arg_my_special_install_FAST`` is set to ``TRUE``,
|
| 176 |
+
``arg_my_special_install_RENAME`` is unset, and
|
| 177 |
+
``arg_my_special_install_KEYWORDS_MISSING_VALUES`` contains the value
|
| 178 |
+
``RENAME``.
|
| 179 |
+
|
| 180 |
+
See Also
|
| 181 |
+
^^^^^^^^
|
| 182 |
+
|
| 183 |
+
* :command:`function`
|
| 184 |
+
* :command:`macro`
|
cmake/share/cmake-3.31/Help/command/cmake_path.rst
ADDED
|
@@ -0,0 +1,798 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_path
|
| 2 |
+
----------
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.20
|
| 5 |
+
|
| 6 |
+
This command is for the manipulation of paths. Only syntactic aspects of
|
| 7 |
+
paths are handled, there is no interaction of any kind with any underlying
|
| 8 |
+
file system. The path may represent a non-existing path or even one that
|
| 9 |
+
is not allowed to exist on the current file system or platform.
|
| 10 |
+
For operations that do interact with the filesystem, see the :command:`file`
|
| 11 |
+
command.
|
| 12 |
+
|
| 13 |
+
.. note::
|
| 14 |
+
|
| 15 |
+
The ``cmake_path`` command handles paths in the format of the build system
|
| 16 |
+
(i.e. the host platform), not the target system. When cross-compiling,
|
| 17 |
+
if the path contains elements that are not representable on the host
|
| 18 |
+
platform (e.g. a drive letter when the host is not Windows), the results
|
| 19 |
+
will be unpredictable.
|
| 20 |
+
|
| 21 |
+
Synopsis
|
| 22 |
+
^^^^^^^^
|
| 23 |
+
|
| 24 |
+
.. parsed-literal::
|
| 25 |
+
|
| 26 |
+
`Conventions`_
|
| 27 |
+
|
| 28 |
+
`Path Structure And Terminology`_
|
| 29 |
+
|
| 30 |
+
`Normalization`_
|
| 31 |
+
|
| 32 |
+
`Decomposition`_
|
| 33 |
+
cmake_path(`GET`_ <path-var> :ref:`ROOT_NAME <GET_ROOT_NAME>` <out-var>)
|
| 34 |
+
cmake_path(`GET`_ <path-var> :ref:`ROOT_DIRECTORY <GET_ROOT_DIRECTORY>` <out-var>)
|
| 35 |
+
cmake_path(`GET`_ <path-var> :ref:`ROOT_PATH <GET_ROOT_PATH>` <out-var>)
|
| 36 |
+
cmake_path(`GET`_ <path-var> :ref:`FILENAME <GET_FILENAME>` <out-var>)
|
| 37 |
+
cmake_path(`GET`_ <path-var> :ref:`EXTENSION <GET_EXTENSION>` [LAST_ONLY] <out-var>)
|
| 38 |
+
cmake_path(`GET`_ <path-var> :ref:`STEM <GET_STEM>` [LAST_ONLY] <out-var>)
|
| 39 |
+
cmake_path(`GET`_ <path-var> :ref:`RELATIVE_PART <GET_RELATIVE_PART>` <out-var>)
|
| 40 |
+
cmake_path(`GET`_ <path-var> :ref:`PARENT_PATH <GET_PARENT_PATH>` <out-var>)
|
| 41 |
+
|
| 42 |
+
`Query`_
|
| 43 |
+
cmake_path(`HAS_ROOT_NAME`_ <path-var> <out-var>)
|
| 44 |
+
cmake_path(`HAS_ROOT_DIRECTORY`_ <path-var> <out-var>)
|
| 45 |
+
cmake_path(`HAS_ROOT_PATH`_ <path-var> <out-var>)
|
| 46 |
+
cmake_path(`HAS_FILENAME`_ <path-var> <out-var>)
|
| 47 |
+
cmake_path(`HAS_EXTENSION`_ <path-var> <out-var>)
|
| 48 |
+
cmake_path(`HAS_STEM`_ <path-var> <out-var>)
|
| 49 |
+
cmake_path(`HAS_RELATIVE_PART`_ <path-var> <out-var>)
|
| 50 |
+
cmake_path(`HAS_PARENT_PATH`_ <path-var> <out-var>)
|
| 51 |
+
cmake_path(`IS_ABSOLUTE`_ <path-var> <out-var>)
|
| 52 |
+
cmake_path(`IS_RELATIVE`_ <path-var> <out-var>)
|
| 53 |
+
cmake_path(`IS_PREFIX`_ <path-var> <input> [NORMALIZE] <out-var>)
|
| 54 |
+
cmake_path(`COMPARE`_ <input1> <OP> <input2> <out-var>)
|
| 55 |
+
|
| 56 |
+
`Modification`_
|
| 57 |
+
cmake_path(:ref:`SET <cmake_path-SET>` <path-var> [NORMALIZE] <input>)
|
| 58 |
+
cmake_path(`APPEND`_ <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
|
| 59 |
+
cmake_path(`APPEND_STRING`_ <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
|
| 60 |
+
cmake_path(`REMOVE_FILENAME`_ <path-var> [OUTPUT_VARIABLE <out-var>])
|
| 61 |
+
cmake_path(`REPLACE_FILENAME`_ <path-var> <input> [OUTPUT_VARIABLE <out-var>])
|
| 62 |
+
cmake_path(`REMOVE_EXTENSION`_ <path-var> [LAST_ONLY] [OUTPUT_VARIABLE <out-var>])
|
| 63 |
+
cmake_path(`REPLACE_EXTENSION`_ <path-var> [LAST_ONLY] <input> [OUTPUT_VARIABLE <out-var>])
|
| 64 |
+
|
| 65 |
+
`Generation`_
|
| 66 |
+
cmake_path(`NORMAL_PATH`_ <path-var> [OUTPUT_VARIABLE <out-var>])
|
| 67 |
+
cmake_path(`RELATIVE_PATH`_ <path-var> [BASE_DIRECTORY <input>] [OUTPUT_VARIABLE <out-var>])
|
| 68 |
+
cmake_path(`ABSOLUTE_PATH`_ <path-var> [BASE_DIRECTORY <input>] [NORMALIZE] [OUTPUT_VARIABLE <out-var>])
|
| 69 |
+
|
| 70 |
+
`Native Conversion`_
|
| 71 |
+
cmake_path(`NATIVE_PATH`_ <path-var> [NORMALIZE] <out-var>)
|
| 72 |
+
cmake_path(`CONVERT`_ <input> `TO_CMAKE_PATH_LIST`_ <out-var> [NORMALIZE])
|
| 73 |
+
cmake_path(`CONVERT`_ <input> `TO_NATIVE_PATH_LIST`_ <out-var> [NORMALIZE])
|
| 74 |
+
|
| 75 |
+
`Hashing`_
|
| 76 |
+
cmake_path(`HASH`_ <path-var> <out-var>)
|
| 77 |
+
|
| 78 |
+
Conventions
|
| 79 |
+
^^^^^^^^^^^
|
| 80 |
+
|
| 81 |
+
The following conventions are used in this command's documentation:
|
| 82 |
+
|
| 83 |
+
``<path-var>``
|
| 84 |
+
Always the name of a variable. For commands that expect a ``<path-var>``
|
| 85 |
+
as input, the variable must exist and it is expected to hold a single path.
|
| 86 |
+
|
| 87 |
+
``<input>``
|
| 88 |
+
A string literal which may contain a path, path fragment, or multiple paths
|
| 89 |
+
with a special separator depending on the command. See the description of
|
| 90 |
+
each command to see how this is interpreted.
|
| 91 |
+
|
| 92 |
+
``<input>...``
|
| 93 |
+
Zero or more string literal arguments.
|
| 94 |
+
|
| 95 |
+
``<out-var>``
|
| 96 |
+
The name of a variable into which the result of a command will be written.
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
.. _Path Structure And Terminology:
|
| 100 |
+
|
| 101 |
+
Path Structure And Terminology
|
| 102 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 103 |
+
|
| 104 |
+
A path has the following structure (all components are optional, with some
|
| 105 |
+
constraints):
|
| 106 |
+
|
| 107 |
+
::
|
| 108 |
+
|
| 109 |
+
root-name root-directory-separator (item-name directory-separator)* filename
|
| 110 |
+
|
| 111 |
+
``root-name``
|
| 112 |
+
Identifies the root on a filesystem with multiple roots (such as ``"C:"``
|
| 113 |
+
or ``"//myserver"``). It is optional.
|
| 114 |
+
|
| 115 |
+
``root-directory-separator``
|
| 116 |
+
A directory separator that, if present, indicates that this path is
|
| 117 |
+
absolute. If it is missing and the first element other than the
|
| 118 |
+
``root-name`` is an ``item-name``, then the path is relative.
|
| 119 |
+
|
| 120 |
+
``item-name``
|
| 121 |
+
A sequence of characters that aren't directory separators. This name may
|
| 122 |
+
identify a file, a hard link, a symbolic link, or a directory. Two special
|
| 123 |
+
cases are recognized:
|
| 124 |
+
|
| 125 |
+
* The item name consisting of a single dot character ``.`` is a
|
| 126 |
+
directory name that refers to the current directory.
|
| 127 |
+
|
| 128 |
+
* The item name consisting of two dot characters ``..`` is a
|
| 129 |
+
directory name that refers to the parent directory.
|
| 130 |
+
|
| 131 |
+
The ``(...)*`` pattern shown above is to indicate that there can be zero
|
| 132 |
+
or more item names, with multiple items separated by a
|
| 133 |
+
``directory-separator``. The ``()*`` characters are not part of the path.
|
| 134 |
+
|
| 135 |
+
``directory-separator``
|
| 136 |
+
The only recognized directory separator is a forward slash character ``/``.
|
| 137 |
+
If this character is repeated, it is treated as a single directory
|
| 138 |
+
separator. In other words, ``/usr///////lib`` is the same as ``/usr/lib``.
|
| 139 |
+
|
| 140 |
+
.. _FILENAME_DEF:
|
| 141 |
+
.. _EXTENSION_DEF:
|
| 142 |
+
.. _STEM_DEF:
|
| 143 |
+
|
| 144 |
+
``filename``
|
| 145 |
+
A path has a ``filename`` if it does not end with a ``directory-separator``.
|
| 146 |
+
The ``filename`` is effectively the last ``item-name`` of the path, so it
|
| 147 |
+
can also be a hard link, symbolic link or a directory.
|
| 148 |
+
|
| 149 |
+
A ``filename`` can have an *extension*. By default, the extension is
|
| 150 |
+
defined as the sub-string beginning at the left-most period (including
|
| 151 |
+
the period) and until the end of the ``filename``. In commands that
|
| 152 |
+
accept a ``LAST_ONLY`` keyword, ``LAST_ONLY`` changes the interpretation
|
| 153 |
+
to the sub-string beginning at the right-most period.
|
| 154 |
+
|
| 155 |
+
The following exceptions apply to the above interpretation:
|
| 156 |
+
|
| 157 |
+
* If the first character in the ``filename`` is a period, that period is
|
| 158 |
+
ignored (i.e. a ``filename`` like ``".profile"`` is treated as having
|
| 159 |
+
no extension).
|
| 160 |
+
|
| 161 |
+
* If the ``filename`` is either ``.`` or ``..``, it has no extension.
|
| 162 |
+
|
| 163 |
+
The *stem* is the part of the ``filename`` before the extension.
|
| 164 |
+
|
| 165 |
+
Some commands refer to a ``root-path``. This is the concatenation of
|
| 166 |
+
``root-name`` and ``root-directory-separator``, either or both of which can
|
| 167 |
+
be empty. A ``relative-part`` refers to the full path with any ``root-path``
|
| 168 |
+
removed.
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
Creating A Path Variable
|
| 172 |
+
^^^^^^^^^^^^^^^^^^^^^^^^
|
| 173 |
+
|
| 174 |
+
While a path can be created with care using an ordinary :command:`set`
|
| 175 |
+
command, it is recommended to use :ref:`cmake_path(SET) <cmake_path-SET>`
|
| 176 |
+
instead, as it automatically converts the path to the required form where
|
| 177 |
+
required. The :ref:`cmake_path(APPEND) <APPEND>` subcommand may
|
| 178 |
+
be another suitable alternative where a path needs to be constructed by
|
| 179 |
+
joining fragments. The following example compares the three methods for
|
| 180 |
+
constructing the same path:
|
| 181 |
+
|
| 182 |
+
.. code-block:: cmake
|
| 183 |
+
|
| 184 |
+
set(path1 "${CMAKE_CURRENT_SOURCE_DIR}/data")
|
| 185 |
+
|
| 186 |
+
cmake_path(SET path2 "${CMAKE_CURRENT_SOURCE_DIR}/data")
|
| 187 |
+
|
| 188 |
+
cmake_path(APPEND path3 "${CMAKE_CURRENT_SOURCE_DIR}" "data")
|
| 189 |
+
|
| 190 |
+
`Modification`_ and `Generation`_ sub-commands can either store the result
|
| 191 |
+
in-place, or in a separate variable named after an ``OUTPUT_VARIABLE``
|
| 192 |
+
keyword. All other sub-commands store the result in a mandatory ``<out-var>``
|
| 193 |
+
variable.
|
| 194 |
+
|
| 195 |
+
.. _Normalization:
|
| 196 |
+
|
| 197 |
+
Normalization
|
| 198 |
+
^^^^^^^^^^^^^
|
| 199 |
+
|
| 200 |
+
Some sub-commands support *normalizing* a path. The algorithm used to
|
| 201 |
+
normalize a path is as follows:
|
| 202 |
+
|
| 203 |
+
1. If the path is empty, stop (the normalized form of an empty path is
|
| 204 |
+
also an empty path).
|
| 205 |
+
2. Replace each ``directory-separator``, which may consist of multiple
|
| 206 |
+
separators, with a single ``/`` (``/a///b --> /a/b``).
|
| 207 |
+
3. Remove each solitary period (``.``) and any immediately following
|
| 208 |
+
``directory-separator`` (``/a/./b/. --> /a/b``).
|
| 209 |
+
4. Remove each ``item-name`` (other than ``..``) that is immediately
|
| 210 |
+
followed by a ``directory-separator`` and a ``..``, along with any
|
| 211 |
+
immediately following ``directory-separator`` (``/a/b/../c --> a/c``).
|
| 212 |
+
5. If there is a ``root-directory``, remove any ``..`` and any
|
| 213 |
+
``directory-separators`` immediately following them. The parent of the
|
| 214 |
+
root directory is treated as still the root directory (``/../a --> /a``).
|
| 215 |
+
6. If the last ``item-name`` is ``..``, remove any trailing
|
| 216 |
+
``directory-separator`` (``../ --> ..``).
|
| 217 |
+
7. If the path is empty by this stage, add a ``dot`` (normal form of ``./``
|
| 218 |
+
is ``.``).
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
.. _Path Decomposition:
|
| 222 |
+
|
| 223 |
+
Decomposition
|
| 224 |
+
^^^^^^^^^^^^^
|
| 225 |
+
|
| 226 |
+
.. _GET:
|
| 227 |
+
.. _GET_ROOT_NAME:
|
| 228 |
+
.. _GET_ROOT_DIRECTORY:
|
| 229 |
+
.. _GET_ROOT_PATH:
|
| 230 |
+
.. _GET_FILENAME:
|
| 231 |
+
.. _GET_EXTENSION:
|
| 232 |
+
.. _GET_STEM:
|
| 233 |
+
.. _GET_RELATIVE_PART:
|
| 234 |
+
.. _GET_PARENT_PATH:
|
| 235 |
+
|
| 236 |
+
The following forms of the ``GET`` subcommand each retrieve a different
|
| 237 |
+
component or group of components from a path. See
|
| 238 |
+
`Path Structure And Terminology`_ for the meaning of each path component.
|
| 239 |
+
|
| 240 |
+
.. code-block:: cmake
|
| 241 |
+
|
| 242 |
+
cmake_path(GET <path-var> ROOT_NAME <out-var>)
|
| 243 |
+
cmake_path(GET <path-var> ROOT_DIRECTORY <out-var>)
|
| 244 |
+
cmake_path(GET <path-var> ROOT_PATH <out-var>)
|
| 245 |
+
cmake_path(GET <path-var> FILENAME <out-var>)
|
| 246 |
+
cmake_path(GET <path-var> EXTENSION [LAST_ONLY] <out-var>)
|
| 247 |
+
cmake_path(GET <path-var> STEM [LAST_ONLY] <out-var>)
|
| 248 |
+
cmake_path(GET <path-var> RELATIVE_PART <out-var>)
|
| 249 |
+
cmake_path(GET <path-var> PARENT_PATH <out-var>)
|
| 250 |
+
|
| 251 |
+
If a requested component is not present in the path, an empty string will be
|
| 252 |
+
stored in ``<out-var>``. For example, only Windows systems have the concept
|
| 253 |
+
of a ``root-name``, so when the host machine is non-Windows, the ``ROOT_NAME``
|
| 254 |
+
subcommand will always return an empty string.
|
| 255 |
+
|
| 256 |
+
For ``PARENT_PATH``, if the `HAS_RELATIVE_PART`_ subcommand returns false,
|
| 257 |
+
the result is a copy of ``<path-var>``. Note that this implies that a root
|
| 258 |
+
directory is considered to have a parent, with that parent being itself.
|
| 259 |
+
Where `HAS_RELATIVE_PART`_ returns true, the result will essentially be
|
| 260 |
+
``<path-var>`` with one less element.
|
| 261 |
+
|
| 262 |
+
Root examples
|
| 263 |
+
"""""""""""""
|
| 264 |
+
|
| 265 |
+
.. code-block:: cmake
|
| 266 |
+
|
| 267 |
+
set(path "c:/a")
|
| 268 |
+
|
| 269 |
+
cmake_path(GET path ROOT_NAME rootName)
|
| 270 |
+
cmake_path(GET path ROOT_DIRECTORY rootDir)
|
| 271 |
+
cmake_path(GET path ROOT_PATH rootPath)
|
| 272 |
+
|
| 273 |
+
message("Root name is \"${rootName}\"")
|
| 274 |
+
message("Root directory is \"${rootDir}\"")
|
| 275 |
+
message("Root path is \"${rootPath}\"")
|
| 276 |
+
|
| 277 |
+
::
|
| 278 |
+
|
| 279 |
+
Root name is "c:"
|
| 280 |
+
Root directory is "/"
|
| 281 |
+
Root path is "c:/"
|
| 282 |
+
|
| 283 |
+
Filename examples
|
| 284 |
+
"""""""""""""""""
|
| 285 |
+
|
| 286 |
+
.. code-block:: cmake
|
| 287 |
+
|
| 288 |
+
set(path "/a/b")
|
| 289 |
+
cmake_path(GET path FILENAME filename)
|
| 290 |
+
message("First filename is \"${filename}\"")
|
| 291 |
+
|
| 292 |
+
# Trailing slash means filename is empty
|
| 293 |
+
set(path "/a/b/")
|
| 294 |
+
cmake_path(GET path FILENAME filename)
|
| 295 |
+
message("Second filename is \"${filename}\"")
|
| 296 |
+
|
| 297 |
+
::
|
| 298 |
+
|
| 299 |
+
First filename is "b"
|
| 300 |
+
Second filename is ""
|
| 301 |
+
|
| 302 |
+
Extension and stem examples
|
| 303 |
+
"""""""""""""""""""""""""""
|
| 304 |
+
|
| 305 |
+
.. code-block:: cmake
|
| 306 |
+
|
| 307 |
+
set(path "name.ext1.ext2")
|
| 308 |
+
|
| 309 |
+
cmake_path(GET path EXTENSION fullExt)
|
| 310 |
+
cmake_path(GET path STEM fullStem)
|
| 311 |
+
message("Full extension is \"${fullExt}\"")
|
| 312 |
+
message("Full stem is \"${fullStem}\"")
|
| 313 |
+
|
| 314 |
+
# Effect of LAST_ONLY
|
| 315 |
+
cmake_path(GET path EXTENSION LAST_ONLY lastExt)
|
| 316 |
+
cmake_path(GET path STEM LAST_ONLY lastStem)
|
| 317 |
+
message("Last extension is \"${lastExt}\"")
|
| 318 |
+
message("Last stem is \"${lastStem}\"")
|
| 319 |
+
|
| 320 |
+
# Special cases
|
| 321 |
+
set(dotPath "/a/.")
|
| 322 |
+
set(dotDotPath "/a/..")
|
| 323 |
+
set(someMorePath "/a/.some.more")
|
| 324 |
+
cmake_path(GET dotPath EXTENSION dotExt)
|
| 325 |
+
cmake_path(GET dotPath STEM dotStem)
|
| 326 |
+
cmake_path(GET dotDotPath EXTENSION dotDotExt)
|
| 327 |
+
cmake_path(GET dotDotPath STEM dotDotStem)
|
| 328 |
+
cmake_path(GET dotMorePath EXTENSION someMoreExt)
|
| 329 |
+
cmake_path(GET dotMorePath STEM someMoreStem)
|
| 330 |
+
message("Dot extension is \"${dotExt}\"")
|
| 331 |
+
message("Dot stem is \"${dotStem}\"")
|
| 332 |
+
message("Dot-dot extension is \"${dotDotExt}\"")
|
| 333 |
+
message("Dot-dot stem is \"${dotDotStem}\"")
|
| 334 |
+
message(".some.more extension is \"${someMoreExt}\"")
|
| 335 |
+
message(".some.more stem is \"${someMoreStem}\"")
|
| 336 |
+
|
| 337 |
+
::
|
| 338 |
+
|
| 339 |
+
Full extension is ".ext1.ext2"
|
| 340 |
+
Full stem is "name"
|
| 341 |
+
Last extension is ".ext2"
|
| 342 |
+
Last stem is "name.ext1"
|
| 343 |
+
Dot extension is ""
|
| 344 |
+
Dot stem is "."
|
| 345 |
+
Dot-dot extension is ""
|
| 346 |
+
Dot-dot stem is ".."
|
| 347 |
+
.some.more extension is ".more"
|
| 348 |
+
.some.more stem is ".some"
|
| 349 |
+
|
| 350 |
+
Relative part examples
|
| 351 |
+
""""""""""""""""""""""
|
| 352 |
+
|
| 353 |
+
.. code-block:: cmake
|
| 354 |
+
|
| 355 |
+
set(path "c:/a/b")
|
| 356 |
+
cmake_path(GET path RELATIVE_PART result)
|
| 357 |
+
message("Relative part is \"${result}\"")
|
| 358 |
+
|
| 359 |
+
set(path "c/d")
|
| 360 |
+
cmake_path(GET path RELATIVE_PART result)
|
| 361 |
+
message("Relative part is \"${result}\"")
|
| 362 |
+
|
| 363 |
+
set(path "/")
|
| 364 |
+
cmake_path(GET path RELATIVE_PART result)
|
| 365 |
+
message("Relative part is \"${result}\"")
|
| 366 |
+
|
| 367 |
+
::
|
| 368 |
+
|
| 369 |
+
Relative part is "a/b"
|
| 370 |
+
Relative part is "c/d"
|
| 371 |
+
Relative part is ""
|
| 372 |
+
|
| 373 |
+
Path traversal examples
|
| 374 |
+
"""""""""""""""""""""""
|
| 375 |
+
|
| 376 |
+
.. code-block:: cmake
|
| 377 |
+
|
| 378 |
+
set(path "c:/a/b")
|
| 379 |
+
cmake_path(GET path PARENT_PATH result)
|
| 380 |
+
message("Parent path is \"${result}\"")
|
| 381 |
+
|
| 382 |
+
set(path "c:/")
|
| 383 |
+
cmake_path(GET path PARENT_PATH result)
|
| 384 |
+
message("Parent path is \"${result}\"")
|
| 385 |
+
|
| 386 |
+
::
|
| 387 |
+
|
| 388 |
+
Parent path is "c:/a"
|
| 389 |
+
Parent path is "c:/"
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
.. _Path Query:
|
| 393 |
+
|
| 394 |
+
Query
|
| 395 |
+
^^^^^
|
| 396 |
+
|
| 397 |
+
Each of the ``GET`` subcommands has a corresponding ``HAS_...``
|
| 398 |
+
subcommand which can be used to discover whether a particular path
|
| 399 |
+
component is present. See `Path Structure And Terminology`_ for the
|
| 400 |
+
meaning of each path component.
|
| 401 |
+
|
| 402 |
+
.. _HAS_ROOT_NAME:
|
| 403 |
+
.. _HAS_ROOT_DIRECTORY:
|
| 404 |
+
.. _HAS_ROOT_PATH:
|
| 405 |
+
.. _HAS_FILENAME:
|
| 406 |
+
.. _HAS_EXTENSION:
|
| 407 |
+
.. _HAS_STEM:
|
| 408 |
+
.. _HAS_RELATIVE_PART:
|
| 409 |
+
.. _HAS_PARENT_PATH:
|
| 410 |
+
|
| 411 |
+
.. code-block:: cmake
|
| 412 |
+
|
| 413 |
+
cmake_path(HAS_ROOT_NAME <path-var> <out-var>)
|
| 414 |
+
cmake_path(HAS_ROOT_DIRECTORY <path-var> <out-var>)
|
| 415 |
+
cmake_path(HAS_ROOT_PATH <path-var> <out-var>)
|
| 416 |
+
cmake_path(HAS_FILENAME <path-var> <out-var>)
|
| 417 |
+
cmake_path(HAS_EXTENSION <path-var> <out-var>)
|
| 418 |
+
cmake_path(HAS_STEM <path-var> <out-var>)
|
| 419 |
+
cmake_path(HAS_RELATIVE_PART <path-var> <out-var>)
|
| 420 |
+
cmake_path(HAS_PARENT_PATH <path-var> <out-var>)
|
| 421 |
+
|
| 422 |
+
Each of the above follows the predictable pattern of setting ``<out-var>``
|
| 423 |
+
to true if the path has the associated component, or false otherwise.
|
| 424 |
+
Note the following special cases:
|
| 425 |
+
|
| 426 |
+
* For ``HAS_ROOT_PATH``, a true result will only be returned if at least one
|
| 427 |
+
of ``root-name`` or ``root-directory`` is non-empty.
|
| 428 |
+
|
| 429 |
+
* For ``HAS_PARENT_PATH``, the root directory is also considered to have a
|
| 430 |
+
parent, which will be itself. The result is true except if the path
|
| 431 |
+
consists of just a :ref:`filename <FILENAME_DEF>`.
|
| 432 |
+
|
| 433 |
+
.. _IS_ABSOLUTE:
|
| 434 |
+
|
| 435 |
+
.. code-block:: cmake
|
| 436 |
+
|
| 437 |
+
cmake_path(IS_ABSOLUTE <path-var> <out-var>)
|
| 438 |
+
|
| 439 |
+
Sets ``<out-var>`` to true if ``<path-var>`` is absolute. An absolute path
|
| 440 |
+
is a path that unambiguously identifies the location of a file without
|
| 441 |
+
reference to an additional starting location. On Windows, this means the
|
| 442 |
+
path must have both a ``root-name`` and a ``root-directory-separator`` to be
|
| 443 |
+
considered absolute. On other platforms, just a ``root-directory-separator``
|
| 444 |
+
is sufficient. Note that this means on Windows, ``IS_ABSOLUTE`` can be
|
| 445 |
+
false while ``HAS_ROOT_DIRECTORY`` can be true.
|
| 446 |
+
|
| 447 |
+
.. _IS_RELATIVE:
|
| 448 |
+
|
| 449 |
+
.. code-block:: cmake
|
| 450 |
+
|
| 451 |
+
cmake_path(IS_RELATIVE <path-var> <out-var>)
|
| 452 |
+
|
| 453 |
+
This will store the opposite of ``IS_ABSOLUTE`` in ``<out-var>``.
|
| 454 |
+
|
| 455 |
+
.. _IS_PREFIX:
|
| 456 |
+
|
| 457 |
+
.. code-block:: cmake
|
| 458 |
+
|
| 459 |
+
cmake_path(IS_PREFIX <path-var> <input> [NORMALIZE] <out-var>)
|
| 460 |
+
|
| 461 |
+
Checks if ``<path-var>`` is the prefix of ``<input>``.
|
| 462 |
+
|
| 463 |
+
When the ``NORMALIZE`` option is specified, ``<path-var>`` and ``<input>``
|
| 464 |
+
are :ref:`normalized <Normalization>` before the check.
|
| 465 |
+
|
| 466 |
+
.. code-block:: cmake
|
| 467 |
+
|
| 468 |
+
set(path "/a/b/c")
|
| 469 |
+
cmake_path(IS_PREFIX path "/a/b/c/d" result) # result = true
|
| 470 |
+
cmake_path(IS_PREFIX path "/a/b" result) # result = false
|
| 471 |
+
cmake_path(IS_PREFIX path "/x/y/z" result) # result = false
|
| 472 |
+
|
| 473 |
+
set(path "/a/b")
|
| 474 |
+
cmake_path(IS_PREFIX path "/a/c/../b" NORMALIZE result) # result = true
|
| 475 |
+
|
| 476 |
+
.. _Path COMPARE:
|
| 477 |
+
.. _COMPARE:
|
| 478 |
+
|
| 479 |
+
.. code-block:: cmake
|
| 480 |
+
|
| 481 |
+
cmake_path(COMPARE <input1> EQUAL <input2> <out-var>)
|
| 482 |
+
cmake_path(COMPARE <input1> NOT_EQUAL <input2> <out-var>)
|
| 483 |
+
|
| 484 |
+
Compares the lexical representations of two paths provided as string literals.
|
| 485 |
+
No normalization is performed on either path, except multiple consecutive
|
| 486 |
+
directory separators are effectively collapsed into a single separator.
|
| 487 |
+
Equality is determined according to the following pseudo-code logic:
|
| 488 |
+
|
| 489 |
+
::
|
| 490 |
+
|
| 491 |
+
if(NOT <input1>.root_name() STREQUAL <input2>.root_name())
|
| 492 |
+
return FALSE
|
| 493 |
+
|
| 494 |
+
if(<input1>.has_root_directory() XOR <input2>.has_root_directory())
|
| 495 |
+
return FALSE
|
| 496 |
+
|
| 497 |
+
Return FALSE if a relative portion of <input1> is not lexicographically
|
| 498 |
+
equal to the relative portion of <input2>. This comparison is performed path
|
| 499 |
+
component-wise. If all of the components compare equal, then return TRUE.
|
| 500 |
+
|
| 501 |
+
.. note::
|
| 502 |
+
Unlike most other ``cmake_path()`` subcommands, the ``COMPARE`` subcommand
|
| 503 |
+
takes literal strings as input, not the names of variables.
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
.. _Path Modification:
|
| 507 |
+
|
| 508 |
+
Modification
|
| 509 |
+
^^^^^^^^^^^^
|
| 510 |
+
|
| 511 |
+
.. _cmake_path-SET:
|
| 512 |
+
|
| 513 |
+
.. code-block:: cmake
|
| 514 |
+
|
| 515 |
+
cmake_path(SET <path-var> [NORMALIZE] <input>)
|
| 516 |
+
|
| 517 |
+
Assign the ``<input>`` path to ``<path-var>``. If ``<input>`` is a native
|
| 518 |
+
path, it is converted into a cmake-style path with forward-slashes
|
| 519 |
+
(``/``). On Windows, the long filename marker is taken into account.
|
| 520 |
+
|
| 521 |
+
When the ``NORMALIZE`` option is specified, the path is :ref:`normalized
|
| 522 |
+
<Normalization>` after the conversion.
|
| 523 |
+
|
| 524 |
+
For example:
|
| 525 |
+
|
| 526 |
+
.. code-block:: cmake
|
| 527 |
+
|
| 528 |
+
set(native_path "c:\\a\\b/..\\c")
|
| 529 |
+
cmake_path(SET path "${native_path}")
|
| 530 |
+
message("CMake path is \"${path}\"")
|
| 531 |
+
|
| 532 |
+
cmake_path(SET path NORMALIZE "${native_path}")
|
| 533 |
+
message("Normalized CMake path is \"${path}\"")
|
| 534 |
+
|
| 535 |
+
Output::
|
| 536 |
+
|
| 537 |
+
CMake path is "c:/a/b/../c"
|
| 538 |
+
Normalized CMake path is "c:/a/c"
|
| 539 |
+
|
| 540 |
+
.. _APPEND:
|
| 541 |
+
|
| 542 |
+
.. code-block:: cmake
|
| 543 |
+
|
| 544 |
+
cmake_path(APPEND <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
|
| 545 |
+
|
| 546 |
+
Append all the ``<input>`` arguments to the ``<path-var>`` using ``/`` as
|
| 547 |
+
the ``directory-separator``. Depending on the ``<input>``, the previous
|
| 548 |
+
contents of ``<path-var>`` may be discarded. For each ``<input>`` argument,
|
| 549 |
+
the following algorithm (pseudo-code) applies:
|
| 550 |
+
|
| 551 |
+
::
|
| 552 |
+
|
| 553 |
+
# <path> is the contents of <path-var>
|
| 554 |
+
|
| 555 |
+
if(<input>.is_absolute() OR
|
| 556 |
+
(<input>.has_root_name() AND
|
| 557 |
+
NOT <input>.root_name() STREQUAL <path>.root_name()))
|
| 558 |
+
replace <path> with <input>
|
| 559 |
+
return()
|
| 560 |
+
endif()
|
| 561 |
+
|
| 562 |
+
if(<input>.has_root_directory())
|
| 563 |
+
remove any root-directory and the entire relative path from <path>
|
| 564 |
+
elseif(<path>.has_filename() OR
|
| 565 |
+
(NOT <path-var>.has_root_directory() OR <path>.is_absolute()))
|
| 566 |
+
append directory-separator to <path>
|
| 567 |
+
endif()
|
| 568 |
+
|
| 569 |
+
append <input> omitting any root-name to <path>
|
| 570 |
+
|
| 571 |
+
.. _APPEND_STRING:
|
| 572 |
+
|
| 573 |
+
.. code-block:: cmake
|
| 574 |
+
|
| 575 |
+
cmake_path(APPEND_STRING <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>])
|
| 576 |
+
|
| 577 |
+
Append all the ``<input>`` arguments to the ``<path-var>`` without adding any
|
| 578 |
+
``directory-separator``.
|
| 579 |
+
|
| 580 |
+
.. _REMOVE_FILENAME:
|
| 581 |
+
|
| 582 |
+
.. code-block:: cmake
|
| 583 |
+
|
| 584 |
+
cmake_path(REMOVE_FILENAME <path-var> [OUTPUT_VARIABLE <out-var>])
|
| 585 |
+
|
| 586 |
+
Removes the :ref:`filename <FILENAME_DEF>` component (as returned by
|
| 587 |
+
:ref:`GET ... FILENAME <GET_FILENAME>`) from ``<path-var>``. After removal,
|
| 588 |
+
any trailing ``directory-separator`` is left alone, if present.
|
| 589 |
+
|
| 590 |
+
If ``OUTPUT_VARIABLE`` is not given, then after this function returns,
|
| 591 |
+
`HAS_FILENAME`_ returns false for ``<path-var>``.
|
| 592 |
+
|
| 593 |
+
For example:
|
| 594 |
+
|
| 595 |
+
.. code-block:: cmake
|
| 596 |
+
|
| 597 |
+
set(path "/a/b")
|
| 598 |
+
cmake_path(REMOVE_FILENAME path)
|
| 599 |
+
message("First path is \"${path}\"")
|
| 600 |
+
|
| 601 |
+
# filename is now already empty, the following removes nothing
|
| 602 |
+
cmake_path(REMOVE_FILENAME path)
|
| 603 |
+
message("Second path is \"${path}\"")
|
| 604 |
+
|
| 605 |
+
Output::
|
| 606 |
+
|
| 607 |
+
First path is "/a/"
|
| 608 |
+
Second path is "/a/"
|
| 609 |
+
|
| 610 |
+
.. _REPLACE_FILENAME:
|
| 611 |
+
|
| 612 |
+
.. code-block:: cmake
|
| 613 |
+
|
| 614 |
+
cmake_path(REPLACE_FILENAME <path-var> <input> [OUTPUT_VARIABLE <out-var>])
|
| 615 |
+
|
| 616 |
+
Replaces the :ref:`filename <FILENAME_DEF>` component from ``<path-var>``
|
| 617 |
+
with ``<input>``. If ``<path-var>`` has no filename component (i.e.
|
| 618 |
+
`HAS_FILENAME`_ returns false), the path is unchanged. The operation is
|
| 619 |
+
equivalent to the following:
|
| 620 |
+
|
| 621 |
+
.. code-block:: cmake
|
| 622 |
+
|
| 623 |
+
cmake_path(HAS_FILENAME path has_filename)
|
| 624 |
+
if(has_filename)
|
| 625 |
+
cmake_path(REMOVE_FILENAME path)
|
| 626 |
+
cmake_path(APPEND path input);
|
| 627 |
+
endif()
|
| 628 |
+
|
| 629 |
+
.. _REMOVE_EXTENSION:
|
| 630 |
+
|
| 631 |
+
.. code-block:: cmake
|
| 632 |
+
|
| 633 |
+
cmake_path(REMOVE_EXTENSION <path-var> [LAST_ONLY]
|
| 634 |
+
[OUTPUT_VARIABLE <out-var>])
|
| 635 |
+
|
| 636 |
+
Removes the :ref:`extension <EXTENSION_DEF>`, if any, from ``<path-var>``.
|
| 637 |
+
|
| 638 |
+
.. _REPLACE_EXTENSION:
|
| 639 |
+
|
| 640 |
+
.. code-block:: cmake
|
| 641 |
+
|
| 642 |
+
cmake_path(REPLACE_EXTENSION <path-var> [LAST_ONLY] <input>
|
| 643 |
+
[OUTPUT_VARIABLE <out-var>])
|
| 644 |
+
|
| 645 |
+
Replaces the :ref:`extension <EXTENSION_DEF>` with ``<input>``. Its effect
|
| 646 |
+
is equivalent to the following:
|
| 647 |
+
|
| 648 |
+
.. code-block:: cmake
|
| 649 |
+
|
| 650 |
+
cmake_path(REMOVE_EXTENSION path)
|
| 651 |
+
if(NOT "input" MATCHES "^\\.")
|
| 652 |
+
cmake_path(APPEND_STRING path ".")
|
| 653 |
+
endif()
|
| 654 |
+
cmake_path(APPEND_STRING path "input")
|
| 655 |
+
|
| 656 |
+
|
| 657 |
+
.. _Path Generation:
|
| 658 |
+
|
| 659 |
+
Generation
|
| 660 |
+
^^^^^^^^^^
|
| 661 |
+
|
| 662 |
+
.. _NORMAL_PATH:
|
| 663 |
+
|
| 664 |
+
.. code-block:: cmake
|
| 665 |
+
|
| 666 |
+
cmake_path(NORMAL_PATH <path-var> [OUTPUT_VARIABLE <out-var>])
|
| 667 |
+
|
| 668 |
+
Normalize ``<path-var>`` according the steps described in :ref:`Normalization`.
|
| 669 |
+
|
| 670 |
+
.. _cmake_path-RELATIVE_PATH:
|
| 671 |
+
.. _RELATIVE_PATH:
|
| 672 |
+
|
| 673 |
+
.. code-block:: cmake
|
| 674 |
+
|
| 675 |
+
cmake_path(RELATIVE_PATH <path-var> [BASE_DIRECTORY <input>]
|
| 676 |
+
[OUTPUT_VARIABLE <out-var>])
|
| 677 |
+
|
| 678 |
+
Modifies ``<path-var>`` to make it relative to the ``BASE_DIRECTORY`` argument.
|
| 679 |
+
If ``BASE_DIRECTORY`` is not specified, the default base directory will be
|
| 680 |
+
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
|
| 681 |
+
|
| 682 |
+
For reference, the algorithm used to compute the relative path is the same
|
| 683 |
+
as that used by C++
|
| 684 |
+
`std::filesystem::path::lexically_relative
|
| 685 |
+
<https://en.cppreference.com/w/cpp/filesystem/path/lexically_normal>`_.
|
| 686 |
+
|
| 687 |
+
.. _ABSOLUTE_PATH:
|
| 688 |
+
|
| 689 |
+
.. code-block:: cmake
|
| 690 |
+
|
| 691 |
+
cmake_path(ABSOLUTE_PATH <path-var> [BASE_DIRECTORY <input>] [NORMALIZE]
|
| 692 |
+
[OUTPUT_VARIABLE <out-var>])
|
| 693 |
+
|
| 694 |
+
If ``<path-var>`` is a relative path (`IS_RELATIVE`_ is true), it is evaluated
|
| 695 |
+
relative to the given base directory specified by ``BASE_DIRECTORY`` option.
|
| 696 |
+
If ``BASE_DIRECTORY`` is not specified, the default base directory will be
|
| 697 |
+
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
|
| 698 |
+
|
| 699 |
+
When the ``NORMALIZE`` option is specified, the path is :ref:`normalized
|
| 700 |
+
<Normalization>` after the path computation.
|
| 701 |
+
|
| 702 |
+
Because ``cmake_path()`` does not access the filesystem, symbolic links are
|
| 703 |
+
not resolved and any leading tilde is not expanded. To compute a real path
|
| 704 |
+
with symbolic links resolved and leading tildes expanded, use the
|
| 705 |
+
:command:`file(REAL_PATH)` command instead.
|
| 706 |
+
|
| 707 |
+
Native Conversion
|
| 708 |
+
^^^^^^^^^^^^^^^^^
|
| 709 |
+
|
| 710 |
+
For commands in this section, *native* refers to the host platform, not the
|
| 711 |
+
target platform when cross-compiling.
|
| 712 |
+
|
| 713 |
+
.. _cmake_path-NATIVE_PATH:
|
| 714 |
+
.. _NATIVE_PATH:
|
| 715 |
+
|
| 716 |
+
.. code-block:: cmake
|
| 717 |
+
|
| 718 |
+
cmake_path(NATIVE_PATH <path-var> [NORMALIZE] <out-var>)
|
| 719 |
+
|
| 720 |
+
Converts a cmake-style ``<path-var>`` into a native path with
|
| 721 |
+
platform-specific slashes (``\`` on Windows hosts and ``/`` elsewhere).
|
| 722 |
+
|
| 723 |
+
When the ``NORMALIZE`` option is specified, the path is :ref:`normalized
|
| 724 |
+
<Normalization>` before the conversion.
|
| 725 |
+
|
| 726 |
+
.. _CONVERT:
|
| 727 |
+
.. _cmake_path-TO_CMAKE_PATH_LIST:
|
| 728 |
+
.. _TO_CMAKE_PATH_LIST:
|
| 729 |
+
|
| 730 |
+
.. code-block:: cmake
|
| 731 |
+
|
| 732 |
+
cmake_path(CONVERT <input> TO_CMAKE_PATH_LIST <out-var> [NORMALIZE])
|
| 733 |
+
|
| 734 |
+
Converts a native ``<input>`` path into a cmake-style path with forward
|
| 735 |
+
slashes (``/``). On Windows hosts, the long filename marker is taken into
|
| 736 |
+
account. The input can be a single path or a system search path like
|
| 737 |
+
``$ENV{PATH}``. A search path will be converted to a cmake-style list
|
| 738 |
+
separated by ``;`` characters (on non-Windows platforms, this essentially
|
| 739 |
+
means ``:`` separators are replaced with ``;``). The result of the
|
| 740 |
+
conversion is stored in the ``<out-var>`` variable.
|
| 741 |
+
|
| 742 |
+
When the ``NORMALIZE`` option is specified, the path is :ref:`normalized
|
| 743 |
+
<Normalization>` before the conversion.
|
| 744 |
+
|
| 745 |
+
.. note::
|
| 746 |
+
Unlike most other ``cmake_path()`` subcommands, the ``CONVERT`` subcommand
|
| 747 |
+
takes a literal string as input, not the name of a variable.
|
| 748 |
+
|
| 749 |
+
.. _cmake_path-TO_NATIVE_PATH_LIST:
|
| 750 |
+
.. _TO_NATIVE_PATH_LIST:
|
| 751 |
+
|
| 752 |
+
.. code-block:: cmake
|
| 753 |
+
|
| 754 |
+
cmake_path(CONVERT <input> TO_NATIVE_PATH_LIST <out-var> [NORMALIZE])
|
| 755 |
+
|
| 756 |
+
Converts a cmake-style ``<input>`` path into a native path with
|
| 757 |
+
platform-specific slashes (``\`` on Windows hosts and ``/`` elsewhere).
|
| 758 |
+
The input can be a single path or a cmake-style list. A list will be
|
| 759 |
+
converted into a native search path (``;``-separated on Windows,
|
| 760 |
+
``:``-separated on other platforms). The result of the conversion is
|
| 761 |
+
stored in the ``<out-var>`` variable.
|
| 762 |
+
|
| 763 |
+
When the ``NORMALIZE`` option is specified, the path is :ref:`normalized
|
| 764 |
+
<Normalization>` before the conversion.
|
| 765 |
+
|
| 766 |
+
.. note::
|
| 767 |
+
Unlike most other ``cmake_path()`` subcommands, the ``CONVERT`` subcommand
|
| 768 |
+
takes a literal string as input, not the name of a variable.
|
| 769 |
+
|
| 770 |
+
For example:
|
| 771 |
+
|
| 772 |
+
.. code-block:: cmake
|
| 773 |
+
|
| 774 |
+
set(paths "/a/b/c" "/x/y/z")
|
| 775 |
+
cmake_path(CONVERT "${paths}" TO_NATIVE_PATH_LIST native_paths)
|
| 776 |
+
message("Native path list is \"${native_paths}\"")
|
| 777 |
+
|
| 778 |
+
Output on Windows::
|
| 779 |
+
|
| 780 |
+
Native path list is "\a\b\c;\x\y\z"
|
| 781 |
+
|
| 782 |
+
Output on all other platforms::
|
| 783 |
+
|
| 784 |
+
Native path list is "/a/b/c:/x/y/z"
|
| 785 |
+
|
| 786 |
+
Hashing
|
| 787 |
+
^^^^^^^
|
| 788 |
+
|
| 789 |
+
.. _HASH:
|
| 790 |
+
|
| 791 |
+
.. code-block:: cmake
|
| 792 |
+
|
| 793 |
+
cmake_path(HASH <path-var> <out-var>)
|
| 794 |
+
|
| 795 |
+
Compute a hash value of ``<path-var>`` such that for two paths ``p1`` and
|
| 796 |
+
``p2`` that compare equal (:ref:`COMPARE ... EQUAL <COMPARE>`), the hash
|
| 797 |
+
value of ``p1`` is equal to the hash value of ``p2``. The path is always
|
| 798 |
+
:ref:`normalized <Normalization>` before the hash is computed.
|
cmake/share/cmake-3.31/Help/command/cmake_pkg_config.rst
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 13 |
+
^^^^^^^^
|
| 14 |
+
|
| 15 |
+
.. parsed-literal::
|
| 16 |
+
|
| 17 |
+
cmake_pkg_config(EXTRACT <package> [<version>] [...])
|
| 18 |
+
|
| 19 |
+
Introduction
|
| 20 |
+
^^^^^^^^^^^^
|
| 21 |
+
|
| 22 |
+
This command generates CMake variables and targets from pkg-config format
|
| 23 |
+
package files natively, without needing to invoke or even require the presence
|
| 24 |
+
of a pkg-config implementation. A ``<package>`` is either an absolute path to a
|
| 25 |
+
package file, or a package name to be searched for using the typical pkg-config
|
| 26 |
+
search patterns. The optional ``<version>`` string has the same format and
|
| 27 |
+
semantics as a pkg-config style version specifier, with the exception that if
|
| 28 |
+
no comparison operator is specified ``=`` is assumed.
|
| 29 |
+
|
| 30 |
+
.. _`common options`:
|
| 31 |
+
|
| 32 |
+
There are multiple signatures for this command, and some of the options are
|
| 33 |
+
common between them. They are:
|
| 34 |
+
|
| 35 |
+
``EXACT`` / ``QUIET`` / ``REQUIRED``
|
| 36 |
+
The ``EXACT`` option requests that the version string be matched exactly
|
| 37 |
+
(including empty string, if no version is provided), overriding the typical
|
| 38 |
+
pkg-config version comparison algorithm. This will ignore any comparison
|
| 39 |
+
operator attached to the version string.
|
| 40 |
+
|
| 41 |
+
The ``QUIET`` option disables informational messages, including those
|
| 42 |
+
indicating that the package cannot be found if it is not ``REQUIRED``. The
|
| 43 |
+
``REQUIRED`` option stops processing with an error message if the package
|
| 44 |
+
cannot be found.
|
| 45 |
+
|
| 46 |
+
``STRICTNESS <mode>``
|
| 47 |
+
Specify how strictly the contents of the package files will be verified during
|
| 48 |
+
parsing and resolution. An invalid file, under the provided strictness mode,
|
| 49 |
+
will cause the command to fail. Possible modes are:
|
| 50 |
+
|
| 51 |
+
* ``STRICT``: Closely mirrors the behavior of the original FDO pkg-config.
|
| 52 |
+
Variables and keywords must be unique. Variables must be defined before
|
| 53 |
+
they are used. The Name, Description, and Version keywords must be present.
|
| 54 |
+
The overall structure of the file must be valid and parsable.
|
| 55 |
+
|
| 56 |
+
* ``PERMISSIVE``: Closely mirrors the behavior of the pkgconf implementation.
|
| 57 |
+
Duplicate variables are overridden. Duplicate keywords are appended.
|
| 58 |
+
Undefined variables resolve to empty strings. The Name, Description, and
|
| 59 |
+
Version keywords must be present. The overall structure of the file must be
|
| 60 |
+
valid and parsable.
|
| 61 |
+
|
| 62 |
+
* ``BEST_EFFORT``: Same behavior as ``PERMISSIVE`` with regards to duplicate
|
| 63 |
+
or uninitialized variables and keywords, but will not fail under any
|
| 64 |
+
conditions. Package files which require BEST_EFFORT will fail validation
|
| 65 |
+
under all other major implementations and should be fixed.
|
| 66 |
+
|
| 67 |
+
The default strictness is ``PERMISSIVE``.
|
| 68 |
+
|
| 69 |
+
``ENV_MODE``
|
| 70 |
+
Specifies which environment variables will be queried when running a given
|
| 71 |
+
command. Possible modes are:
|
| 72 |
+
|
| 73 |
+
* ``FDO``: Queries only the original set of ``PKG_CONFIG_*`` environment
|
| 74 |
+
variables used by the freedesktop.org ``pkg-config`` implementation.
|
| 75 |
+
|
| 76 |
+
* ``PKGCONF``: Queries the more extensive set of environment variables used
|
| 77 |
+
by the ``pkgconf`` implementation.
|
| 78 |
+
|
| 79 |
+
* ``IGNORE``: Ignores the presence, absence, and value of environment
|
| 80 |
+
variables entirely. In all cases an environment variable would be queried
|
| 81 |
+
its treated as defined, but with a value of empty string for the purpose
|
| 82 |
+
of the operation. This does not modify the current environment. For boolean
|
| 83 |
+
environment variables, such as ``PKG_CONFIG_ALLOW_*``, this means they are
|
| 84 |
+
evaluated as truthy.
|
| 85 |
+
|
| 86 |
+
``PKG_CONFIG_SYSROOT_PATH`` is a minor exception. When ``ENV_MODE IGNORE``
|
| 87 |
+
is used, no root path prepending will occur by default and ``pc_sysrootdir``
|
| 88 |
+
remains defaulted to ``/``.
|
| 89 |
+
|
| 90 |
+
Target-generating subcommands always ignore flag-filtering environment
|
| 91 |
+
variables. The default environment mode is ``PKGCONF``.
|
| 92 |
+
|
| 93 |
+
``PC_LIBDIR <path>...``
|
| 94 |
+
Overrides the default search location for package files; also used to derive
|
| 95 |
+
the ``pc_path`` package variable.
|
| 96 |
+
|
| 97 |
+
When this option is not provided, the default library directory is the first
|
| 98 |
+
available of the following values:
|
| 99 |
+
|
| 100 |
+
#. ``CMAKE_PKG_CONFIG_PC_LIB_DIRS``
|
| 101 |
+
#. The ``PKG_CONFIG_LIBDIR`` environment variable
|
| 102 |
+
#. The output of ``pkg-config --variable pc_path pkg-config``
|
| 103 |
+
#. A platform-dependent default value
|
| 104 |
+
|
| 105 |
+
``PC_PATH <path>...``
|
| 106 |
+
Overrides the supplemental package file directories which will be prepended
|
| 107 |
+
to the search path; also used to derive the ``pc_path`` package variable.
|
| 108 |
+
|
| 109 |
+
When this option is not provided, the default paths are the first available of
|
| 110 |
+
the following values:
|
| 111 |
+
|
| 112 |
+
#. ``CMAKE_PKG_CONFIG_PC_PATH``
|
| 113 |
+
#. The ``PKG_CONFIG_PATH`` environment variable
|
| 114 |
+
#. Empty list
|
| 115 |
+
|
| 116 |
+
``DISABLE_UNINSTALLED <bool>``
|
| 117 |
+
Overrides the search behavior for "uninstalled" package files. These are
|
| 118 |
+
package files with an "-uninstalled" suffix which describe packages integrated
|
| 119 |
+
directly from a build tree.
|
| 120 |
+
|
| 121 |
+
Normally such package files have higher priority than "installed" packages.
|
| 122 |
+
When ``DISABLE_UNINSTALLED`` is true, searching for "uninstalled" packages
|
| 123 |
+
is disabled.
|
| 124 |
+
|
| 125 |
+
When this option is not provided, the default search behavior is determined
|
| 126 |
+
by the first available of the following values:
|
| 127 |
+
|
| 128 |
+
#. ``CMAKE_PKG_CONFIG_DISABLE_UNINSTALLED``
|
| 129 |
+
#. If the ``PKG_CONFIG_DISABLE_UNINSTALLED`` environment variable is defined
|
| 130 |
+
the search is disabled, otherwise it is enabled.
|
| 131 |
+
|
| 132 |
+
``PC_SYSROOT_DIR <path>``
|
| 133 |
+
Overrides the root path which will be prepended to paths specified by ``-I``
|
| 134 |
+
compile flags and ``-L`` library search locations; also used to derive the
|
| 135 |
+
``pc_sysrootdir`` package variable.
|
| 136 |
+
|
| 137 |
+
When this option is not provided, the default root path is provided by the
|
| 138 |
+
first available of the following values:
|
| 139 |
+
|
| 140 |
+
#. ``CMAKE_PKG_CONFIG_SYSROOT_DIR``
|
| 141 |
+
#. The ``PKG_CONFIG_SYSROOT_DIR`` environment variable
|
| 142 |
+
#. If no root path is available, nothing will be prepended to include or
|
| 143 |
+
library directory paths and ``pc_sysrootdir`` will be set to ``/``
|
| 144 |
+
|
| 145 |
+
``TOP_BUILD_DIR <path>``
|
| 146 |
+
Overrides the top build directory path used to derived the ``pc_top_builddir``
|
| 147 |
+
package variable.
|
| 148 |
+
|
| 149 |
+
When this option is not provided, the default top build directory path is
|
| 150 |
+
the first available of the following values:
|
| 151 |
+
|
| 152 |
+
#. ``CMAKE_PKG_CONFIG_TOP_BUILD_DIR``
|
| 153 |
+
#. The ``PKG_CONFIG_TOP_BUILD_DIR`` environment variable
|
| 154 |
+
#. If no top build directory path is available, the ``pc_top_builddir``
|
| 155 |
+
package variable is not set
|
| 156 |
+
|
| 157 |
+
Signatures
|
| 158 |
+
^^^^^^^^^^
|
| 159 |
+
|
| 160 |
+
.. signature::
|
| 161 |
+
cmake_pkg_config(EXTRACT <package> [<version>] [...])
|
| 162 |
+
|
| 163 |
+
Extract the contents of the package into variables.
|
| 164 |
+
|
| 165 |
+
.. code-block:: cmake
|
| 166 |
+
|
| 167 |
+
cmake_pkg_config(EXTRACT <package> [<version>]
|
| 168 |
+
[REQUIRED] [EXACT] [QUIET]
|
| 169 |
+
[STRICTNESS <mode>]
|
| 170 |
+
[ENV_MODE <mode>]
|
| 171 |
+
[PC_LIBDIR <path>...]
|
| 172 |
+
[PC_PATH <path>...]
|
| 173 |
+
[DISABLE_UNINSTALLED <bool>]
|
| 174 |
+
[PC_SYSROOT_DIR <path>]
|
| 175 |
+
[TOP_BUILD_DIR <path>]
|
| 176 |
+
[SYSTEM_INCLUDE_DIRS <path>...]
|
| 177 |
+
[SYSTEM_LIBRARY_DIRS <path>...]
|
| 178 |
+
[ALLOW_SYSTEM_INCLUDES <bool>]
|
| 179 |
+
[ALLOW_SYSTEM_LIBS <bool>])
|
| 180 |
+
|
| 181 |
+
The following variables will be populated from the contents of package file:
|
| 182 |
+
|
| 183 |
+
==================================== ====== ========================================================================================
|
| 184 |
+
Variable Type Definition
|
| 185 |
+
==================================== ====== ========================================================================================
|
| 186 |
+
``CMAKE_PKG_CONFIG_NAME`` String Value of the ``Name`` keyword
|
| 187 |
+
``CMAKE_PKG_CONFIG_DESCRIPTION`` String Value of the ``Description`` keyword
|
| 188 |
+
``CMAKE_PKG_CONFIG_VERSION`` String Value of the ``Version`` keyword
|
| 189 |
+
``CMAKE_PKG_CONFIG_PROVIDES`` List Value of the ``Provides`` keyword
|
| 190 |
+
``CMAKE_PKG_CONFIG_REQUIRES`` List Value of the ``Requires`` keyword
|
| 191 |
+
``CMAKE_PKG_CONFIG_CONFLICTS`` List Value of the ``Conflicts`` keyword
|
| 192 |
+
``CMAKE_PKG_CONFIG_CFLAGS`` String Value of the ``CFlags`` / ``Cflags`` keyword
|
| 193 |
+
``CMAKE_PKG_CONFIG_INCLUDES`` List All ``-I`` prefixed flags from ``CMAKE_PKG_CONFIG_CFLAGS``
|
| 194 |
+
``CMAKE_PKG_CONFIG_COMPILE_OPTIONS`` List All flags not prefixed with ``-I`` from ``CMAKE_PKG_CONFIG_CFLAGS``
|
| 195 |
+
``CMAKE_PKG_CONFIG_LIBS`` String Value of the ``Libs`` keyword
|
| 196 |
+
``CMAKE_PKG_CONFIG_LIBDIRS`` List All ``-L`` prefixed flags from ``CMAKE_PKG_CONFIG_LIBS``
|
| 197 |
+
``CMAKE_PKG_CONFIG_LIBNAMES`` List All ``-l`` prefixed flags from ``CMAKE_PKG_CONFIG_LIBS``
|
| 198 |
+
``CMAKE_PKG_CONFIG_LINK_OPTIONS`` List All flags not prefixed with ``-L`` or ``-l`` from ``CMAKE_PKG_CONFIG_LIBS``
|
| 199 |
+
``CMAKE_PKG_CONFIG_*_PRIVATE`` \* ``CFLAGS`` / ``LIBS`` / ``REQUIRES`` and derived, but in their ``.private`` suffix forms
|
| 200 |
+
==================================== ====== ========================================================================================
|
| 201 |
+
|
| 202 |
+
``SYSTEM_INCLUDE_DIRS``
|
| 203 |
+
Overrides the "system" directories for the purpose of flag mangling include
|
| 204 |
+
directories in ``CMAKE_PKG_CONFIG_CFLAGS`` and derived variables.
|
| 205 |
+
|
| 206 |
+
When this option is not provided, the default directories are provided by the
|
| 207 |
+
first available of the following values:
|
| 208 |
+
|
| 209 |
+
#. ``CMAKE_PKG_CONFIG_SYS_INCLUDE_DIRS``
|
| 210 |
+
#. The ``PKG_CONFIG_SYSTEM_INCLUDE_PATH`` environment variable
|
| 211 |
+
#. The output of ``pkgconf --variable pc_system_includedirs pkg-config``
|
| 212 |
+
#. A platform-dependent default value
|
| 213 |
+
|
| 214 |
+
Additionally, when the ``ENV_MODE`` is ``PKGCONF`` the
|
| 215 |
+
``CMAKE_PKG_CONFIG_PKGCONF_INCLUDES`` variable will be concatenated to the
|
| 216 |
+
list if available. If it is not available, the following environment variables
|
| 217 |
+
will be queried and concatenated:
|
| 218 |
+
|
| 219 |
+
* ``CPATH``
|
| 220 |
+
* ``C_INCLUDE_PATH``
|
| 221 |
+
* ``CPLUS_INCLUDE_PATH``
|
| 222 |
+
* ``OBJC_INCLUDE_PATH``
|
| 223 |
+
* ``INCLUDE`` (Windows Only)
|
| 224 |
+
|
| 225 |
+
``SYSTEM_LIBRARY_DIRS``
|
| 226 |
+
Overrides the "system" directories for the purpose of flag mangling library
|
| 227 |
+
directories in ``CMAKE_PKG_CONFIG_LIBS`` and derived variables.
|
| 228 |
+
|
| 229 |
+
When this option is not provided, the default directories are provided by the
|
| 230 |
+
first available of the following values:
|
| 231 |
+
|
| 232 |
+
#. ``CMAKE_PKG_CONFIG_SYS_LIB_DIRS``
|
| 233 |
+
#. The ``PKG_CONFIG_SYSTEM_LIBRARY_PATH`` environment variable
|
| 234 |
+
#. The output of ``pkgconf --variable pc_system_libdirs pkg-config``
|
| 235 |
+
#. A platform-dependent default value
|
| 236 |
+
|
| 237 |
+
Additionally, when the ``ENV_MODE`` is ``PKGCONF`` the
|
| 238 |
+
``CMAKE_PKG_CONFIG_PKGCONF_LIB_DIRS`` variable will be concatenated to the
|
| 239 |
+
list if available. If it is not available, the ``LIBRARY_PATH`` environment
|
| 240 |
+
variable will be queried and concatenated.
|
| 241 |
+
|
| 242 |
+
``ALLOW_SYSTEM_INCLUDES``
|
| 243 |
+
Preserves "system" directories during flag mangling of include directories
|
| 244 |
+
in ``CMAKE_PKG_CONFIG_CFLAGS`` and derived variables.
|
| 245 |
+
|
| 246 |
+
When this option is not provided, the default value is determined by the first
|
| 247 |
+
available of the following values:
|
| 248 |
+
|
| 249 |
+
#. ``CMAKE_PKG_CONFIG_ALLOW_SYS_INCLUDES``
|
| 250 |
+
#. If the ``PKG_CONFIG_ALLOW_SYSTEM_CFLAGS`` environment variable is defined
|
| 251 |
+
the flags are preserved, otherwise they are filtered during flag mangling.
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
``ALLOW_SYSTEM_LIBS``
|
| 255 |
+
Preserves "system" directories during flag mangling of library directories
|
| 256 |
+
in ``CMAKE_PKG_CONFIG_LIBS`` and derived variables.
|
| 257 |
+
|
| 258 |
+
When this option is not provided, the default value is determined by the first
|
| 259 |
+
available of the following values:
|
| 260 |
+
|
| 261 |
+
#. ``CMAKE_PKG_CONFIG_ALLOW_SYS_LIBS``
|
| 262 |
+
#. If the ``PKG_CONFIG_ALLOW_SYSTEM_LIBS`` environment variable is defined
|
| 263 |
+
the flags are preserved, otherwise they are filtered during flag mangling.
|
cmake/share/cmake-3.31/Help/command/cmake_policy.rst
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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es necessary to change existing behavior
|
| 8 |
+
in order to fix bugs or improve implementations of existing features.
|
| 9 |
+
The CMake Policy mechanism is designed to help keep existing projects
|
| 10 |
+
building as new versions of CMake introduce changes in behavior. Each
|
| 11 |
+
new policy (behavioral change) is given an identifier of the form
|
| 12 |
+
``CMP<NNNN>`` where ``<NNNN>`` is an integer index. Documentation
|
| 13 |
+
associated with each policy describes the ``OLD`` and ``NEW`` behavior
|
| 14 |
+
and the reason the policy was introduced. Projects may set each policy
|
| 15 |
+
to select the desired behavior. When CMake needs to know which behavior
|
| 16 |
+
to use it checks for a setting specified by the project. If no
|
| 17 |
+
setting is available the ``OLD`` behavior is assumed and a warning is
|
| 18 |
+
produced requesting that the policy be set.
|
| 19 |
+
|
| 20 |
+
Setting Policies by CMake Version
|
| 21 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 22 |
+
|
| 23 |
+
The ``cmake_policy`` command is used to set policies to ``OLD`` or ``NEW``
|
| 24 |
+
behavior. While setting policies individually is supported, we
|
| 25 |
+
encourage projects to set policies based on CMake versions:
|
| 26 |
+
|
| 27 |
+
.. signature:: cmake_policy(VERSION <min>[...<max>])
|
| 28 |
+
:target: VERSION
|
| 29 |
+
|
| 30 |
+
.. versionadded:: 3.12
|
| 31 |
+
The optional ``<max>`` version.
|
| 32 |
+
|
| 33 |
+
``<min>`` and the optional ``<max>`` are each CMake versions of the form
|
| 34 |
+
``major.minor[.patch[.tweak]]``, and the ``...`` is literal. The ``<min>``
|
| 35 |
+
version must be at least ``2.4`` and at most the running version of CMake.
|
| 36 |
+
The ``<max>`` version, if specified, must be at least the ``<min>`` version
|
| 37 |
+
but may exceed the running version of CMake. If the running version of
|
| 38 |
+
CMake is older than 3.12, the extra ``...`` dots will be seen as version
|
| 39 |
+
component separators, resulting in the ``...<max>`` part being ignored and
|
| 40 |
+
preserving the pre-3.12 behavior of basing policies on ``<min>``.
|
| 41 |
+
|
| 42 |
+
This specifies that the current CMake code is written for the given
|
| 43 |
+
range of CMake versions. All policies known to the running version of CMake
|
| 44 |
+
and introduced in the ``<min>`` (or ``<max>``, if specified) version
|
| 45 |
+
or earlier will be set to use ``NEW`` behavior. All policies
|
| 46 |
+
introduced in later versions will be unset (unless the
|
| 47 |
+
:variable:`CMAKE_POLICY_DEFAULT_CMP<NNNN>` variable sets a default).
|
| 48 |
+
This effectively requests behavior preferred as of a given CMake
|
| 49 |
+
version and tells newer CMake versions to warn about their new policies.
|
| 50 |
+
|
| 51 |
+
Note that the :command:`cmake_minimum_required(VERSION)`
|
| 52 |
+
command implicitly calls ``cmake_policy(VERSION)`` too.
|
| 53 |
+
|
| 54 |
+
.. include:: DEPRECATED_POLICY_VERSIONS.txt
|
| 55 |
+
|
| 56 |
+
Setting Policies Explicitly
|
| 57 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 58 |
+
|
| 59 |
+
.. signature:: cmake_policy(SET CMP<NNNN> NEW|OLD)
|
| 60 |
+
:target: SET
|
| 61 |
+
|
| 62 |
+
Tell CMake to use the ``OLD`` or ``NEW`` behavior for a given policy.
|
| 63 |
+
Projects depending on the old behavior of a given policy may silence a
|
| 64 |
+
policy warning by setting the policy state to ``OLD``. Alternatively
|
| 65 |
+
one may fix the project to work with the new behavior and set the
|
| 66 |
+
policy state to ``NEW``.
|
| 67 |
+
|
| 68 |
+
.. include:: ../policy/DEPRECATED.txt
|
| 69 |
+
|
| 70 |
+
Checking Policy Settings
|
| 71 |
+
^^^^^^^^^^^^^^^^^^^^^^^^
|
| 72 |
+
|
| 73 |
+
.. signature:: cmake_policy(GET CMP<NNNN> <variable>)
|
| 74 |
+
:target: GET
|
| 75 |
+
|
| 76 |
+
Check whether a given policy is set to ``OLD`` or ``NEW`` behavior.
|
| 77 |
+
The output ``<variable>`` value will be ``OLD`` or ``NEW`` if the
|
| 78 |
+
policy is set, and empty otherwise.
|
| 79 |
+
|
| 80 |
+
CMake Policy Stack
|
| 81 |
+
^^^^^^^^^^^^^^^^^^
|
| 82 |
+
|
| 83 |
+
CMake keeps policy settings on a stack, so changes made by the
|
| 84 |
+
``cmake_policy`` command affect only the top of the stack. A new entry on
|
| 85 |
+
the policy stack is managed automatically for each subdirectory to
|
| 86 |
+
protect its parents and siblings. CMake also manages a new entry for
|
| 87 |
+
scripts loaded by :command:`include` and :command:`find_package` commands
|
| 88 |
+
except when invoked with the ``NO_POLICY_SCOPE`` option
|
| 89 |
+
(see also policy :policy:`CMP0011`).
|
| 90 |
+
The ``cmake_policy`` command provides an interface to manage custom
|
| 91 |
+
entries on the policy stack:
|
| 92 |
+
|
| 93 |
+
.. signature:: cmake_policy(PUSH)
|
| 94 |
+
:target: PUSH
|
| 95 |
+
|
| 96 |
+
Create a new entry on the policy stack.
|
| 97 |
+
|
| 98 |
+
.. signature:: cmake_policy(POP)
|
| 99 |
+
:target: POP
|
| 100 |
+
|
| 101 |
+
Remove the last policy stack entry created with ``cmake_policy(PUSH)``.
|
| 102 |
+
|
| 103 |
+
Each ``PUSH`` must have a matching ``POP`` to erase any changes.
|
| 104 |
+
This is useful to make temporary changes to policy settings.
|
| 105 |
+
Calls to the :command:`cmake_minimum_required(VERSION)`,
|
| 106 |
+
:command:`cmake_policy(VERSION)`, or :command:`cmake_policy(SET)` commands
|
| 107 |
+
influence only the current top of the policy stack.
|
| 108 |
+
|
| 109 |
+
.. versionadded:: 3.25
|
| 110 |
+
The :command:`block(SCOPE_FOR POLICIES)` command offers a more flexible
|
| 111 |
+
and more secure way to manage the policy stack. The pop action is done
|
| 112 |
+
automatically when leaving the block scope, so there is no need to
|
| 113 |
+
precede each :command:`return` with a call to :command:`cmake_policy(POP)`.
|
| 114 |
+
|
| 115 |
+
.. code-block:: cmake
|
| 116 |
+
|
| 117 |
+
# stack management with cmake_policy()
|
| 118 |
+
function(my_func)
|
| 119 |
+
cmake_policy(PUSH)
|
| 120 |
+
cmake_policy(SET ...)
|
| 121 |
+
if (<cond1>)
|
| 122 |
+
...
|
| 123 |
+
cmake_policy(POP)
|
| 124 |
+
return()
|
| 125 |
+
elseif(<cond2>)
|
| 126 |
+
...
|
| 127 |
+
cmake_policy(POP)
|
| 128 |
+
return()
|
| 129 |
+
endif()
|
| 130 |
+
...
|
| 131 |
+
cmake_policy(POP)
|
| 132 |
+
endfunction()
|
| 133 |
+
|
| 134 |
+
# stack management with block()/endblock()
|
| 135 |
+
function(my_func)
|
| 136 |
+
block(SCOPE_FOR POLICIES)
|
| 137 |
+
cmake_policy(SET ...)
|
| 138 |
+
if (<cond1>)
|
| 139 |
+
...
|
| 140 |
+
return()
|
| 141 |
+
elseif(<cond2>)
|
| 142 |
+
...
|
| 143 |
+
return()
|
| 144 |
+
endif()
|
| 145 |
+
...
|
| 146 |
+
endblock()
|
| 147 |
+
endfunction()
|
| 148 |
+
|
| 149 |
+
Commands created by the :command:`function` and :command:`macro`
|
| 150 |
+
commands record policy settings when they are created and
|
| 151 |
+
use the pre-record policies when they are invoked. If the function or
|
| 152 |
+
macro implementation sets policies, the changes automatically
|
| 153 |
+
propagate up through callers until they reach the closest nested
|
| 154 |
+
policy stack entry.
|
| 155 |
+
|
| 156 |
+
See Also
|
| 157 |
+
^^^^^^^^
|
| 158 |
+
|
| 159 |
+
* :command:`cmake_minimum_required`
|
cmake/share/cmake-3.31/Help/command/configure_file.rst
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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. code-block:: cmake
|
| 11 |
+
|
| 12 |
+
configure_file(<input> <output>
|
| 13 |
+
[NO_SOURCE_PERMISSIONS | USE_SOURCE_PERMISSIONS |
|
| 14 |
+
FILE_PERMISSIONS <permissions>...]
|
| 15 |
+
[COPYONLY] [ESCAPE_QUOTES] [@ONLY]
|
| 16 |
+
[NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
|
| 17 |
+
|
| 18 |
+
Copies an ``<input>`` file to an ``<output>`` file while performing
|
| 19 |
+
`transformations`_ of the input file content.
|
| 20 |
+
|
| 21 |
+
If the input file is modified the build system will re-run CMake to
|
| 22 |
+
re-configure the file and generate the build system again.
|
| 23 |
+
The generated file is modified and its timestamp updated on subsequent
|
| 24 |
+
cmake runs only if its content is changed.
|
| 25 |
+
|
| 26 |
+
Options
|
| 27 |
+
^^^^^^^
|
| 28 |
+
|
| 29 |
+
The options are:
|
| 30 |
+
|
| 31 |
+
``<input>``
|
| 32 |
+
Path to the input file. A relative path is treated with respect to
|
| 33 |
+
the value of :variable:`CMAKE_CURRENT_SOURCE_DIR`. The input path
|
| 34 |
+
must be a file, not a directory.
|
| 35 |
+
|
| 36 |
+
``<output>``
|
| 37 |
+
Path to the output file or directory. A relative path is treated
|
| 38 |
+
with respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`.
|
| 39 |
+
If the path names an existing directory the output file is placed
|
| 40 |
+
in that directory with the same file name as the input file.
|
| 41 |
+
If the path contains non-existent directories, they are created.
|
| 42 |
+
|
| 43 |
+
``NO_SOURCE_PERMISSIONS``
|
| 44 |
+
.. versionadded:: 3.19
|
| 45 |
+
|
| 46 |
+
Do not transfer the permissions of the input file to the output file.
|
| 47 |
+
The copied file permissions default to the standard 644 value
|
| 48 |
+
(-rw-r--r--).
|
| 49 |
+
|
| 50 |
+
``USE_SOURCE_PERMISSIONS``
|
| 51 |
+
.. versionadded:: 3.20
|
| 52 |
+
|
| 53 |
+
Transfer the permissions of the input file to the output file.
|
| 54 |
+
This is already the default behavior if none of the three permissions-related
|
| 55 |
+
keywords are given (``NO_SOURCE_PERMISSIONS``, ``USE_SOURCE_PERMISSIONS``
|
| 56 |
+
or ``FILE_PERMISSIONS``). The ``USE_SOURCE_PERMISSIONS`` keyword mostly
|
| 57 |
+
serves as a way of making the intended behavior clearer at the call site.
|
| 58 |
+
|
| 59 |
+
``FILE_PERMISSIONS <permissions>...``
|
| 60 |
+
.. versionadded:: 3.20
|
| 61 |
+
|
| 62 |
+
Ignore the input file's permissions and use the specified ``<permissions>``
|
| 63 |
+
for the output file instead.
|
| 64 |
+
|
| 65 |
+
``COPYONLY``
|
| 66 |
+
Copy the file without replacing any variable references or other
|
| 67 |
+
content. This option may not be used with ``NEWLINE_STYLE``.
|
| 68 |
+
|
| 69 |
+
``ESCAPE_QUOTES``
|
| 70 |
+
Escape any substituted quotes with backslashes (C-style).
|
| 71 |
+
|
| 72 |
+
``@ONLY``
|
| 73 |
+
Restrict variable replacement to references of the form ``@VAR@``.
|
| 74 |
+
This is useful for configuring scripts that use ``${VAR}`` syntax.
|
| 75 |
+
|
| 76 |
+
``NEWLINE_STYLE <style>``
|
| 77 |
+
Specify the newline style for the output file. Specify
|
| 78 |
+
``UNIX`` or ``LF`` for ``\n`` newlines, or specify
|
| 79 |
+
``DOS``, ``WIN32``, or ``CRLF`` for ``\r\n`` newlines.
|
| 80 |
+
This option may not be used with ``COPYONLY``.
|
| 81 |
+
|
| 82 |
+
Transformations
|
| 83 |
+
^^^^^^^^^^^^^^^
|
| 84 |
+
|
| 85 |
+
:ref:`Variables <CMake Language Variables>` referenced in the input
|
| 86 |
+
file content as ``@VAR@``, ``${VAR}``, ``$CACHE{VAR}``, and
|
| 87 |
+
:ref:`environment variables <CMake Language Environment Variables>`
|
| 88 |
+
referenced as ``$ENV{VAR}``, will each be replaced with the current value
|
| 89 |
+
of the variable, or the empty string if the variable is not defined.
|
| 90 |
+
Furthermore, input lines of the form
|
| 91 |
+
|
| 92 |
+
.. code-block:: c
|
| 93 |
+
|
| 94 |
+
#cmakedefine VAR ...
|
| 95 |
+
|
| 96 |
+
will be replaced with either
|
| 97 |
+
|
| 98 |
+
.. code-block:: c
|
| 99 |
+
|
| 100 |
+
#define VAR ...
|
| 101 |
+
|
| 102 |
+
or
|
| 103 |
+
|
| 104 |
+
.. code-block:: c
|
| 105 |
+
|
| 106 |
+
/* #undef VAR */
|
| 107 |
+
|
| 108 |
+
depending on whether ``VAR`` is set in CMake to any value not considered
|
| 109 |
+
a false constant by the :command:`if` command. The "..." content on the
|
| 110 |
+
line after the variable name, if any, is processed as above.
|
| 111 |
+
|
| 112 |
+
Unlike lines of the form ``#cmakedefine VAR ...``, in lines of the form
|
| 113 |
+
``#cmakedefine01 VAR``, ``VAR`` itself will expand to ``VAR 0`` or ``VAR 1``
|
| 114 |
+
rather than being assigned the value ``...``. Therefore, input lines of the form
|
| 115 |
+
|
| 116 |
+
.. code-block:: c
|
| 117 |
+
|
| 118 |
+
#cmakedefine01 VAR
|
| 119 |
+
|
| 120 |
+
will be replaced with either
|
| 121 |
+
|
| 122 |
+
.. code-block:: c
|
| 123 |
+
|
| 124 |
+
#define VAR 0
|
| 125 |
+
|
| 126 |
+
or
|
| 127 |
+
|
| 128 |
+
.. code-block:: c
|
| 129 |
+
|
| 130 |
+
#define VAR 1
|
| 131 |
+
|
| 132 |
+
Input lines of the form ``#cmakedefine01 VAR ...`` will expand
|
| 133 |
+
as ``#cmakedefine01 VAR ... 0`` or ``#cmakedefine01 VAR ... 1``,
|
| 134 |
+
which may lead to undefined behavior.
|
| 135 |
+
|
| 136 |
+
.. versionadded:: 3.10
|
| 137 |
+
The result lines (with the exception of the ``#undef`` comments) can be
|
| 138 |
+
indented using spaces and/or tabs between the ``#`` character
|
| 139 |
+
and the ``cmakedefine`` or ``cmakedefine01`` words. This whitespace
|
| 140 |
+
indentation will be preserved in the output lines:
|
| 141 |
+
|
| 142 |
+
.. code-block:: c
|
| 143 |
+
|
| 144 |
+
# cmakedefine VAR
|
| 145 |
+
# cmakedefine01 VAR
|
| 146 |
+
|
| 147 |
+
will be replaced, if ``VAR`` is defined, with
|
| 148 |
+
|
| 149 |
+
.. code-block:: c
|
| 150 |
+
|
| 151 |
+
# define VAR
|
| 152 |
+
# define VAR 1
|
| 153 |
+
|
| 154 |
+
Example
|
| 155 |
+
^^^^^^^
|
| 156 |
+
|
| 157 |
+
Consider a source tree containing a ``foo.h.in`` file:
|
| 158 |
+
|
| 159 |
+
.. code-block:: c
|
| 160 |
+
|
| 161 |
+
#cmakedefine FOO_ENABLE
|
| 162 |
+
#cmakedefine FOO_STRING "@FOO_STRING@"
|
| 163 |
+
|
| 164 |
+
An adjacent ``CMakeLists.txt`` may use ``configure_file`` to
|
| 165 |
+
configure the header:
|
| 166 |
+
|
| 167 |
+
.. code-block:: cmake
|
| 168 |
+
|
| 169 |
+
option(FOO_ENABLE "Enable Foo" ON)
|
| 170 |
+
if(FOO_ENABLE)
|
| 171 |
+
set(FOO_STRING "foo")
|
| 172 |
+
endif()
|
| 173 |
+
configure_file(foo.h.in foo.h @ONLY)
|
| 174 |
+
|
| 175 |
+
This creates a ``foo.h`` in the build directory corresponding to
|
| 176 |
+
this source directory. If the ``FOO_ENABLE`` option is on, the
|
| 177 |
+
configured file will contain:
|
| 178 |
+
|
| 179 |
+
.. code-block:: c
|
| 180 |
+
|
| 181 |
+
#define FOO_ENABLE
|
| 182 |
+
#define FOO_STRING "foo"
|
| 183 |
+
|
| 184 |
+
Otherwise it will contain:
|
| 185 |
+
|
| 186 |
+
.. code-block:: c
|
| 187 |
+
|
| 188 |
+
/* #undef FOO_ENABLE */
|
| 189 |
+
/* #undef FOO_STRING */
|
| 190 |
+
|
| 191 |
+
One may then use the :command:`target_include_directories` command to
|
| 192 |
+
specify the output directory as an include directory:
|
| 193 |
+
|
| 194 |
+
.. code-block:: cmake
|
| 195 |
+
|
| 196 |
+
target_include_directories(<target> [SYSTEM] <INTERFACE|PUBLIC|PRIVATE> "${CMAKE_CURRENT_BINARY_DIR}")
|
| 197 |
+
|
| 198 |
+
so that sources may include the header as ``#include <foo.h>``.
|
| 199 |
+
|
| 200 |
+
See Also
|
| 201 |
+
^^^^^^^^
|
| 202 |
+
|
| 203 |
+
* :command:`file(GENERATE)`
|
cmake/share/cmake-3.31/Help/command/continue.rst
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
continue
|
| 2 |
+
--------
|
| 3 |
+
|
| 4 |
+
.. versionadded:: 3.2
|
| 5 |
+
|
| 6 |
+
Continue to the top of enclosing foreach or while loop.
|
| 7 |
+
|
| 8 |
+
.. code-block:: cmake
|
| 9 |
+
|
| 10 |
+
continue()
|
| 11 |
+
|
| 12 |
+
The ``continue()`` command allows a cmake script to abort the rest of the
|
| 13 |
+
current iteration of a :command:`foreach` or :command:`while` loop, and start
|
| 14 |
+
at the top of the next iteration.
|
| 15 |
+
|
| 16 |
+
See also the :command:`break` command.
|
cmake/share/cmake-3.31/Help/command/create_test_sourcelist.rst
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
create_test_sourcelist
|
| 2 |
+
----------------------
|
| 3 |
+
|
| 4 |
+
Create a test driver program that links together many small tests into a
|
| 5 |
+
single executable. This is useful when building static executables with
|
| 6 |
+
large libraries to shrink the total required size.
|
| 7 |
+
|
| 8 |
+
.. signature::
|
| 9 |
+
create_test_sourcelist(<sourceListName> <driverName> <test>... <options>...)
|
| 10 |
+
:target: original
|
| 11 |
+
|
| 12 |
+
Generate a test driver source file from a list of individual test sources
|
| 13 |
+
and provide a combined list of sources that can be built as an executable.
|
| 14 |
+
|
| 15 |
+
The options are:
|
| 16 |
+
|
| 17 |
+
``<sourceListName>``
|
| 18 |
+
The name of a variable in which to store the list of source files needed
|
| 19 |
+
to build the test driver. The list will contain the ``<test>...`` sources
|
| 20 |
+
and the generated ``<driverName>`` source.
|
| 21 |
+
|
| 22 |
+
.. versionchanged:: 3.29
|
| 23 |
+
|
| 24 |
+
The test driver source is listed by absolute path in the build tree.
|
| 25 |
+
Previously it was listed only as ``<driverName>``.
|
| 26 |
+
|
| 27 |
+
``<driverName>``
|
| 28 |
+
Name of the test driver source file to be generated into the build tree.
|
| 29 |
+
The source file will contain a ``main()`` program entry point that
|
| 30 |
+
dispatches to whatever test is named on the command line.
|
| 31 |
+
|
| 32 |
+
``<test>...``
|
| 33 |
+
Test source files to be added to the driver binary. Each test source
|
| 34 |
+
file must have a function in it that is the same name as the file with the
|
| 35 |
+
extension removed. For example, a ``foo.cxx`` test source might contain:
|
| 36 |
+
|
| 37 |
+
.. code-block:: c++
|
| 38 |
+
|
| 39 |
+
int foo(int argc, char** argv)
|
| 40 |
+
|
| 41 |
+
``EXTRA_INCLUDE <header>``
|
| 42 |
+
Specify a header file to ``#include`` in the generated test driver source.
|
| 43 |
+
|
| 44 |
+
``FUNCTION <function>``
|
| 45 |
+
Specify a function to be called with pointers to ``argc`` and ``argv``.
|
| 46 |
+
The function may be provided in the ``EXTRA_INCLUDE`` header:
|
| 47 |
+
|
| 48 |
+
.. code-block:: c++
|
| 49 |
+
|
| 50 |
+
void function(int* pargc, char*** pargv)
|
| 51 |
+
|
| 52 |
+
This can be used to add extra command line processing to each test.
|
| 53 |
+
|
| 54 |
+
Additionally, some CMake variables affect test driver generation:
|
| 55 |
+
|
| 56 |
+
.. variable:: CMAKE_TESTDRIVER_BEFORE_TESTMAIN
|
| 57 |
+
|
| 58 |
+
Code to be placed directly before calling each test's function.
|
| 59 |
+
|
| 60 |
+
.. variable:: CMAKE_TESTDRIVER_AFTER_TESTMAIN
|
| 61 |
+
|
| 62 |
+
Code to be placed directly after the call to each test's function.
|
cmake/share/cmake-3.31/Help/command/ctest_build.rst
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_build
|
| 2 |
+
-----------
|
| 3 |
+
|
| 4 |
+
Perform the :ref:`CTest Build Step` as a :ref:`Dashboard Client`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_build([BUILD <build-dir>] [APPEND]
|
| 9 |
+
[CONFIGURATION <config>]
|
| 10 |
+
[PARALLEL_LEVEL <parallel>]
|
| 11 |
+
[FLAGS <flags>]
|
| 12 |
+
[PROJECT_NAME <project-name>]
|
| 13 |
+
[TARGET <target-name>]
|
| 14 |
+
[NUMBER_ERRORS <num-err-var>]
|
| 15 |
+
[NUMBER_WARNINGS <num-warn-var>]
|
| 16 |
+
[RETURN_VALUE <result-var>]
|
| 17 |
+
[CAPTURE_CMAKE_ERROR <result-var>]
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
Build the project and store results in ``Build.xml``
|
| 21 |
+
for submission with the :command:`ctest_submit` command.
|
| 22 |
+
|
| 23 |
+
The :variable:`CTEST_BUILD_COMMAND` variable may be set to explicitly
|
| 24 |
+
specify the build command line. Otherwise the build command line is
|
| 25 |
+
computed automatically based on the options given.
|
| 26 |
+
|
| 27 |
+
The options are:
|
| 28 |
+
|
| 29 |
+
``BUILD <build-dir>``
|
| 30 |
+
Specify the top-level build directory. If not given, the
|
| 31 |
+
:variable:`CTEST_BINARY_DIRECTORY` variable is used.
|
| 32 |
+
|
| 33 |
+
``APPEND``
|
| 34 |
+
Mark ``Build.xml`` for append to results previously submitted to a
|
| 35 |
+
dashboard server since the last :command:`ctest_start` call.
|
| 36 |
+
Append semantics are defined by the dashboard server in use.
|
| 37 |
+
This does *not* cause results to be appended to a ``.xml`` file
|
| 38 |
+
produced by a previous call to this command.
|
| 39 |
+
|
| 40 |
+
``CONFIGURATION <config>``
|
| 41 |
+
Specify the build configuration (e.g. ``Debug``). If not
|
| 42 |
+
specified the ``CTEST_BUILD_CONFIGURATION`` variable will be checked.
|
| 43 |
+
Otherwise the :option:`-C \<cfg\> <ctest -C>` option given to the
|
| 44 |
+
:manual:`ctest(1)` command will be used, if any.
|
| 45 |
+
|
| 46 |
+
``PARALLEL_LEVEL <parallel>``
|
| 47 |
+
.. versionadded:: 3.21
|
| 48 |
+
|
| 49 |
+
Specify the parallel level of the underlying build system. If not
|
| 50 |
+
specified, the :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment
|
| 51 |
+
variable will be checked.
|
| 52 |
+
|
| 53 |
+
``FLAGS <flags>``
|
| 54 |
+
Pass additional arguments to the underlying build command.
|
| 55 |
+
If not specified the ``CTEST_BUILD_FLAGS`` variable will be checked.
|
| 56 |
+
This can, e.g., be used to trigger a parallel build using the
|
| 57 |
+
``-j`` option of ``make``. See the :module:`ProcessorCount` module
|
| 58 |
+
for an example.
|
| 59 |
+
|
| 60 |
+
``PROJECT_NAME <project-name>``
|
| 61 |
+
Ignored since CMake 3.0.
|
| 62 |
+
|
| 63 |
+
.. versionchanged:: 3.14
|
| 64 |
+
This value is no longer required.
|
| 65 |
+
|
| 66 |
+
``TARGET <target-name>``
|
| 67 |
+
Specify the name of a target to build. If not specified the
|
| 68 |
+
``CTEST_BUILD_TARGET`` variable will be checked. Otherwise the
|
| 69 |
+
default target will be built. This is the "all" target
|
| 70 |
+
(called ``ALL_BUILD`` in :ref:`Visual Studio Generators`).
|
| 71 |
+
|
| 72 |
+
``NUMBER_ERRORS <num-err-var>``
|
| 73 |
+
Store the number of build errors detected in the given variable.
|
| 74 |
+
|
| 75 |
+
``NUMBER_WARNINGS <num-warn-var>``
|
| 76 |
+
Store the number of build warnings detected in the given variable.
|
| 77 |
+
|
| 78 |
+
``RETURN_VALUE <result-var>``
|
| 79 |
+
Store the return value of the native build tool in the given variable.
|
| 80 |
+
|
| 81 |
+
``CAPTURE_CMAKE_ERROR <result-var>``
|
| 82 |
+
.. versionadded:: 3.7
|
| 83 |
+
|
| 84 |
+
Store in the ``<result-var>`` variable -1 if there are any errors running
|
| 85 |
+
the command and prevent ctest from returning non-zero if an error occurs.
|
| 86 |
+
|
| 87 |
+
``QUIET``
|
| 88 |
+
.. versionadded:: 3.3
|
| 89 |
+
|
| 90 |
+
Suppress any CTest-specific non-error output that would have been
|
| 91 |
+
printed to the console otherwise. The summary of warnings / errors,
|
| 92 |
+
as well as the output from the native build tool is unaffected by
|
| 93 |
+
this option.
|
cmake/share/cmake-3.31/Help/command/ctest_configure.rst
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_configure
|
| 2 |
+
---------------
|
| 3 |
+
|
| 4 |
+
Perform the :ref:`CTest Configure Step` as a :ref:`Dashboard Client`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_configure([BUILD <build-dir>] [SOURCE <source-dir>] [APPEND]
|
| 9 |
+
[OPTIONS <options>] [RETURN_VALUE <result-var>] [QUIET]
|
| 10 |
+
[CAPTURE_CMAKE_ERROR <result-var>])
|
| 11 |
+
|
| 12 |
+
Configure the project build tree and record results in ``Configure.xml``
|
| 13 |
+
for submission with the :command:`ctest_submit` command.
|
| 14 |
+
|
| 15 |
+
The options are:
|
| 16 |
+
|
| 17 |
+
``BUILD <build-dir>``
|
| 18 |
+
Specify the top-level build directory. If not given, the
|
| 19 |
+
:variable:`CTEST_BINARY_DIRECTORY` variable is used.
|
| 20 |
+
|
| 21 |
+
``SOURCE <source-dir>``
|
| 22 |
+
Specify the source directory. If not given, the
|
| 23 |
+
:variable:`CTEST_SOURCE_DIRECTORY` variable is used.
|
| 24 |
+
|
| 25 |
+
``APPEND``
|
| 26 |
+
Mark ``Configure.xml`` for append to results previously submitted to a
|
| 27 |
+
dashboard server since the last :command:`ctest_start` call.
|
| 28 |
+
Append semantics are defined by the dashboard server in use.
|
| 29 |
+
This does *not* cause results to be appended to a ``.xml`` file
|
| 30 |
+
produced by a previous call to this command.
|
| 31 |
+
|
| 32 |
+
``OPTIONS <options>``
|
| 33 |
+
Specify command-line arguments to pass to the configuration tool.
|
| 34 |
+
|
| 35 |
+
``RETURN_VALUE <result-var>``
|
| 36 |
+
Store in the ``<result-var>`` variable the return value of the native
|
| 37 |
+
configuration tool.
|
| 38 |
+
|
| 39 |
+
``CAPTURE_CMAKE_ERROR <result-var>``
|
| 40 |
+
.. versionadded:: 3.7
|
| 41 |
+
|
| 42 |
+
Store in the ``<result-var>`` variable -1 if there are any errors running
|
| 43 |
+
the command and prevent ctest from returning non-zero if an error occurs.
|
| 44 |
+
|
| 45 |
+
``QUIET``
|
| 46 |
+
.. versionadded:: 3.3
|
| 47 |
+
|
| 48 |
+
Suppress any CTest-specific non-error messages that would have
|
| 49 |
+
otherwise been printed to the console. Output from the underlying
|
| 50 |
+
configure command is not affected.
|
cmake/share/cmake-3.31/Help/command/ctest_coverage.rst
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_coverage
|
| 2 |
+
--------------
|
| 3 |
+
|
| 4 |
+
Perform the :ref:`CTest Coverage Step` as a :ref:`Dashboard Client`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_coverage([BUILD <build-dir>] [APPEND]
|
| 9 |
+
[LABELS <label>...]
|
| 10 |
+
[RETURN_VALUE <result-var>]
|
| 11 |
+
[CAPTURE_CMAKE_ERROR <result-var>]
|
| 12 |
+
[QUIET]
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
Collect coverage tool results and stores them in ``Coverage.xml``
|
| 16 |
+
for submission with the :command:`ctest_submit` command.
|
| 17 |
+
|
| 18 |
+
The options are:
|
| 19 |
+
|
| 20 |
+
``BUILD <build-dir>``
|
| 21 |
+
Specify the top-level build directory. If not given, the
|
| 22 |
+
:variable:`CTEST_BINARY_DIRECTORY` variable is used.
|
| 23 |
+
|
| 24 |
+
``APPEND``
|
| 25 |
+
Mark ``Coverage.xml`` for append to results previously submitted to a
|
| 26 |
+
dashboard server since the last :command:`ctest_start` call.
|
| 27 |
+
Append semantics are defined by the dashboard server in use.
|
| 28 |
+
This does *not* cause results to be appended to a ``.xml`` file
|
| 29 |
+
produced by a previous call to this command.
|
| 30 |
+
|
| 31 |
+
``LABELS``
|
| 32 |
+
Filter the coverage report to include only source files labeled
|
| 33 |
+
with at least one of the labels specified.
|
| 34 |
+
|
| 35 |
+
``RETURN_VALUE <result-var>``
|
| 36 |
+
Store in the ``<result-var>`` variable ``0`` if coverage tools
|
| 37 |
+
ran without error and non-zero otherwise.
|
| 38 |
+
|
| 39 |
+
``CAPTURE_CMAKE_ERROR <result-var>``
|
| 40 |
+
.. versionadded:: 3.7
|
| 41 |
+
|
| 42 |
+
Store in the ``<result-var>`` variable -1 if there are any errors running
|
| 43 |
+
the command and prevent ctest from returning non-zero if an error occurs.
|
| 44 |
+
|
| 45 |
+
``QUIET``
|
| 46 |
+
.. versionadded:: 3.3
|
| 47 |
+
|
| 48 |
+
Suppress any CTest-specific non-error output that would have been
|
| 49 |
+
printed to the console otherwise. The summary indicating how many
|
| 50 |
+
lines of code were covered is unaffected by this option.
|
cmake/share/cmake-3.31/Help/command/ctest_empty_binary_directory.rst
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_empty_binary_directory
|
| 2 |
+
----------------------------
|
| 3 |
+
|
| 4 |
+
empties the binary directory
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_empty_binary_directory(<directory>)
|
| 9 |
+
|
| 10 |
+
Removes a binary directory. This command will perform some checks
|
| 11 |
+
prior to deleting the directory in an attempt to avoid malicious or
|
| 12 |
+
accidental directory deletion.
|
cmake/share/cmake-3.31/Help/command/ctest_memcheck.rst
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_memcheck
|
| 2 |
+
--------------
|
| 3 |
+
|
| 4 |
+
Perform the :ref:`CTest MemCheck Step` as a :ref:`Dashboard Client`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_memcheck([BUILD <build-dir>] [APPEND]
|
| 9 |
+
[START <start-number>]
|
| 10 |
+
[END <end-number>]
|
| 11 |
+
[STRIDE <stride-number>]
|
| 12 |
+
[EXCLUDE <exclude-regex>]
|
| 13 |
+
[INCLUDE <include-regex>]
|
| 14 |
+
[EXCLUDE_LABEL <label-exclude-regex>]
|
| 15 |
+
[INCLUDE_LABEL <label-include-regex>]
|
| 16 |
+
[EXCLUDE_FIXTURE <regex>]
|
| 17 |
+
[EXCLUDE_FIXTURE_SETUP <regex>]
|
| 18 |
+
[EXCLUDE_FIXTURE_CLEANUP <regex>]
|
| 19 |
+
[PARALLEL_LEVEL <level>]
|
| 20 |
+
[RESOURCE_SPEC_FILE <file>]
|
| 21 |
+
[TEST_LOAD <threshold>]
|
| 22 |
+
[SCHEDULE_RANDOM <ON|OFF>]
|
| 23 |
+
[STOP_ON_FAILURE]
|
| 24 |
+
[STOP_TIME <time-of-day>]
|
| 25 |
+
[RETURN_VALUE <result-var>]
|
| 26 |
+
[CAPTURE_CMAKE_ERROR <result-var>]
|
| 27 |
+
[REPEAT <mode>:<n>]
|
| 28 |
+
[OUTPUT_JUNIT <file>]
|
| 29 |
+
[DEFECT_COUNT <defect-count-var>]
|
| 30 |
+
[QUIET]
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
Run tests with a dynamic analysis tool and store results in
|
| 35 |
+
``MemCheck.xml`` for submission with the :command:`ctest_submit`
|
| 36 |
+
command.
|
| 37 |
+
|
| 38 |
+
Most options are the same as those for the :command:`ctest_test` command.
|
| 39 |
+
|
| 40 |
+
The options unique to this command are:
|
| 41 |
+
|
| 42 |
+
``DEFECT_COUNT <defect-count-var>``
|
| 43 |
+
.. versionadded:: 3.8
|
| 44 |
+
|
| 45 |
+
Store in the ``<defect-count-var>`` the number of defects found.
|
cmake/share/cmake-3.31/Help/command/ctest_read_custom_files.rst
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_read_custom_files
|
| 2 |
+
-----------------------
|
| 3 |
+
|
| 4 |
+
read CTestCustom files.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_read_custom_files(<directory>...)
|
| 9 |
+
|
| 10 |
+
Read all the CTestCustom.ctest or CTestCustom.cmake files from the
|
| 11 |
+
given directory.
|
| 12 |
+
|
| 13 |
+
By default, invoking :manual:`ctest(1)` without a script will read custom
|
| 14 |
+
files from the binary directory.
|
cmake/share/cmake-3.31/Help/command/ctest_run_script.rst
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_run_script
|
| 2 |
+
----------------
|
| 3 |
+
|
| 4 |
+
runs a :option:`ctest -S` script
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_run_script([NEW_PROCESS] script_file_name script_file_name1
|
| 9 |
+
script_file_name2 ... [RETURN_VALUE var])
|
| 10 |
+
|
| 11 |
+
Runs a script or scripts much like if it was run from :option:`ctest -S`.
|
| 12 |
+
If no argument is provided then the current script is run using the current
|
| 13 |
+
settings of the variables. If ``NEW_PROCESS`` is specified then each
|
| 14 |
+
script will be run in a separate process.If ``RETURN_VALUE`` is specified
|
| 15 |
+
the return value of the last script run will be put into ``var``.
|
cmake/share/cmake-3.31/Help/command/ctest_sleep.rst
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_sleep
|
| 2 |
+
-----------
|
| 3 |
+
|
| 4 |
+
sleeps for some amount of time
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_sleep(<seconds>)
|
| 9 |
+
|
| 10 |
+
Sleep for given number of seconds.
|
| 11 |
+
|
| 12 |
+
.. code-block:: cmake
|
| 13 |
+
|
| 14 |
+
ctest_sleep(<time1> <duration> <time2>)
|
| 15 |
+
|
| 16 |
+
Sleep for t=(time1 + duration - time2) seconds if t > 0.
|
cmake/share/cmake-3.31/Help/command/ctest_start.rst
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_start
|
| 2 |
+
-----------
|
| 3 |
+
|
| 4 |
+
Starts the testing for a given model
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_start(<model> [<source> [<binary>]] [GROUP <group>] [QUIET])
|
| 9 |
+
|
| 10 |
+
ctest_start([<model> [<source> [<binary>]]] [GROUP <group>] APPEND [QUIET])
|
| 11 |
+
|
| 12 |
+
Starts the testing for a given model. The command should be called
|
| 13 |
+
after the binary directory is initialized.
|
| 14 |
+
|
| 15 |
+
The parameters are as follows:
|
| 16 |
+
|
| 17 |
+
``<model>``
|
| 18 |
+
Set the dashboard model. Must be one of ``Experimental``, ``Continuous``, or
|
| 19 |
+
``Nightly``. This parameter is required unless ``APPEND`` is specified.
|
| 20 |
+
|
| 21 |
+
``<source>``
|
| 22 |
+
Set the source directory. If not specified, the value of
|
| 23 |
+
:variable:`CTEST_SOURCE_DIRECTORY` is used instead.
|
| 24 |
+
|
| 25 |
+
``<binary>``
|
| 26 |
+
Set the binary directory. If not specified, the value of
|
| 27 |
+
:variable:`CTEST_BINARY_DIRECTORY` is used instead.
|
| 28 |
+
|
| 29 |
+
``GROUP <group>``
|
| 30 |
+
If ``GROUP`` is used, the submissions will go to the specified group on the
|
| 31 |
+
CDash server. If no ``GROUP`` is specified, the name of the model is used by
|
| 32 |
+
default.
|
| 33 |
+
|
| 34 |
+
.. versionchanged:: 3.16
|
| 35 |
+
This replaces the deprecated option ``TRACK``. Despite the name
|
| 36 |
+
change its behavior is unchanged.
|
| 37 |
+
|
| 38 |
+
``APPEND``
|
| 39 |
+
If ``APPEND`` is used, the existing ``TAG`` is used rather than creating a new
|
| 40 |
+
one based on the current time stamp. If you use ``APPEND``, you can omit the
|
| 41 |
+
``<model>`` and ``GROUP <group>`` parameters, because they will be read from
|
| 42 |
+
the generated ``TAG`` file. For example:
|
| 43 |
+
|
| 44 |
+
.. code-block:: cmake
|
| 45 |
+
|
| 46 |
+
ctest_start(Experimental GROUP GroupExperimental)
|
| 47 |
+
|
| 48 |
+
Later, in another :option:`ctest -S` script:
|
| 49 |
+
|
| 50 |
+
.. code-block:: cmake
|
| 51 |
+
|
| 52 |
+
ctest_start(APPEND)
|
| 53 |
+
|
| 54 |
+
When the second script runs ``ctest_start(APPEND)``, it will read the
|
| 55 |
+
``Experimental`` model and ``GroupExperimental`` group from the ``TAG`` file
|
| 56 |
+
generated by the first ``ctest_start()`` command. Please note that if you
|
| 57 |
+
call ``ctest_start(APPEND)`` and specify a different model or group than
|
| 58 |
+
in the first ``ctest_start()`` command, a warning will be issued, and the
|
| 59 |
+
new model and group will be used.
|
| 60 |
+
|
| 61 |
+
``QUIET``
|
| 62 |
+
.. versionadded:: 3.3
|
| 63 |
+
|
| 64 |
+
If ``QUIET`` is used, CTest will suppress any non-error messages that it
|
| 65 |
+
otherwise would have printed to the console.
|
| 66 |
+
|
| 67 |
+
The parameters for ``ctest_start()`` can be issued in any order, with the
|
| 68 |
+
exception that ``<model>``, ``<source>``, and ``<binary>`` have to appear
|
| 69 |
+
in that order with respect to each other. The following are all valid and
|
| 70 |
+
equivalent:
|
| 71 |
+
|
| 72 |
+
.. code-block:: cmake
|
| 73 |
+
|
| 74 |
+
ctest_start(Experimental path/to/source path/to/binary GROUP SomeGroup QUIET APPEND)
|
| 75 |
+
|
| 76 |
+
ctest_start(GROUP SomeGroup Experimental QUIET path/to/source APPEND path/to/binary)
|
| 77 |
+
|
| 78 |
+
ctest_start(APPEND QUIET Experimental path/to/source GROUP SomeGroup path/to/binary)
|
| 79 |
+
|
| 80 |
+
However, for the sake of readability, it is recommended that you order your
|
| 81 |
+
parameters in the order listed at the top of this page.
|
| 82 |
+
|
| 83 |
+
If the :variable:`CTEST_CHECKOUT_COMMAND` variable (or the
|
| 84 |
+
:variable:`CTEST_CVS_CHECKOUT` variable) is set, its content is treated as
|
| 85 |
+
command-line. The command is invoked with the current working directory set
|
| 86 |
+
to the parent of the source directory, even if the source directory already
|
| 87 |
+
exists. This can be used to create the source tree from a version control
|
| 88 |
+
repository.
|
cmake/share/cmake-3.31/Help/command/ctest_submit.rst
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_submit
|
| 2 |
+
------------
|
| 3 |
+
|
| 4 |
+
Perform the :ref:`CTest Submit Step` as a :ref:`Dashboard Client`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_submit([PARTS <part>...] [FILES <file>...]
|
| 9 |
+
[SUBMIT_URL <url>]
|
| 10 |
+
[BUILD_ID <result-var>]
|
| 11 |
+
[HTTPHEADER <header>]
|
| 12 |
+
[RETRY_COUNT <count>]
|
| 13 |
+
[RETRY_DELAY <delay>]
|
| 14 |
+
[RETURN_VALUE <result-var>]
|
| 15 |
+
[CAPTURE_CMAKE_ERROR <result-var>]
|
| 16 |
+
[QUIET]
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
Submit results to a dashboard server.
|
| 20 |
+
By default all available parts are submitted.
|
| 21 |
+
|
| 22 |
+
The options are:
|
| 23 |
+
|
| 24 |
+
``PARTS <part>...``
|
| 25 |
+
Specify a subset of parts to submit. Valid part names are::
|
| 26 |
+
|
| 27 |
+
Start = nothing
|
| 28 |
+
Update = ctest_update results, in Update.xml
|
| 29 |
+
Configure = ctest_configure results, in Configure.xml
|
| 30 |
+
Build = ctest_build results, in Build.xml
|
| 31 |
+
Test = ctest_test results, in Test.xml
|
| 32 |
+
Coverage = ctest_coverage results, in Coverage.xml
|
| 33 |
+
MemCheck = ctest_memcheck results, in DynamicAnalysis.xml and
|
| 34 |
+
DynamicAnalysis-Test.xml
|
| 35 |
+
Notes = Files listed by CTEST_NOTES_FILES, in Notes.xml
|
| 36 |
+
ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES
|
| 37 |
+
Upload = Files prepared for upload by ctest_upload(), in Upload.xml
|
| 38 |
+
Submit = nothing
|
| 39 |
+
Done = Build is complete, in Done.xml
|
| 40 |
+
|
| 41 |
+
``FILES <file>...``
|
| 42 |
+
Specify an explicit list of specific files to be submitted.
|
| 43 |
+
Each individual file must exist at the time of the call.
|
| 44 |
+
|
| 45 |
+
``SUBMIT_URL <url>``
|
| 46 |
+
.. versionadded:: 3.14
|
| 47 |
+
|
| 48 |
+
The ``http`` or ``https`` URL of the dashboard server to send the submission
|
| 49 |
+
to. If not given, the :variable:`CTEST_SUBMIT_URL` variable is used.
|
| 50 |
+
|
| 51 |
+
``BUILD_ID <result-var>``
|
| 52 |
+
.. versionadded:: 3.15
|
| 53 |
+
|
| 54 |
+
Store in the ``<result-var>`` variable the ID assigned to this build by
|
| 55 |
+
CDash.
|
| 56 |
+
|
| 57 |
+
``HTTPHEADER <HTTP-header>``
|
| 58 |
+
.. versionadded:: 3.9
|
| 59 |
+
|
| 60 |
+
Specify HTTP header to be included in the request to CDash during submission.
|
| 61 |
+
For example, CDash can be configured to only accept submissions from
|
| 62 |
+
authenticated clients. In this case, you should provide a bearer token in your
|
| 63 |
+
header:
|
| 64 |
+
|
| 65 |
+
.. code-block:: cmake
|
| 66 |
+
|
| 67 |
+
ctest_submit(HTTPHEADER "Authorization: Bearer <auth-token>")
|
| 68 |
+
|
| 69 |
+
This suboption can be repeated several times for multiple headers.
|
| 70 |
+
|
| 71 |
+
``RETRY_COUNT <count>``
|
| 72 |
+
Specify how many times to retry a timed-out submission.
|
| 73 |
+
|
| 74 |
+
``RETRY_DELAY <delay>``
|
| 75 |
+
Specify how long (in seconds) to wait after a timed-out submission
|
| 76 |
+
before attempting to re-submit.
|
| 77 |
+
|
| 78 |
+
``RETURN_VALUE <result-var>``
|
| 79 |
+
Store in the ``<result-var>`` variable ``0`` for success and
|
| 80 |
+
non-zero on failure.
|
| 81 |
+
|
| 82 |
+
``CAPTURE_CMAKE_ERROR <result-var>``
|
| 83 |
+
.. versionadded:: 3.13
|
| 84 |
+
|
| 85 |
+
Store in the ``<result-var>`` variable -1 if there are any errors running
|
| 86 |
+
the command and prevent ctest from returning non-zero if an error occurs.
|
| 87 |
+
|
| 88 |
+
``QUIET``
|
| 89 |
+
.. versionadded:: 3.3
|
| 90 |
+
|
| 91 |
+
Suppress all non-error messages that would have otherwise been
|
| 92 |
+
printed to the console.
|
| 93 |
+
|
| 94 |
+
Submit to CDash Upload API
|
| 95 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 96 |
+
|
| 97 |
+
.. versionadded:: 3.2
|
| 98 |
+
|
| 99 |
+
.. code-block:: cmake
|
| 100 |
+
|
| 101 |
+
ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>]
|
| 102 |
+
[SUBMIT_URL <url>]
|
| 103 |
+
[BUILD_ID <result-var>]
|
| 104 |
+
[HTTPHEADER <header>]
|
| 105 |
+
[RETRY_COUNT <count>]
|
| 106 |
+
[RETRY_DELAY <delay>]
|
| 107 |
+
[RETURN_VALUE <result-var>]
|
| 108 |
+
[QUIET])
|
| 109 |
+
|
| 110 |
+
This second signature is used to upload files to CDash via the CDash
|
| 111 |
+
file upload API. The API first sends a request to upload to CDash along
|
| 112 |
+
with a content hash of the file. If CDash does not already have the file,
|
| 113 |
+
then it is uploaded. Along with the file, a CDash type string is specified
|
| 114 |
+
to tell CDash which handler to use to process the data.
|
| 115 |
+
|
| 116 |
+
This signature interprets options in the same way as the first one.
|
| 117 |
+
|
| 118 |
+
.. versionadded:: 3.8
|
| 119 |
+
Added the ``RETRY_COUNT``, ``RETRY_DELAY``, ``QUIET`` options.
|
| 120 |
+
|
| 121 |
+
.. versionadded:: 3.9
|
| 122 |
+
Added the ``HTTPHEADER`` option.
|
| 123 |
+
|
| 124 |
+
.. versionadded:: 3.13
|
| 125 |
+
Added the ``RETURN_VALUE`` option.
|
| 126 |
+
|
| 127 |
+
.. versionadded:: 3.14
|
| 128 |
+
Added the ``SUBMIT_URL`` option.
|
| 129 |
+
|
| 130 |
+
.. versionadded:: 3.15
|
| 131 |
+
Added the ``BUILD_ID`` option.
|
cmake/share/cmake-3.31/Help/command/ctest_test.rst
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_test
|
| 2 |
+
----------
|
| 3 |
+
|
| 4 |
+
Perform the :ref:`CTest Test Step` as a :ref:`Dashboard Client`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_test([BUILD <build-dir>] [APPEND]
|
| 9 |
+
[START <start-number>]
|
| 10 |
+
[END <end-number>]
|
| 11 |
+
[STRIDE <stride-number>]
|
| 12 |
+
[EXCLUDE <exclude-regex>]
|
| 13 |
+
[INCLUDE <include-regex>]
|
| 14 |
+
[EXCLUDE_LABEL <label-exclude-regex>]
|
| 15 |
+
[INCLUDE_LABEL <label-include-regex>]
|
| 16 |
+
[EXCLUDE_FROM_FILE <filename>]
|
| 17 |
+
[INCLUDE_FROM_FILE <filename>]
|
| 18 |
+
[EXCLUDE_FIXTURE <regex>]
|
| 19 |
+
[EXCLUDE_FIXTURE_SETUP <regex>]
|
| 20 |
+
[EXCLUDE_FIXTURE_CLEANUP <regex>]
|
| 21 |
+
[PARALLEL_LEVEL [<level>]]
|
| 22 |
+
[RESOURCE_SPEC_FILE <file>]
|
| 23 |
+
[TEST_LOAD <threshold>]
|
| 24 |
+
[SCHEDULE_RANDOM <ON|OFF>]
|
| 25 |
+
[STOP_ON_FAILURE]
|
| 26 |
+
[STOP_TIME <time-of-day>]
|
| 27 |
+
[RETURN_VALUE <result-var>]
|
| 28 |
+
[CAPTURE_CMAKE_ERROR <result-var>]
|
| 29 |
+
[REPEAT <mode>:<n>]
|
| 30 |
+
[OUTPUT_JUNIT <file>]
|
| 31 |
+
[QUIET]
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
..
|
| 35 |
+
NOTE If updating the argument list here, please also update the argument
|
| 36 |
+
list documentation for :command:`ctest_memcheck` as well.
|
| 37 |
+
|
| 38 |
+
Run tests in the project build tree and store results in
|
| 39 |
+
``Test.xml`` for submission with the :command:`ctest_submit` command.
|
| 40 |
+
|
| 41 |
+
The options are:
|
| 42 |
+
|
| 43 |
+
``BUILD <build-dir>``
|
| 44 |
+
Specify the top-level build directory. If not given, the
|
| 45 |
+
:variable:`CTEST_BINARY_DIRECTORY` variable is used.
|
| 46 |
+
|
| 47 |
+
``APPEND``
|
| 48 |
+
Mark ``Test.xml`` for append to results previously submitted to a
|
| 49 |
+
dashboard server since the last :command:`ctest_start` call.
|
| 50 |
+
Append semantics are defined by the dashboard server in use.
|
| 51 |
+
This does *not* cause results to be appended to a ``.xml`` file
|
| 52 |
+
produced by a previous call to this command.
|
| 53 |
+
|
| 54 |
+
``START <start-number>``
|
| 55 |
+
Specify the beginning of a range of test numbers.
|
| 56 |
+
|
| 57 |
+
``END <end-number>``
|
| 58 |
+
Specify the end of a range of test numbers.
|
| 59 |
+
|
| 60 |
+
``STRIDE <stride-number>``
|
| 61 |
+
Specify the stride by which to step across a range of test numbers.
|
| 62 |
+
|
| 63 |
+
``EXCLUDE <exclude-regex>``
|
| 64 |
+
Specify a regular expression matching test names to exclude.
|
| 65 |
+
|
| 66 |
+
``INCLUDE <include-regex>``
|
| 67 |
+
Specify a regular expression matching test names to include.
|
| 68 |
+
Tests not matching this expression are excluded.
|
| 69 |
+
|
| 70 |
+
``EXCLUDE_LABEL <label-exclude-regex>``
|
| 71 |
+
Specify a regular expression matching test labels to exclude.
|
| 72 |
+
|
| 73 |
+
``INCLUDE_LABEL <label-include-regex>``
|
| 74 |
+
Specify a regular expression matching test labels to include.
|
| 75 |
+
Tests not matching this expression are excluded.
|
| 76 |
+
|
| 77 |
+
``EXCLUDE_FROM_FILE <filename>``
|
| 78 |
+
.. versionadded:: 3.29
|
| 79 |
+
|
| 80 |
+
Do NOT run tests listed with their exact name in the given file.
|
| 81 |
+
|
| 82 |
+
``INCLUDE_FROM_FILE <filename>``
|
| 83 |
+
.. versionadded:: 3.29
|
| 84 |
+
|
| 85 |
+
Only run the tests listed with their exact name in the given file.
|
| 86 |
+
|
| 87 |
+
``EXCLUDE_FIXTURE <regex>``
|
| 88 |
+
.. versionadded:: 3.7
|
| 89 |
+
|
| 90 |
+
If a test in the set of tests to be executed requires a particular fixture,
|
| 91 |
+
that fixture's setup and cleanup tests would normally be added to the test
|
| 92 |
+
set automatically. This option prevents adding setup or cleanup tests for
|
| 93 |
+
fixtures matching the ``<regex>``. Note that all other fixture behavior is
|
| 94 |
+
retained, including test dependencies and skipping tests that have fixture
|
| 95 |
+
setup tests that fail.
|
| 96 |
+
|
| 97 |
+
``EXCLUDE_FIXTURE_SETUP <regex>``
|
| 98 |
+
.. versionadded:: 3.7
|
| 99 |
+
|
| 100 |
+
Same as ``EXCLUDE_FIXTURE`` except only matching setup tests are excluded.
|
| 101 |
+
|
| 102 |
+
``EXCLUDE_FIXTURE_CLEANUP <regex>``
|
| 103 |
+
.. versionadded:: 3.7
|
| 104 |
+
|
| 105 |
+
Same as ``EXCLUDE_FIXTURE`` except only matching cleanup tests are excluded.
|
| 106 |
+
|
| 107 |
+
``PARALLEL_LEVEL [<level>]``
|
| 108 |
+
Run tests in parallel, limited to a given level of parallelism.
|
| 109 |
+
|
| 110 |
+
.. versionadded:: 3.29
|
| 111 |
+
|
| 112 |
+
The ``<level>`` may be omitted, or ``0``, to let ctest use a default
|
| 113 |
+
level of parallelism, or unbounded parallelism, respectively, as
|
| 114 |
+
documented by the :option:`ctest --parallel` option.
|
| 115 |
+
|
| 116 |
+
``RESOURCE_SPEC_FILE <file>``
|
| 117 |
+
.. versionadded:: 3.16
|
| 118 |
+
|
| 119 |
+
Specify a
|
| 120 |
+
:ref:`resource specification file <ctest-resource-specification-file>`. See
|
| 121 |
+
:ref:`ctest-resource-allocation` for more information.
|
| 122 |
+
|
| 123 |
+
``TEST_LOAD <threshold>``
|
| 124 |
+
.. versionadded:: 3.4
|
| 125 |
+
|
| 126 |
+
While running tests in parallel, try not to start tests when they
|
| 127 |
+
may cause the CPU load to pass above a given threshold. If not
|
| 128 |
+
specified the :variable:`CTEST_TEST_LOAD` variable will be checked,
|
| 129 |
+
and then the :option:`--test-load <ctest --test-load>` command-line
|
| 130 |
+
argument to :manual:`ctest(1)`. See also the ``TestLoad`` setting
|
| 131 |
+
in the :ref:`CTest Test Step`.
|
| 132 |
+
|
| 133 |
+
``REPEAT <mode>:<n>``
|
| 134 |
+
.. versionadded:: 3.17
|
| 135 |
+
|
| 136 |
+
Run tests repeatedly based on the given ``<mode>`` up to ``<n>`` times.
|
| 137 |
+
The modes are:
|
| 138 |
+
|
| 139 |
+
``UNTIL_FAIL``
|
| 140 |
+
Require each test to run ``<n>`` times without failing in order to pass.
|
| 141 |
+
This is useful in finding sporadic failures in test cases.
|
| 142 |
+
|
| 143 |
+
``UNTIL_PASS``
|
| 144 |
+
Allow each test to run up to ``<n>`` times in order to pass.
|
| 145 |
+
Repeats tests if they fail for any reason.
|
| 146 |
+
This is useful in tolerating sporadic failures in test cases.
|
| 147 |
+
|
| 148 |
+
``AFTER_TIMEOUT``
|
| 149 |
+
Allow each test to run up to ``<n>`` times in order to pass.
|
| 150 |
+
Repeats tests only if they timeout.
|
| 151 |
+
This is useful in tolerating sporadic timeouts in test cases
|
| 152 |
+
on busy machines.
|
| 153 |
+
|
| 154 |
+
``SCHEDULE_RANDOM <ON|OFF>``
|
| 155 |
+
Launch tests in a random order. This may be useful for detecting
|
| 156 |
+
implicit test dependencies.
|
| 157 |
+
|
| 158 |
+
``STOP_ON_FAILURE``
|
| 159 |
+
.. versionadded:: 3.18
|
| 160 |
+
|
| 161 |
+
Stop the execution of the tests once one has failed.
|
| 162 |
+
|
| 163 |
+
``STOP_TIME <time-of-day>``
|
| 164 |
+
Specify a time of day at which the tests should all stop running.
|
| 165 |
+
|
| 166 |
+
``RETURN_VALUE <result-var>``
|
| 167 |
+
Store in the ``<result-var>`` variable ``0`` if all tests passed.
|
| 168 |
+
Store non-zero if anything went wrong.
|
| 169 |
+
|
| 170 |
+
``CAPTURE_CMAKE_ERROR <result-var>``
|
| 171 |
+
.. versionadded:: 3.7
|
| 172 |
+
|
| 173 |
+
Store in the ``<result-var>`` variable -1 if there are any errors running
|
| 174 |
+
the command and prevent ctest from returning non-zero if an error occurs.
|
| 175 |
+
|
| 176 |
+
``OUTPUT_JUNIT <file>``
|
| 177 |
+
.. versionadded:: 3.21
|
| 178 |
+
|
| 179 |
+
Write test results to ``<file>`` in JUnit XML format. If ``<file>`` is a
|
| 180 |
+
relative path, it will be placed in the build directory. If ``<file>``
|
| 181 |
+
already exists, it will be overwritten. Note that the resulting JUnit XML
|
| 182 |
+
file is **not** uploaded to CDash because it would be redundant with
|
| 183 |
+
CTest's ``Test.xml`` file.
|
| 184 |
+
|
| 185 |
+
``QUIET``
|
| 186 |
+
.. versionadded:: 3.3
|
| 187 |
+
|
| 188 |
+
Suppress any CTest-specific non-error messages that would have otherwise
|
| 189 |
+
been printed to the console. Output from the underlying test command is not
|
| 190 |
+
affected. Summary info detailing the percentage of passing tests is also
|
| 191 |
+
unaffected by the ``QUIET`` option.
|
| 192 |
+
|
| 193 |
+
See also the :variable:`CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE`,
|
| 194 |
+
:variable:`CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE` and
|
| 195 |
+
:variable:`CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION` variables, along with their
|
| 196 |
+
corresponding :manual:`ctest(1)` command line options
|
| 197 |
+
:option:`--test-output-size-passed <ctest --test-output-size-passed>`,
|
| 198 |
+
:option:`--test-output-size-failed <ctest --test-output-size-failed>`, and
|
| 199 |
+
:option:`--test-output-truncation <ctest --test-output-truncation>`.
|
| 200 |
+
|
| 201 |
+
.. _`Additional Test Measurements`:
|
| 202 |
+
|
| 203 |
+
Additional Test Measurements
|
| 204 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 205 |
+
|
| 206 |
+
CTest can parse the output of your tests for extra measurements to report
|
| 207 |
+
to CDash.
|
| 208 |
+
|
| 209 |
+
When run as a :ref:`Dashboard Client`, CTest will include these custom
|
| 210 |
+
measurements in the ``Test.xml`` file that gets uploaded to CDash.
|
| 211 |
+
|
| 212 |
+
Check the `CDash test measurement documentation
|
| 213 |
+
<https://github.com/Kitware/CDash/blob/master/docs/test_measurements.md>`_
|
| 214 |
+
for more information on the types of test measurements that CDash recognizes.
|
| 215 |
+
|
| 216 |
+
.. versionadded: 3.22
|
| 217 |
+
CTest can parse custom measurements from tags named
|
| 218 |
+
``<CTestMeasurement>`` or ``<CTestMeasurementFile>``. The older names
|
| 219 |
+
``<DartMeasurement>`` and ``<DartMeasurementFile>`` are still supported.
|
| 220 |
+
|
| 221 |
+
The following example demonstrates how to output a variety of custom test
|
| 222 |
+
measurements.
|
| 223 |
+
|
| 224 |
+
.. code-block:: c++
|
| 225 |
+
|
| 226 |
+
std::cout <<
|
| 227 |
+
"<CTestMeasurement type=\"numeric/double\" name=\"score\">28.3</CTestMeasurement>"
|
| 228 |
+
<< std::endl;
|
| 229 |
+
|
| 230 |
+
std::cout <<
|
| 231 |
+
"<CTestMeasurement type=\"text/string\" name=\"color\">red</CTestMeasurement>"
|
| 232 |
+
<< std::endl;
|
| 233 |
+
|
| 234 |
+
std::cout <<
|
| 235 |
+
"<CTestMeasurement type=\"text/link\" name=\"CMake URL\">https://cmake.org</CTestMeasurement>"
|
| 236 |
+
<< std::endl;
|
| 237 |
+
|
| 238 |
+
std::cout <<
|
| 239 |
+
"<CTestMeasurement type=\"text/preformatted\" name=\"Console Output\">" <<
|
| 240 |
+
"line 1.\n" <<
|
| 241 |
+
" \033[31;1m line 2. Bold red, and indented!\033[0;0ml\n" <<
|
| 242 |
+
"line 3. Not bold or indented...\n" <<
|
| 243 |
+
"</CTestMeasurement>" << std::endl;
|
| 244 |
+
|
| 245 |
+
Image Measurements
|
| 246 |
+
""""""""""""""""""
|
| 247 |
+
|
| 248 |
+
The following example demonstrates how to upload test images to CDash.
|
| 249 |
+
|
| 250 |
+
.. code-block:: c++
|
| 251 |
+
|
| 252 |
+
std::cout <<
|
| 253 |
+
"<CTestMeasurementFile type=\"image/jpg\" name=\"TestImage\">" <<
|
| 254 |
+
"/dir/to/test_img.jpg</CTestMeasurementFile>" << std::endl;
|
| 255 |
+
|
| 256 |
+
std::cout <<
|
| 257 |
+
"<CTestMeasurementFile type=\"image/gif\" name=\"ValidImage\">" <<
|
| 258 |
+
"/dir/to/valid_img.gif</CTestMeasurementFile>" << std::endl;
|
| 259 |
+
|
| 260 |
+
std::cout <<
|
| 261 |
+
"<CTestMeasurementFile type=\"image/png\" name=\"AlgoResult\">" <<
|
| 262 |
+
"/dir/to/img.png</CTestMeasurementFile>"
|
| 263 |
+
<< std::endl;
|
| 264 |
+
|
| 265 |
+
Images will be displayed together in an interactive comparison mode on CDash
|
| 266 |
+
if they are provided with two or more of the following names.
|
| 267 |
+
|
| 268 |
+
* ``TestImage``
|
| 269 |
+
* ``ValidImage``
|
| 270 |
+
* ``BaselineImage``
|
| 271 |
+
* ``DifferenceImage2``
|
| 272 |
+
|
| 273 |
+
By convention, ``TestImage`` is the image generated by your test, and
|
| 274 |
+
``ValidImage`` (or ``BaselineImage``) is basis of comparison used to determine
|
| 275 |
+
if the test passed or failed.
|
| 276 |
+
|
| 277 |
+
If another image name is used it will be displayed by CDash as a static image
|
| 278 |
+
separate from the interactive comparison UI.
|
| 279 |
+
|
| 280 |
+
Attached Files
|
| 281 |
+
""""""""""""""
|
| 282 |
+
|
| 283 |
+
.. versionadded:: 3.21
|
| 284 |
+
|
| 285 |
+
The following example demonstrates how to upload non-image files to CDash.
|
| 286 |
+
|
| 287 |
+
.. code-block:: c++
|
| 288 |
+
|
| 289 |
+
std::cout <<
|
| 290 |
+
"<CTestMeasurementFile type=\"file\" name=\"TestInputData1\">" <<
|
| 291 |
+
"/dir/to/data1.csv</CTestMeasurementFile>\n" <<
|
| 292 |
+
"<CTestMeasurementFile type=\"file\" name=\"TestInputData2\">" <<
|
| 293 |
+
"/dir/to/data2.csv</CTestMeasurementFile>" << std::endl;
|
| 294 |
+
|
| 295 |
+
If the name of the file to upload is known at configure time, you can use the
|
| 296 |
+
:prop_test:`ATTACHED_FILES` or :prop_test:`ATTACHED_FILES_ON_FAIL` test
|
| 297 |
+
properties instead.
|
| 298 |
+
|
| 299 |
+
Custom Details
|
| 300 |
+
""""""""""""""
|
| 301 |
+
|
| 302 |
+
.. versionadded:: 3.21
|
| 303 |
+
|
| 304 |
+
The following example demonstrates how to specify a custom value for the
|
| 305 |
+
``Test Details`` field displayed on CDash.
|
| 306 |
+
|
| 307 |
+
.. code-block:: c++
|
| 308 |
+
|
| 309 |
+
std::cout <<
|
| 310 |
+
"<CTestDetails>My Custom Details Value</CTestDetails>" << std::endl;
|
| 311 |
+
|
| 312 |
+
.. _`Additional Labels`:
|
| 313 |
+
|
| 314 |
+
Additional Labels
|
| 315 |
+
"""""""""""""""""
|
| 316 |
+
|
| 317 |
+
.. versionadded:: 3.22
|
| 318 |
+
|
| 319 |
+
The following example demonstrates how to add additional labels to a test
|
| 320 |
+
at runtime.
|
| 321 |
+
|
| 322 |
+
.. code-block:: c++
|
| 323 |
+
|
| 324 |
+
std::cout <<
|
| 325 |
+
"<CTestLabel>Custom Label 1</CTestLabel>\n" <<
|
| 326 |
+
"<CTestLabel>Custom Label 2</CTestLabel>" << std::endl;
|
| 327 |
+
|
| 328 |
+
Use the :prop_test:`LABELS` test property instead for labels that can be
|
| 329 |
+
determined at configure time.
|
cmake/share/cmake-3.31/Help/command/ctest_update.rst
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ctest_update
|
| 2 |
+
------------
|
| 3 |
+
|
| 4 |
+
Perform the :ref:`CTest Update Step` as a :ref:`Dashboard Client`.
|
| 5 |
+
|
| 6 |
+
.. code-block:: cmake
|
| 7 |
+
|
| 8 |
+
ctest_update([SOURCE <source-dir>]
|
| 9 |
+
[RETURN_VALUE <result-var>]
|
| 10 |
+
[CAPTURE_CMAKE_ERROR <result-var>]
|
| 11 |
+
[QUIET])
|
| 12 |
+
|
| 13 |
+
Update the source tree from version control and record results in
|
| 14 |
+
``Update.xml`` for submission with the :command:`ctest_submit` command.
|
| 15 |
+
|
| 16 |
+
The options are:
|
| 17 |
+
|
| 18 |
+
``SOURCE <source-dir>``
|
| 19 |
+
Specify the source directory. If not given, the
|
| 20 |
+
:variable:`CTEST_SOURCE_DIRECTORY` variable is used.
|
| 21 |
+
|
| 22 |
+
``RETURN_VALUE <result-var>``
|
| 23 |
+
Store in the ``<result-var>`` variable the number of files
|
| 24 |
+
updated or ``-1`` on error.
|
| 25 |
+
|
| 26 |
+
``CAPTURE_CMAKE_ERROR <result-var>``
|
| 27 |
+
.. versionadded:: 3.13
|
| 28 |
+
|
| 29 |
+
Store in the ``<result-var>`` variable -1 if there are any errors running
|
| 30 |
+
the command and prevent ctest from returning non-zero if an error occurs.
|
| 31 |
+
|
| 32 |
+
``QUIET``
|
| 33 |
+
.. versionadded:: 3.3
|
| 34 |
+
|
| 35 |
+
Tell CTest to suppress most non-error messages that it would
|
| 36 |
+
have otherwise printed to the console. CTest will still report
|
| 37 |
+
the new revision of the repository and any conflicting files
|
| 38 |
+
that were found.
|
| 39 |
+
|
| 40 |
+
The update always follows the version control branch currently checked
|
| 41 |
+
out in the source directory. See the :ref:`CTest Update Step`
|
| 42 |
+
documentation for information about variables that change the behavior
|
| 43 |
+
of ``ctest_update()``.
|