1include
2-------
3
4Load and run CMake code from a file or module.
5
6.. code-block:: cmake
7
8  include(<file|module> [OPTIONAL] [RESULT_VARIABLE <var>]
9                        [NO_POLICY_SCOPE])
10
11Loads and runs CMake code from the file given.  Variable reads and
12writes access the scope of the caller (dynamic scoping).  If ``OPTIONAL``
13is present, then no error is raised if the file does not exist.  If
14``RESULT_VARIABLE`` is given the variable ``<var>`` will be set to the
15full filename which has been included or ``NOTFOUND`` if it failed.
16
17If a module is specified instead of a file, the file with name
18``<modulename>.cmake`` is searched first in :variable:`CMAKE_MODULE_PATH`,
19then in the CMake module directory.  There is one exception to this: if
20the file which calls ``include()`` is located itself in the CMake builtin
21module directory, then first the CMake builtin module directory is searched and
22:variable:`CMAKE_MODULE_PATH` afterwards.  See also policy :policy:`CMP0017`.
23
24See the :command:`cmake_policy` command documentation for discussion of the
25``NO_POLICY_SCOPE`` option.
26