cmake/Help/command/include.rst

26 lines
1.1 KiB
ReStructuredText
Raw Normal View History

2014-08-03 19:52:23 +02:00
include
-------
Load and run CMake code from a file or module.
2019-11-11 23:01:05 +01:00
.. code-block:: cmake
2014-08-03 19:52:23 +02:00
2019-11-11 23:01:05 +01:00
include(<file|module> [OPTIONAL] [RESULT_VARIABLE <var>]
2014-08-03 19:52:23 +02:00
[NO_POLICY_SCOPE])
2019-11-11 23:01:05 +01:00
Loads and runs CMake code from the file given. Variable reads and
2015-11-17 17:22:37 +01:00
writes access the scope of the caller (dynamic scoping). If ``OPTIONAL``
2014-08-03 19:52:23 +02:00
is present, then no error is raised if the file does not exist. If
2019-11-11 23:01:05 +01:00
``RESULT_VARIABLE`` is given the variable ``<var>`` will be set to the
full filename which has been included or ``NOTFOUND`` if it failed.
2014-08-03 19:52:23 +02:00
If a module is specified instead of a file, the file with name
2016-10-30 18:24:19 +01:00
``<modulename>.cmake`` is searched first in :variable:`CMAKE_MODULE_PATH`,
2015-11-17 17:22:37 +01:00
then in the CMake module directory. There is one exception to this: if
2016-10-30 18:24:19 +01:00
the file which calls ``include()`` is located itself in the CMake builtin
module directory, then first the CMake builtin module directory is searched and
2015-11-17 17:22:37 +01:00
:variable:`CMAKE_MODULE_PATH` afterwards. See also policy :policy:`CMP0017`.
2014-08-03 19:52:23 +02:00
2015-11-17 17:22:37 +01:00
See the :command:`cmake_policy` command documentation for discussion of the
``NO_POLICY_SCOPE`` option.