code:
function
--------

Start recording a function for later invocation as a command.

.. code-block:: cmake

  function(<name> [<arg1> ...])
    <commands>
  endfunction()

Defines a function named ``<name>`` that takes arguments named
``<arg1>``, ...  The ``<commands>`` in the function definition
are recorded; they are not executed until the function is invoked.

Per legacy, the :command:`endfunction` command admits an optional
``<name>`` argument. If used, it must be a verbatim repeat of the
argument of the opening ``function`` command.

A function opens a new scope: see :command:`set(var PARENT_SCOPE)` for
details.

See the :command:`cmake_policy()` command documentation for the behavior
of policies inside functions.

See the :command:`macro()` command documentation for differences
between CMake functions and macros.

Invocation
^^^^^^^^^^

The function invocation is case-insensitive. A function defined as

.. code-block:: cmake

  function(foo)
    <commands>
  endfunction()

can be invoked through any of

.. code-block:: cmake

  foo()
  Foo()
  FOO()
  cmake_language(CALL foo)

and so on. However, it is strongly recommended to stay with the
case chosen in the function definition. Typically functions use
all-lowercase names.

.. versionadded:: 3.18
  The :command:`cmake_language(CALL ...)` command can also be used to
  invoke the function.

Arguments
^^^^^^^^^

When the function is invoked, the recorded ``<commands>`` are first
modified by replacing formal parameters (``${arg1}``, ...) with the
arguments passed, and then invoked as normal commands.

In addition to referencing the formal parameters you can reference the
``ARGC`` variable which will be set to the number of arguments passed
into the function as well as ``ARGV0``, ``ARGV1``, ``ARGV2``, ...  which
will have the actual values of the arguments passed in.  This facilitates
creating functions with optional arguments.

Furthermore, ``ARGV`` holds the list of all arguments given to the
function and ``ARGN`` holds the list of arguments past the last expected
argument.  Referencing to ``ARGV#`` arguments beyond ``ARGC`` have
undefined behavior.  Checking that ``ARGC`` is greater than ``#`` is
the only way to ensure that ``ARGV#`` was passed to the function as an
extra argument.

See Also
^^^^^^^^

* :command:`cmake_parse_arguments`
* :command:`endfunction`
* :command:`return`


code:
get_cmake_property
------------------

Get a global property of the CMake instance.

.. code-block:: cmake

  get_cmake_property(<variable> <property>)

Gets a global property from the CMake instance.  The value of
the ``<property>`` is stored in the specified ``<variable>``.
If the property is not found, ``<variable>`` will be set to ``NOTFOUND``.
See the :manual:`cmake-properties(7)` manual for available properties.

In addition to global properties, this command (for historical reasons)
also supports the :prop_dir:`VARIABLES` and :prop_dir:`MACROS` directory
properties.  It also supports a special ``COMPONENTS`` global property that
lists the components given to the :command:`install` command.

See Also
^^^^^^^^

* the :command:`get_property` command ``GLOBAL`` option

repo_name: lazytadpole/codenamesilverfish

license: mit


code:
get_directory_property
----------------------

Get a property of ``DIRECTORY`` scope.

.. code-block:: cmake

  get_directory_property(<variable> [DIRECTORY <dir>] <prop-name>)

Stores a property of directory scope in the named ``<variable>``.

The ``DIRECTORY`` argument specifies another directory from which
to retrieve the property value instead of the current directory.
Relative paths are treated as relative to the
current source directory.  CMake must already know about the directory,
either by having added it through a call to :command:`add_subdirectory`
or being the top level directory.

.. versionadded:: 3.19
  ``<dir>`` may reference a binary directory.

If the property is not defined for the nominated directory scope,
an empty string is returned.  In the case of ``INHERITED`` properties,
if the property is not found for the nominated directory scope,
the search will chain to a parent scope as described for the
:command:`define_property` command.

.. code-block:: cmake

  get_directory_property(<variable> [DIRECTORY <dir>]
                         DEFINITION <var-name>)

Get a variable definition from a directory.  This form is useful to
get a variable definition from another directory.

See Also
^^^^^^^^

* :command:`define_property`
* the more general :command:`get_property` command


code:
get_filename_component
----------------------

Get a specific component of a full filename.

.. versionchanged:: 3.20
  This command has been superseded by the :command:`cmake_path` command, except
  for ``REALPATH``, which is now offered by :command:`file(REAL_PATH)`, and
  ``PROGRAM``, now available in :command:`separate_arguments(PROGRAM)`.

.. versionchanged:: 3.24
  The undocumented feature offering the capability to query the ``Windows``
  registry is superseded by
  :ref:`cmake_host_system_information(QUERY WINDOWS_REGISTRY)<Query Windows registry>`
  command.

.. code-block:: cmake

  get_filename_component(<var> <FileName> <mode> [CACHE])

Sets ``<var>`` to a component of ``<FileName>``, where ``<mode>`` is one of:

::

 DIRECTORY = Directory without file name
 NAME      = File name without directory
 EXT       = File name longest extension (.b.c from d/a.b.c)
 NAME_WE   = File name with neither the directory nor the longest extension
 LAST_EXT  = File name last extension (.c from d/a.b.c)
 NAME_WLE  = File name with neither the directory nor the last extension
 PATH      = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)

.. versionadded:: 3.14
  Added the ``LAST_EXT`` and ``NAME_WLE`` modes.

Paths are returned with forward slashes and have no trailing slashes.
If the optional ``CACHE`` argument is specified, the result variable is
added to the cache.

.. code-block:: cmake

  get_filename_component(<var> <FileName> <mode> [BASE_DIR <dir>] [CACHE])

.. versionadded:: 3.4

Sets ``<var>`` to the absolute path of ``<FileName>``, where ``<mode>`` is one
of:

::

 ABSOLUTE  = Full path to file
 REALPATH  = Full path to existing file with symlinks resolved

If the provided ``<FileName>`` is a relative path, it is evaluated relative
to the given base directory ``<dir>``.  If no base directory is
provided, the default base directory will be
:variable:`CMAKE_CURRENT_SOURCE_DIR`.

Paths are returned with forward slashes and have no trailing slashes.  If the
optional ``CACHE`` argument is specified, the result variable is added to the
cache.

.. code-block:: cmake

  get_filename_component(<var> <FileName> PROGRAM [PROGRAM_ARGS <arg_var>] [CACHE])

The program in ``<FileName>`` will be found in the system search path or
left as a full path.  If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then
any command-line arguments present in the ``<FileName>`` string are split
from the program name and stored in ``<arg_var>``.  This is used to
separate a program name from its arguments in a command line string.

See Also
^^^^^^^^

* :command:`cmake_path`


code:
get_property
------------

Get a property.

.. code-block:: cmake

  get_property(<variable>
               <GLOBAL             |
                DIRECTORY [<dir>]  |
                TARGET    <target> |
                SOURCE    <source>
                          [DIRECTORY <dir> | TARGET_DIRECTORY <target>] |
                INSTALL   <file>   |
                TEST      <test>
                          [DIRECTORY <dir>] |
                CACHE     <entry>  |
                VARIABLE           >
               PROPERTY <name>
               [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])

Gets one property from one object in a scope.

The first argument specifies the variable in which to store the result.
The second argument determines the scope from which to get the property.
It must be one of the following:

``GLOBAL``
  Scope is unique and does not accept a name.

``DIRECTORY``
  Scope defaults to the current directory but another
  directory (already processed by CMake) may be named by the
  full or relative path ``<dir>``.
  Relative paths are treated as relative to the current source directory.
  See also the :command:`get_directory_property` command.

  .. versionadded:: 3.19
    ``<dir>`` may reference a binary directory.

``TARGET``
  Scope must name one existing target.
  See also the :command:`get_target_property` command.

``SOURCE``
  Scope must name one source file.  By default, the source file's property
  will be read from the current source directory's scope.

  .. versionadded:: 3.18
    Directory scope can be overridden with one of the following sub-options:

    ``DIRECTORY <dir>``
      The source file property will be read from the ``<dir>`` directory's
      scope.  CMake must already know about
      the directory, either by having added it through a call
      to :command:`add_subdirectory` or ``<dir>`` being the top level directory.
      Relative paths are treated as relative to the current source directory.

      .. versionadded:: 3.19
        ``<dir>`` may reference a binary directory.

    ``TARGET_DIRECTORY <target>``
      The source file property will be read from the directory scope in which
      ``<target>`` was created (``<target>`` must therefore already exist).

  See also the :command:`get_source_file_property` command.

``INSTALL``
  .. versionadded:: 3.1

  Scope must name one installed file path.

``TEST``
  Scope must name one existing test.
  See also the :command:`get_test_property` command.

  .. versionadded:: 3.28
    Directory scope can be overridden with the following sub-option:

    ``DIRECTORY <dir>``
      The test property will be read from the ``<dir>`` directory's
      scope.  CMake must already know about the directory, either by having added
      it through a call to :command:`add_subdirectory` or ``<dir>`` being the top
      level directory. Relative paths are treated as relative to the current
      source directory. ``<dir>`` may reference a binary directory.

``CACHE``
  Scope must name one cache entry.

``VARIABLE``
  Scope is unique and does not accept a name.

The required ``PROPERTY`` option is immediately followed by the name of
the property to get.  If the property is not set an empty value is
returned, although some properties support inheriting from a parent scope
if defined to behave that way (see :command:`define_property`).

If the ``SET`` option is given the variable is set to a boolean
value indicating whether the property has been set.  If the ``DEFINED``
option is given the variable is set to a boolean value indicating
whether the property has been defined such as with the
:command:`define_property` command.

If ``BRIEF_DOCS`` or ``FULL_DOCS`` is given then the variable is set to a
string containing documentation for the requested property.  If
documentation is requested for a property that has not been defined
``NOTFOUND`` is returned.

.. note::

  The :prop_sf:`GENERATED` source file property may be globally visible.
  See its documentation for details.

See Also
^^^^^^^^

* :command:`define_property`
* :command:`set_property`


code:
get_source_file_property
------------------------

Get a property for a source file.

.. code-block:: cmake

  get_source_file_property(<variable> <file>
                           [DIRECTORY <dir> | TARGET_DIRECTORY <target>]
                           <property>)

Gets a property from a source file.  The value of the property is stored in
the specified ``<variable>``.  If the ``<file>`` is not a source file, or the
source property is not found, ``<variable>`` will be set to ``NOTFOUND``.
If the source property was defined to be an ``INHERITED`` property (see
:command:`define_property`), the search will include the relevant parent
scopes, as described for the :command:`define_property` command.

By default, the source file's property will be read from the current source
directory's scope.

.. versionadded:: 3.18
  Directory scope can be overridden with one of the following sub-options:

  ``DIRECTORY <dir>``
    The source file property will be read from the ``<dir>`` directory's
    scope.  CMake must already know about that source directory, either by
    having added it through a call to :command:`add_subdirectory` or ``<dir>``
    being the top level source directory.  Relative paths are treated as
    relative to the current source directory.

  ``TARGET_DIRECTORY <target>``
    The source file property will be read from the directory scope in which
    ``<target>`` was created (``<target>`` must therefore already exist).

Use :command:`set_source_files_properties` to set property values.  Source
file properties usually control how the file is built. One property that is
always there is :prop_sf:`LOCATION`.

.. note::

  The :prop_sf:`GENERATED` source file property may be globally visible.
  See its documentation for details.

See Also
^^^^^^^^

* :command:`define_property`
* the more general :command:`get_property` command
* :command:`set_source_files_properties`


code:
get_target_property
-------------------

Get a property from a target.

.. code-block:: cmake

  get_target_property(<variable> <target> <property>)

Get a property from a target.  The value of the property is stored in the
specified ``<variable>``.  If the target property is not found, ``<variable>``
will be set to ``<variable>-NOTFOUND``.  If the target property was defined to
be an ``INHERITED`` property (see :command:`define_property`), the search will
include the relevant parent scopes, as described for the
:command:`define_property` command.

Use :command:`set_target_properties` to set target property values.
Properties are usually used to control how a target is built, but some
query the target instead.  This command can get properties for any
target so far created.  The targets do not need to be in the current
``CMakeLists.txt`` file.

See Also
^^^^^^^^

* :command:`define_property`
* the more general :command:`get_property` command
* :command:`set_target_properties`
* :ref:`Target Properties` for the list of properties known to CMake


code:
get_test_property
-----------------

Get a property of the test.

.. code-block:: cmake

  get_test_property(<test> <property> [DIRECTORY <dir>] <variable>)

Get a property from the test.  The value of the property is stored in
the specified ``<variable>``.  If the ``<test>`` is not defined, or the
test property is not found, ``<variable>`` will be set to ``NOTFOUND``.
If the test property was defined to be an ``INHERITED`` property (see
:command:`define_property`), the search will include the relevant parent
scopes, as described for the :command:`define_property` command.

For a list of standard properties you can type
:option:`cmake --help-property-list`.

.. versionadded:: 3.28
  Directory scope can be overridden with the following sub-option:

  ``DIRECTORY <dir>``
    The test property will be read from the ``<dir>`` directory's
    scope.  CMake must already know about that source directory, either by
    having added it through a call to :command:`add_subdirectory` or ``<dir>``
    being the top level source directory.  Relative paths are treated as
    relative to the current source directory. ``<dir>`` may reference a binary
    directory.

See Also
^^^^^^^^

* :command:`define_property`
* the more general :command:`get_property` command


code:
if
--

Conditionally execute a group of commands.

Synopsis
^^^^^^^^

.. code-block:: cmake

  if(<condition>)
    <commands>
  elseif(<condition>) # optional block, can be repeated
    <commands>
  else()              # optional block
    <commands>
  endif()

Evaluates the ``condition`` argument of the ``if`` clause according to the
`Condition syntax`_ described below. If the result is true, then the
``commands`` in the ``if`` block are executed.
Otherwise, optional ``elseif`` blocks are processed in the same way.
Finally, if no ``condition`` is true, ``commands`` in the optional ``else``
block are executed.

Per legacy, the :command:`else` and :command:`endif` commands admit
an optional ``<condition>`` argument.
If used, it must be a verbatim
repeat of the argument of the opening
``if`` command.

.. _`Condition Syntax`:

Condition Syntax
^^^^^^^^^^^^^^^^

The following syntax applies to the ``condition`` argument of
the ``if``, ``elseif`` and :command:`while` clauses.

Compound conditions are evaluated in the following order of precedence:

1. `Parentheses`_.

2. Unary tests such as `EXISTS`_, `COMMAND`_, and `DEFINED`_.

3. Binary tests such as `EQUAL`_, `LESS`_, `LESS_EQUAL`_, `GREATER`_,
   `GREATER_EQUAL`_, `STREQUAL`_, `STRLESS`_, `STRLESS_EQUAL`_,
   `STRGREATER`_, `STRGREATER_EQUAL`_, `VERSION_EQUAL`_, `VERSION_LESS`_,
   `VERSION_LESS_EQUAL`_, `VERSION_GREATER`_, `VERSION_GREATER_EQUAL`_,
   `PATH_EQUAL`_, and `MATCHES`_.

4. Unary logical operator `NOT`_.

5. Binary logical operators `AND`_ and `OR`_, from left to right,
   without any short-circuit.

Basic Expressions
"""""""""""""""""

.. signature:: if(<constant>)
  :target: constant

  True if the constant is ``1``, ``ON``, ``YES``, ``TRUE``, ``Y``,
  or a non-zero number (including floating point numbers).
  False if the constant is ``0``, ``OFF``,
  ``NO``, ``FALSE``, ``N``, ``IGNORE``, ``NOTFOUND``, the empty string,
  or ends in the suffix ``-NOTFOUND``.  Named boolean constants are
  case-insensitive.  If the argument is not one of these specific
  constants, it is treated as a variable or string (see `Variable Expansion`_
  further below) and one of the following two forms applies.

.. signature:: if(<variable>)
  :target: variable

  True if given a variable that is defined to a value that is not a false
  constant.  False otherwise, including if the variable is undefined.
  Note that macro arguments are not variables.
  :ref:`Environment Variables <CMake Language Environment Variables>` also
  cannot be tested this way, e.g. ``if(ENV{some_var})`` will always evaluate
  to false.

.. signature:: if(<string>)
  :target: string

  A quoted string always evaluates to false unless:

  * The string's value is one of the true constants, or
  * Policy :policy:`CMP0054` is not set to ``NEW`` and the string's value
    happens to be a variable name that is affected by :policy:`CMP0054`'s
    behavior.

Logic Operators
"""""""""""""""

.. signature:: if(NOT <condition>)

  True if the condition is not true.

.. signature:: if(<cond1> AND <cond2>)
  :target: AND

  True if both conditions would be considered true individually.

.. signature:: if(<cond1> OR <cond2>)
  :target: OR

  True if either condition would be considered true individually.

.. signature:: if((condition) AND (condition OR (condition)))
  :target: parentheses

  The conditions inside the parenthesis are evaluated first and then
  the remaining condition is evaluated as in the other examples.
  Where there are nested parenthesis the innermost are evaluated as part
  of evaluating the condition that contains them.

Existence Checks
""""""""""""""""

.. signature:: if(COMMAND <command-name>)

  True if the given name is a command, macro or function that can be
  invoked.

.. signature:: if(POLICY <policy-id>)

  True if the given name is an existing policy (of the form ``CMP<NNNN>``).

.. signature:: if(TARGET <target-name>)

  True if the given name is an existing logical target name created
  by a call to the :command:`add_executable`, :command:`add_library`,
  or :command:`add_custom_target` command that has already been invoked
  (in any directory).

.. signature:: if(TEST <test-name>)

  .. versionadded:: 3.3

  True if the given name is an existing test name created by the
  :command:`add_test` command.

.. signature:: if(DEFINED <name>|CACHE{<name>}|ENV{<name>})

  True if a variable, cache variable or environment variable
  with given ``<name>`` is defined. The value of the variable
  does not matter. Note the following caveats:

  * Macro arguments are not variables.
  * It is not possible to test directly whether a `<name>` is a non-cache
    variable.  The expression ``if(DEFINED someName)`` will evaluate to true
    if either a cache or non-cache variable ``someName`` exists.  In
    comparison, the expression ``if(DEFINED CACHE{someName})`` will only
    evaluate to true if a cache variable ``someName`` exists.  Both expressions
    need to be tested if you need to know whether a non-cache variable exists:
    ``if(DEFINED someName AND NOT DEFINED CACHE{someName})``.

 .. versionadded:: 3.14
  Added support for ``CACHE{<name>}`` variables.

.. signature:: if(<variable|string> IN_LIST <variable>)
  :target: IN_LIST

  .. versionadded:: 3.3

  True if the given element is contained in the named list variable.

File Operations
"""""""""""""""

.. signature:: if(EXISTS <path-to-file-or-directory>)

  True if the named file or directory exists and is readable.  Behavior
  is well-defined only for explicit full paths (a leading ``~/`` is not
  expanded as a home directory and is considered a relative path).
  Resolves symbolic links, i.e. if the named file or directory is a
  symbolic link, returns true if the target of the symbolic link exists.

  False if the given path is an empty string.

  .. note::
    Prefer ``if(IS_READABLE)`` to check file readability.  ``if(EXISTS)``
    may be changed in the future to to only check file existence.

.. signature:: if(IS_READABLE <path-to-file-or-directory>)

  .. versionadded:: 3.29

  True if the named file or directory is readable.  Behavior
  is well-defined only for explicit full paths (a leading ``~/`` is not
  expanded as a home directory and is considered a relative path).
  Resolves symbolic links, i.e. if the named file or directory is a
  symbolic link, returns true if the target of the symbolic link is readable.

  False if the given path is an empty string.

.. signature:: if(IS_WRITABLE <path-to-file-or-directory>)

  .. versionadded:: 3.29

  True if the named file or directory is writable.  Behavior
  is well-defined only for explicit full paths (a leading ``~/`` is not
  expanded as a home directory and is considered a relative path).
  Resolves symbolic links, i.e. if the named file or directory is a
  symbolic link, returns true if the target of the symbolic link is writable.

  False if the given path is an empty string.

.. signature:: if(IS_EXECUTABLE <path-to-file-or-directory>)

  .. versionadded:: 3.29

  True if the named file or directory is executable.  Behavior
  is well-defined only for explicit full paths (a leading ``~/`` is not
  expanded as a home directory and is considered a relative path).
  Resolves symbolic links, i.e. if the named file or directory is a
  symbolic link, returns true if the target of the symbolic link is executable.

  False if the given path is an empty string.

.. signature:: if(<file1> IS_NEWER_THAN <file2>)
  :target: IS_NEWER_THAN

  True if ``file1`` is newer than ``file2`` or if one of the two files doesn't
  exist.  Behavior is well-defined only for full paths.  If the file
  time stamps are exactly the same, an ``IS_NEWER_THAN`` comparison returns
  true, so that any dependent build operations will occur in the event
  of a tie.  This includes the case of passing the same file name for
  both file1 and file2.

.. signature:: if(IS_DIRECTORY <path>)

  True if ``path`` is a directory.  Behavior is well-defined only
  for full paths.

  False if the given path is an empty string.

.. signature:: if(IS_SYMLINK <path>)

  True if the given path is a symbolic link.  Behavior is well-defined
  only for full paths.

.. signature:: if(IS_ABSOLUTE <path>)

  True if the given path is an absolute path.  Note the following special
  cases:

  * An empty ``path`` evaluates to false.
  * On Windows hosts, any ``path`` that begins with a drive letter and colon
    (e.g. ``C:``), a forward slash or a backslash will evaluate to true.
    This means a path like ``C:no\base\dir`` will evaluate to true, even
    though the non-drive part of the path is relative.
  * On non-Windows hosts, any ``path`` that begins with a tilde (``~``)
    evaluates to true.

Comparisons
"""""""""""

.. signature:: if(<variable|string> MATCHES <regex>)
  :target: MATCHES

  True if the given string or variable's value matches the given regular
  expression.  See :ref:`Regex Specification` for regex format.

  .. versionadded:: 3.9
   ``()`` groups are captured in :variable:`CMAKE_MATCH_<n>` variables.

.. signature:: if(<variable|string> LESS <variable|string>)
  :target: LESS

  True if the given string or variable's value parses as a real number
  (like a C ``double``) and less than that on the right.

.. signature:: if(<variable|string> GREATER <variable|string>)
  :target: GREATER

  True if the given string or variable's value parses as a real number
  (like a C ``double``) and greater than that on the right.

.. signature:: if(<variable|string> EQUAL <variable|string>)
  :target: EQUAL

  True if the given string or variable's value parses as a real number
  (like a C ``double``) and equal to that on the right.

.. signature:: if(<variable|string> LESS_EQUAL <variable|string>)
  :target: LESS_EQUAL

  .. versionadded:: 3.7

  True if the given string or variable's value parses as a real number
  (like a C ``double``) and less than or equal to that on the right.

.. signature:: if(<variable|string> GREATER_EQUAL <variable|string>)
  :target: GREATER_EQUAL

  .. versionadded:: 3.7

  True if the given string or variable's value parses as a real number
  (like a C ``double``) and greater than or equal to that on the right.

.. signature:: if(<variable|string> STRLESS <variable|string>)
  :target: STRLESS

  True if the given string or variable's value is lexicographically less
  than the string or variable on the right.

.. signature:: if(<variable|string> STRGREATER <variable|string>)
  :target: STRGREATER

  True if the given string or variable's value is lexicographically greater
  than the string or variable on the right.

.. signature:: if(<variable|string> STREQUAL <variable|string>)
  :target: STREQUAL

  True if the given string or variable's value is lexicographically equal
  to the string or variable on the right.

.. signature:: if(<variable|string> STRLESS_EQUAL <variable|string>)
  :target: STRLESS_EQUAL

  .. versionadded:: 3.7

  True if the given string or variable's value is lexicographically less
  than or equal to the string or variable on the right.

.. signature:: if(<variable|string> STRGREATER_EQUAL <variable|string>)
  :target: STRGREATER_EQUAL

  .. versionadded:: 3.7

  True if the given string or variable's value is lexicographically greater
  than or equal to the string or variable on the right.

Version Comparisons
"""""""""""""""""""

.. signature:: if(<variable|string> VERSION_LESS <variable|string>)
  :target: VERSION_LESS

  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.

.. signature:: if(<variable|string> VERSION_GREATER <variable|string>)
  :target: VERSION_GREATER

  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.

.. signature:: if(<variable|string> VERSION_EQUAL <variable|string>)
  :target: VERSION_EQUAL

  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.

.. signature:: if(<variable|string> VERSION_LESS_EQUAL <variable|string>)
  :target: VERSION_LESS_EQUAL

  .. versionadded:: 3.7

  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.

.. signature:: if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)
  :target: VERSION_GREATER_EQUAL

  .. versionadded:: 3.7

  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.

Path Comparisons
""""""""""""""""

.. signature:: if(<variable|string> PATH_EQUAL <variable|string>)
  :target: PATH_EQUAL

  .. versionadded:: 3.24

  Compares the two paths component-by-component.  Only if every component of
  both paths match will the two paths compare equal.  Multiple path separators
  are effectively collapsed into a single separator, but note that backslashes
  are not converted to forward slashes.  No other
  :ref:`path normalization <Normalization>` is performed.

  Component-wise comparison is superior to string-based comparison due to the
  handling of multiple path separators.  In the following example, the
  expression evaluates to true using ``PATH_EQUAL``, but false with
  ``STREQUAL``:

  .. code-block:: cmake

    # comparison is TRUE
    if ("/a//b/c" PATH_EQUAL "/a/b/c")
       ...
    endif()

    # comparison is FALSE
    if ("/a//b/c" STREQUAL "/a/b/c")
       ...
    endif()

  See :ref:`cmake_path(COMPARE) <Path COMPARE>` for more details.

Variable Expansion
^^^^^^^^^^^^^^^^^^

The if command was written very early in CMake's history, predating
the ``${}`` variable evaluation syntax, and for convenience evaluates
variables named by its arguments as shown in the above signatures.
Note that normal variable evaluation with ``${}`` applies before the if
command even receives the arguments.  Therefore code like

.. code-block:: cmake

 set(var1 OFF)
 set(var2 "var1")
 if(${var2})

appears to the if command as

.. code-block:: cmake

  if(var1)

and is evaluated according to the ``if(<variable>)`` case documented
above.  The result is ``OFF`` which is false.  However, if we remove the
``${}`` from the example then the command sees

.. code-block:: cmake

  if(var2)

which is true because ``var2`` is defined to ``var1`` which is not a false
constant.

Automatic evaluation applies in the other cases whenever the
above-documented condition syntax accepts ``<variable|string>``:

* The left hand argument to `MATCHES`_ is first checked to see if it is
  a defined variable.  If so, the variable's value is used, otherwise the
  original value is used.

* If the left hand argument to `MATCHES`_ is missing it returns false
  without error

* Both left and right hand arguments to `LESS`_, `GREATER`_, `EQUAL`_,
  `LESS_EQUAL`_, and `GREATER_EQUAL`_, are independently tested to see if
  they are defined variables.  If so, their defined values are used otherwise
  the original value is used.

* Both left and right hand arguments to `STRLESS`_, `STRGREATER`_,
  `STREQUAL`_, `STRLESS_EQUAL`_, and `STRGREATER_EQUAL`_ are independently
  tested to see if they are defined variables.  If so, their defined values are
  used otherwise the original value is used.

* Both left and right hand arguments to `VERSION_LESS`_,
  `VERSION_GREATER`_, `VERSION_EQUAL`_, `VERSION_LESS_EQUAL`_, and
  `VERSION_GREATER_EQUAL`_ are independently tested to see if they are defined
  variables.  If so, their defined values are used otherwise the original value
  is used.

* The right hand argument to `NOT`_ is tested to see if it is a boolean
  constant.  If so, the value is used, otherwise it is assumed to be a
  variable and it is dereferenced.

* The left and right hand arguments to `AND`_ and `OR`_ are independently
  tested to see if they are boolean constants.  If so, they are used as
  such, otherwise they are assumed to be variables and are dereferenced.

.. versionchanged:: 3.1
  To prevent ambiguity, potential variable or keyword names can be
  specified in a :ref:`Quoted Argument` or a :ref:`Bracket Argument`.
  A quoted or bracketed variable or keyword will be interpreted as a
  string and not dereferenced or interpreted.
  See policy :policy:`CMP0054`.

There is no automatic evaluation for environment or cache
:ref:`Variable References`.  Their values must be referenced as
``$ENV{<name>}`` or ``$CACHE{<name>}`` wherever the above-documented
condition syntax accepts ``<variable|string>``.

See also
^^^^^^^^

* :command:`else`
* :command:`elseif`
* :command:`endif`


code:
include
-------

Load and run CMake code from a file or module.

.. code-block:: cmake

  include(<file|module> [OPTIONAL] [RESULT_VARIABLE <var>]
                        [NO_POLICY_SCOPE])

Loads and runs CMake code from the file given.  Variable reads and
writes access the scope of the caller (dynamic scoping).  If ``OPTIONAL``
is present, then no error is raised if the file does not exist.  If
``RESULT_VARIABLE`` is given the variable ``<var>`` will be set to the
full filename which has been included or ``NOTFOUND`` if it failed.

If a module is specified instead of a file, the file with name
``<modulename>.cmake`` is searched first in :variable:`CMAKE_MODULE_PATH`,
then in the CMake module directory.  There is one exception to this: if
the file which calls ``include()`` is located itself in the CMake builtin
module directory, then first the CMake builtin module directory is searched and
:variable:`CMAKE_MODULE_PATH` afterwards.  See also policy :policy:`CMP0017`.

See the :command:`cmake_policy` command documentation for discussion of the
``NO_POLICY_SCOPE`` option.


code:
include_directories
-------------------

Add include directories to the build.

.. code-block:: cmake

  include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])

Add the given directories to those the compiler uses to search for
include files.  Relative paths are interpreted as relative to the
current source directory.

The include directories are added to the :prop_dir:`INCLUDE_DIRECTORIES`
directory property for the current ``CMakeLists`` file.  They are also
added to the :prop_tgt:`INCLUDE_DIRECTORIES` target property for each
target in the current ``CMakeLists`` file.  The target property values
are the ones used by the generators.

By default the directories specified are appended onto the current list of
directories.  This default behavior can be changed by setting
:variable:`CMAKE_INCLUDE_DIRECTORIES_BEFORE` to ``ON``.  By using
``AFTER`` or ``BEFORE`` explicitly, you can select between appending and
prepending, independent of the default.

If the ``SYSTEM`` option is given, the compiler will be told the
directories are meant as system include directories on some platforms.
Signaling this setting might achieve effects such as the compiler
skipping warnings, or these fixed-install system files not being
considered in dependency calculations - see compiler docs.

.. |command_name| replace:: ``include_directories``
.. include:: GENEX_NOTE.txt

.. note::

  Prefer the :command:`target_include_directories` command to add include
  directories to individual targets and optionally propagate/export them
  to dependents.

See Also
^^^^^^^^

* :command:`target_include_directories`


code:
include_external_msproject
--------------------------

Include an external Microsoft project file in a workspace.

.. code-block:: cmake

  include_external_msproject(projectname location
                             [TYPE projectTypeGUID]
                             [GUID projectGUID]
                             [PLATFORM platformName]
                             dep1 dep2 ...)

Includes an external Microsoft project in the generated workspace
file.  Currently does nothing on UNIX.  This will create a target
named ``[projectname]``.  This can be used in the :command:`add_dependencies`
command to make things depend on the external project.

``TYPE``, ``GUID`` and ``PLATFORM`` are optional parameters that allow one to
specify the type of project, id (``GUID``) of the project and the name of
the target platform.  This is useful for projects requiring values
other than the default (e.g.  WIX projects).

.. versionadded:: 3.9
  If the imported project has different configuration names than the
  current project, set the :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>`
  target property to specify the mapping.


code:
include_guard
-------------

.. versionadded:: 3.10

Provides an include guard for the file currently being processed by CMake.

.. code-block:: cmake

  include_guard([DIRECTORY|GLOBAL])

Sets up an include guard for the current CMake file (see the
:variable:`CMAKE_CURRENT_LIST_FILE` variable documentation).

CMake will end its processing of the current file at the location of the
``include_guard`` command if the current file has already been
processed for the applicable scope (see below). This provides functionality
similar to the include guards commonly used in source headers or to the
``#pragma once`` directive. If the current file has been processed previously
for the applicable scope, the effect is as though :command:`return` had been
called. Do not call this command from inside a function being defined within
the current file.

An optional argument specifying the scope of the guard may be provided.
Possible values for the option are:

``DIRECTORY``
  The include guard applies within the current directory and below. The file
  will only be included once within this directory scope, but may be included
  again by other files outside of this directory (i.e. a parent directory or
  another directory not pulled in by :command:`add_subdirectory` or
  :command:`include` from the current file or its children).

``GLOBAL``
  The include guard applies globally to the whole build. The current file
  will only be included once regardless of the scope.

If no arguments given, ``include_guard`` has the same scope as a variable,
meaning that the include guard effect is isolated by the most recent
function scope or current directory if no inner function scopes exist.
In this case the command behavior is the same as:

.. code-block:: cmake

  if(__CURRENT_FILE_VAR__)
    return()
  endif()
  set(__CURRENT_FILE_VAR__ TRUE)


code:
include_regular_expression
--------------------------

Set the regular expression used for dependency checking.

.. code-block:: cmake

  include_regular_expression(regex_match [regex_complain])

Sets the regular expressions used in dependency checking.  Only files
matching ``regex_match`` will be traced as dependencies.  Only files
matching ``regex_complain`` will generate warnings if they cannot be found
(standard header paths are not searched).  The defaults are:

::

  regex_match    = "^.*$" (match everything)
  regex_complain = "^$" (match empty string only)


code:
install
-------

.. only:: html

   .. contents::

Specify rules to run at install time.

Synopsis
^^^^^^^^

.. parsed-literal::

  install(`TARGETS`_ <target>... [...])
  install(`IMPORTED_RUNTIME_ARTIFACTS`_ <target>... [...])
  install({`FILES`_ | `PROGRAMS`_} <file>... [...])
  install(`DIRECTORY`_ <dir>... [...])
  install(`SCRIPT`_ <file> [...])
  install(`CODE`_ <code> [...])
  install(`EXPORT`_ <export-name> [...])
  install(`RUNTIME_DEPENDENCY_SET`_ <set-name> [...])

Introduction
^^^^^^^^^^^^

This command generates installation rules for a project.  Install rules
specified by calls to the ``install()`` command within a source directory
are executed in order during installation.

.. versionchanged:: 3.14
  Install rules in subdirectories
  added by calls to the :command:`add_subdirectory` command are interleaved
  with those in the parent directory to run in the order declared (see
  policy :policy:`CMP0082`).

.. versionchanged:: 3.22
  The environment variable :envvar:`CMAKE_INSTALL_MODE` can override the
  default copying behavior of ``install()``.

.. _`common options`:

There are multiple signatures for this command.  Some of them define
installation options for files and targets.  Options common to
multiple signatures are covered here but they are valid only for
signatures that specify them.  The common options are:

``DESTINATION <dir>``
  Specify the directory on disk to which a file will be installed.
  ``<dir>`` should be a relative path.  An absolute path is allowed,
  but not recommended.

  When a relative path is given it is interpreted relative to the value
  of the :variable:`CMAKE_INSTALL_PREFIX` variable.
  The prefix can be relocated at install time using the ``DESTDIR``
  mechanism explained in the :variable:`CMAKE_INSTALL_PREFIX` variable
  documentation.

  As absolute paths do not work with the ``cmake --install`` command's
  :option:`--prefix <cmake--install --prefix>` option, or with the
  :manual:`cpack <cpack(1)>` installer generators, it is strongly recommended
  to use relative paths throughout for best support by package maintainers.
  In particular, there is no need to make paths absolute by prepending
  :variable:`CMAKE_INSTALL_PREFIX`; this prefix is used by default if
  the DESTINATION is a relative path.

  If an absolute path (with a leading slash or drive letter) is given
  it is used verbatim.

``PERMISSIONS <permission>...``
  Specify permissions for installed files.  Valid permissions are
  ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``, ``GROUP_READ``,
  ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``, ``WORLD_WRITE``,
  ``WORLD_EXECUTE``, ``SETUID``, and ``SETGID``.  Permissions that do
  not make sense on certain platforms are ignored on those platforms.

  If this option is used multiple times in a single call, its list
  of permissions accumulates.  If an :command:`install(TARGETS)` call
  uses `\<artifact-kind\>`_ arguments, a separate list of permissions
  is accumulated for each kind of artifact.

``CONFIGURATIONS <config>...``
  Specify a list of build configurations for which the install rule
  applies (Debug, Release, etc.).

  If this option is used multiple times in a single call, its list
  of configurations accumulates.  If an :command:`install(TARGETS)`
  call uses `\<artifact-kind\>`_ arguments, a separate list of
  configurations is accumulated for each kind of artifact.

``COMPONENT <component>``
  Specify an installation component name with which the install rule
  is associated, such as ``Runtime`` or ``Development``.  During
  component-specific installation only install rules associated with
  the given component name will be executed.  During a full installation
  all components are installed unless marked with ``EXCLUDE_FROM_ALL``.
  If ``COMPONENT`` is not provided a default component "Unspecified" is
  created.  The default component name may be controlled with the
  :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable.

``EXCLUDE_FROM_ALL``
  .. versionadded:: 3.6

  Specify that the file is excluded from a full installation and only
  installed as part of a component-specific installation

``RENAME <name>``
  Specify a name for an installed file that may be different from the
  original file.  Renaming is allowed only when a single file is
  installed by the command.

``OPTIONAL``
  Specify that it is not an error if the file to be installed does
  not exist.

.. versionadded:: 3.1
  Command signatures that install files may print messages during
  installation.  Use the :variable:`CMAKE_INSTALL_MESSAGE` variable
  to control which messages are printed.

.. versionadded:: 3.11
  Many of the ``install()`` variants implicitly create the directories
  containing the installed files. If
  :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` is set, these
  directories will be created with the permissions specified. Otherwise,
  they will be created according to the uname rules on Unix-like platforms.
  Windows platforms are unaffected.

Signatures
^^^^^^^^^^

.. signature::
  install(TARGETS <target>... [...])

  Install target :ref:`Output Artifacts` and associated files:

  .. code-block:: cmake

    install(TARGETS <target>... [EXPORT <export-name>]
            [RUNTIME_DEPENDENCIES <arg>...|RUNTIME_DEPENDENCY_SET <set-name>]
            [<artifact-option>...]
            [<artifact-kind> <artifact-option>...]...
            [INCLUDES DESTINATION [<dir> ...]]
            )

  where ``<artifact-option>...`` group may contain:

  .. code-block:: cmake

    [DESTINATION <dir>]
    [PERMISSIONS <permission>...]
    [CONFIGURATIONS <config>...]
    [COMPONENT <component>]
    [NAMELINK_COMPONENT <component>]
    [OPTIONAL] [EXCLUDE_FROM_ALL]
    [NAMELINK_ONLY|NAMELINK_SKIP]

  The first ``<artifact-option>...`` group applies to target
  :ref:`Output Artifacts` that do not have a dedicated group specified
  later in the same call.

  .. _`<artifact-kind>`:

  Each ``<artifact-kind> <artifact-option>...`` group applies to
  :ref:`Output Artifacts` of the specified artifact kind:

  ``ARCHIVE``
    Target artifacts of this kind include:

    * *Static libraries*
      (except on macOS when marked as ``FRAMEWORK``, see below);
    * *DLL import libraries*
      (on all Windows-based systems including Cygwin; they have extension
      ``.lib``, in contrast to the ``.dll`` libraries that go to ``RUNTIME``);
    * On AIX, the *linker import file* created for executables with
      :prop_tgt:`ENABLE_EXPORTS` enabled.
    * On macOS, the *linker import file* created for shared libraries with
      :prop_tgt:`ENABLE_EXPORTS` enabled (except when marked as ``FRAMEWORK``,
      see below).

  ``LIBRARY``
    Target artifacts of this kind include:

    * *Shared libraries*, except

      - DLLs (these go to ``RUNTIME``, see below),
      - on macOS when marked as ``FRAMEWORK`` (see below).

  ``RUNTIME``
    Target artifacts of this kind include:

    * *Executables*
      (except on macOS when marked as ``MACOSX_BUNDLE``, see ``BUNDLE`` below);
    * DLLs (on all Windows-based systems including Cygwin; note that the
      accompanying import libraries are of kind ``ARCHIVE``).

  ``OBJECTS``
    .. versionadded:: 3.9

    Object files associated with *object libraries*.

  ``FRAMEWORK``
    Both static and shared libraries marked with the ``FRAMEWORK``
    property are treated as ``FRAMEWORK`` targets on macOS.

  ``BUNDLE``
    Executables marked with the :prop_tgt:`MACOSX_BUNDLE` property are treated as
    ``BUNDLE`` targets on macOS.

  ``PUBLIC_HEADER``
    Any :prop_tgt:`PUBLIC_HEADER` files associated with a library are installed in
    the destination specified by the ``PUBLIC_HEADER`` argument on non-Apple
    platforms. Rules defined by this argument are ignored for :prop_tgt:`FRAMEWORK`
    libraries on Apple platforms because the associated files are installed
    into the appropriate locations inside the framework folder. See
    :prop_tgt:`PUBLIC_HEADER` for details.

  ``PRIVATE_HEADER``
    Similar to ``PUBLIC_HEADER``, but for ``PRIVATE_HEADER`` files. See
    :prop_tgt:`PRIVATE_HEADER` for details.

  ``RESOURCE``
    Similar to ``PUBLIC_HEADER`` and ``PRIVATE_HEADER``, but for
    ``RESOURCE`` files. See :prop_tgt:`RESOURCE` for details.

  ``FILE_SET <set-name>``
    .. versionadded:: 3.23

    File sets are defined by the :command:`target_sources(FILE_SET)` command.
    If the file set ``<set-name>`` exists and is ``PUBLIC`` or ``INTERFACE``,
    any files in the set are installed under the destination (see below).
    The directory structure relative to the file set's base directories is
    preserved. For example, a file added to the file set as
    ``/blah/include/myproj/here.h`` with a base directory ``/blah/include``
    would be installed to ``myproj/here.h`` below the destination.

  ``CXX_MODULES_BMI``
    .. versionadded:: 3.28

    Any module files from C++ modules from ``PUBLIC`` sources in a file set of
    type ``CXX_MODULES`` will be installed to the given ``DESTINATION``. All
    modules are placed directly in the destination as no directory structure is
    derived from the names of the modules. An empty ``DESTINATION`` may be used
    to suppress installing these files (for use in generic code).

  For regular executables, static libraries and shared libraries, the
  ``DESTINATION`` argument is not required.  For these target types, when
  ``DESTINATION`` is omitted, a default destination will be taken from the
  appropriate variable from :module:`GNUInstallDirs`, or set to a built-in
  default value if that variable is not defined.  The same is true for file
  sets, and the public and private headers associated with the installed
  targets through the :prop_tgt:`PUBLIC_HEADER` and :prop_tgt:`PRIVATE_HEADER`
  target properties. A destination must always be provided for module libraries,
  Apple bundles and frameworks.  A destination can be omitted for interface and
  object libraries, but they are handled differently (see the discussion of this
  topic toward the end of this section).

  For shared libraries on DLL platforms, if neither ``RUNTIME`` nor ``ARCHIVE``
  destinations are specified, both the ``RUNTIME`` and ``ARCHIVE`` components are
  installed to their default destinations. If either a ``RUNTIME`` or ``ARCHIVE``
  destination is specified, the component is installed to that destination, and
  the other component is not installed. If both ``RUNTIME`` and ``ARCHIVE``
  destinations are specified, then both components are installed to their
  respective destinations.

  The following table shows the target types with their associated variables and
  built-in defaults that apply when no destination is given:

  =============================== =============================== ======================
     Target Type                      GNUInstallDirs Variable        Built-In Default
  =============================== =============================== ======================
  ``RUNTIME``                     ``${CMAKE_INSTALL_BINDIR}``     ``bin``
  ``LIBRARY``                     ``${CMAKE_INSTALL_LIBDIR}``     ``lib``
  ``ARCHIVE``                     ``${CMAKE_INSTALL_LIBDIR}``     ``lib``
  ``PRIVATE_HEADER``              ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  ``PUBLIC_HEADER``               ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  ``FILE_SET`` (type ``HEADERS``) ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
  =============================== =============================== ======================

  Projects wishing to follow the common practice of installing headers into a
  project-specific subdirectory may prefer using file sets with appropriate
  paths and base directories. Otherwise, they must provide a ``DESTINATION``
  instead of being able to rely on the above (see next example below).

  To make packages compliant with distribution filesystem layout policies, if
  projects must specify a ``DESTINATION``, it is strongly recommended that they use
  a path that begins with the appropriate relative :module:`GNUInstallDirs` variable.
  This allows package maintainers to control the install destination by setting
  the appropriate cache variables.  The following example shows a static library
  being installed to the default destination provided by
  :module:`GNUInstallDirs`, but with its headers installed to a project-specific
  subdirectory without using file sets:

  .. code-block:: cmake

    add_library(mylib STATIC ...)
    set_target_properties(mylib PROPERTIES PUBLIC_HEADER mylib.h)
    include(GNUInstallDirs)
    install(TARGETS mylib
            PUBLIC_HEADER
              DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
    )

  In addition to the `common options`_ listed above, each target can accept
  the following additional arguments:

  ``NAMELINK_COMPONENT``
    .. versionadded:: 3.12

    On some platforms a versioned shared library has a symbolic link such
    as::

      lib<name>.so -> lib<name>.so.1

    where ``lib<name>.so.1`` is the soname of the library and ``lib<name>.so``
    is a "namelink" allowing linkers to find the library when given
    ``-l<name>``. The ``NAMELINK_COMPONENT`` option is similar to the
    ``COMPONENT`` option, but it changes the installation component of a shared
    library namelink if one is generated. If not specified, this defaults to the
    value of ``COMPONENT``. It is an error to use this parameter outside of a
    ``LIBRARY`` block.

    .. versionchanged:: 3.27
      This parameter is also usable for an ``ARCHIVE`` block to manage
      the linker import file created, on macOS, for shared libraries with
      :prop_tgt:`ENABLE_EXPORTS` enabled.

    See the `Example: Install Targets with Per-Artifact Components`_
    for an example using ``NAMELINK_COMPONENT``.

    This option is typically used for package managers that have separate
    runtime and development packages. For example, on Debian systems, the
    library is expected to be in the runtime package, and the headers and
    namelink are expected to be in the development package.

    See the :prop_tgt:`VERSION` and :prop_tgt:`SOVERSION` target properties for
    details on creating versioned shared libraries.

  ``NAMELINK_ONLY``
    This option causes the installation of only the namelink when a library
    target is installed. On platforms where versioned shared libraries do not
    have namelinks or when a library is not versioned, the ``NAMELINK_ONLY``
    option installs nothing. It is an error to use this parameter outside of a
    ``LIBRARY`` block.

    .. versionchanged:: 3.27
      This parameter is also usable for an ``ARCHIVE`` block to manage
      the linker import file created, on macOS, for shared libraries with
      :prop_tgt:`ENABLE_EXPORTS` enabled.

    When ``NAMELINK_ONLY`` is given, either ``NAMELINK_COMPONENT`` or
    ``COMPONENT`` may be used to specify the installation component of the
    namelink, but ``COMPONENT`` should generally be preferred.

  ``NAMELINK_SKIP``
    Similar to ``NAMELINK_ONLY``, but it has the opposite effect: it causes the
    installation of library files other than the namelink when a library target
    is installed. When neither ``NAMELINK_ONLY`` or ``NAMELINK_SKIP`` are given,
    both portions are installed. On platforms where versioned shared libraries
    do not have symlinks or when a library is not versioned, ``NAMELINK_SKIP``
    installs the library. It is an error to use this parameter outside of a
    ``LIBRARY`` block.

    .. versionchanged:: 3.27
      This parameter is also usable for an ``ARCHIVE`` block to manage
      the linker import file created, on macOS, for shared libraries with
      :prop_tgt:`ENABLE_EXPORTS` enabled.

    If ``NAMELINK_SKIP`` is specified, ``NAMELINK_COMPONENT`` has no effect. It
    is not recommended to use ``NAMELINK_SKIP`` in conjunction with
    ``NAMELINK_COMPONENT``.

  The :command:`install(TARGETS)` command can also accept the following
  options at the top level:

  ``EXPORT``
    This option associates the installed target files with an export called
    ``<export-name>``.  It must appear before any target options.
    To actually install the export file itself, call
    :command:`install(EXPORT)`, documented below.
    See documentation of the :prop_tgt:`EXPORT_NAME` target property to change
    the name of the exported target.

    If ``EXPORT`` is used and the targets include ``PUBLIC`` or ``INTERFACE``
    file sets, all of them must be specified with ``FILE_SET`` arguments. All
    ``PUBLIC`` or ``INTERFACE`` file sets associated with a target are included
    in the export.

  ``INCLUDES DESTINATION``
    This option specifies a list of directories which will be added to the
    :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property of the
    ``<targets>`` when exported by the :command:`install(EXPORT)` command.
    If a relative path is specified, it is treated as relative to the
    :genex:`$<INSTALL_PREFIX>`.

  ``RUNTIME_DEPENDENCY_SET <set-name>``
    .. versionadded:: 3.21

    This option causes all runtime dependencies of installed executable, shared
    library, and module targets to be added to the specified runtime dependency
    set. This set can then be installed with an
    :command:`install(RUNTIME_DEPENDENCY_SET)` command.

    This keyword and the ``RUNTIME_DEPENDENCIES`` keyword are mutually
    exclusive.

  ``RUNTIME_DEPENDENCIES <arg>...``
    .. versionadded:: 3.21

    This option causes all runtime dependencies of installed executable, shared
    library, and module targets to be installed along with the targets
    themselves. The ``RUNTIME``, ``LIBRARY``, ``FRAMEWORK``, and generic
    arguments are used to determine the properties (``DESTINATION``,
    ``COMPONENT``, etc.) of the installation of these dependencies.

    ``RUNTIME_DEPENDENCIES`` is semantically equivalent to the following pair
    of calls:

    .. code-block:: cmake

      install(TARGETS ... RUNTIME_DEPENDENCY_SET <set-name>)
      install(RUNTIME_DEPENDENCY_SET <set-name> <arg>...)

    where ``<set-name>`` will be a randomly generated set name.
    ``<arg>...`` may include any of the following keywords supported by
    the :command:`install(RUNTIME_DEPENDENCY_SET)` command:

    * ``DIRECTORIES``
    * ``PRE_INCLUDE_REGEXES``
    * ``PRE_EXCLUDE_REGEXES``
    * ``POST_INCLUDE_REGEXES``
    * ``POST_EXCLUDE_REGEXES``
    * ``POST_INCLUDE_FILES``
    * ``POST_EXCLUDE_FILES``

    The ``RUNTIME_DEPENDENCIES`` and ``RUNTIME_DEPENDENCY_SET`` keywords are
    mutually exclusive.

  :ref:`Interface Libraries` may be listed among the targets to install.
  They install no artifacts but will be included in an associated ``EXPORT``.
  If :ref:`Object Libraries` are listed but given no destination for their
  object files, they will be exported as :ref:`Interface Libraries`.
  This is sufficient to satisfy transitive usage requirements of other
  targets that link to the object libraries in their implementation.

  Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property
  set to ``TRUE`` has undefined behavior.

  .. versionadded:: 3.3
    An install destination given as a ``DESTINATION`` argument may
    use "generator expressions" with the syntax ``$<...>``.  See the
    :manual:`cmake-generator-expressions(7)` manual for available expressions.

  .. versionadded:: 3.13
    :command:`install(TARGETS)` can install targets that were created in
    other directories.  When using such cross-directory install rules, running
    ``make install`` (or similar) from a subdirectory will not guarantee that
    targets from other directories are up-to-date.  You can use
    :command:`target_link_libraries` or :command:`add_dependencies`
    to ensure that such out-of-directory targets are built before the
    subdirectory-specific install rules are run.

.. signature::
  install(IMPORTED_RUNTIME_ARTIFACTS <target>... [...])

  .. versionadded:: 3.21

  Install runtime artifacts of imported targets:

  .. code-block:: cmake

    install(IMPORTED_RUNTIME_ARTIFACTS <target>...
            [RUNTIME_DEPENDENCY_SET <set-name>]
            [[LIBRARY|RUNTIME|FRAMEWORK|BUNDLE]
             [DESTINATION <dir>]
             [PERMISSIONS <permission>...]
             [CONFIGURATIONS <config>...]
             [COMPONENT <component>]
             [OPTIONAL] [EXCLUDE_FROM_ALL]
            ] [...]
            )

  The ``IMPORTED_RUNTIME_ARTIFACTS`` form specifies rules for installing the
  runtime artifacts of imported targets. Projects may do this if they want to
  bundle outside executables or modules inside their installation. The
  ``LIBRARY``, ``RUNTIME``, ``FRAMEWORK``, and ``BUNDLE`` arguments have the
  same semantics that they do in the `TARGETS`_ mode. Only the runtime artifacts
  of imported targets are installed (except in the case of :prop_tgt:`FRAMEWORK`
  libraries, :prop_tgt:`MACOSX_BUNDLE` executables, and :prop_tgt:`BUNDLE`
  CFBundles.) For example, headers and import libraries associated with DLLs are
  not installed. In the case of :prop_tgt:`FRAMEWORK` libraries,
  :prop_tgt:`MACOSX_BUNDLE` executables, and :prop_tgt:`BUNDLE` CFBundles, the
  entire directory is installed.

  The ``RUNTIME_DEPENDENCY_SET`` option causes the runtime artifacts of the
  imported executable, shared library, and module library ``targets`` to be
  added to the ``<set-name>`` runtime dependency set. This set can then be
  installed with an :command:`install(RUNTIME_DEPENDENCY_SET)` command.

.. signature::
  install(FILES <file>... [...])
  install(PROGRAMS <program>... [...])

  .. note::

    If installing header files, consider using file sets defined by
    :command:`target_sources(FILE_SET)` instead. File sets associate
    headers with a target and they install as part of the target.

  Install files or programs:

  .. code-block:: cmake

    install(<FILES|PROGRAMS> <file>...
            TYPE <type> | DESTINATION <dir>
            [PERMISSIONS <permission>...]
            [CONFIGURATIONS <config>...]
            [COMPONENT <component>]
            [RENAME <name>] [OPTIONAL] [EXCLUDE_FROM_ALL])

  The ``FILES`` form specifies rules for installing files for a project.
  File names given as relative paths are interpreted with respect to the
  current source directory.  Files installed by this form are by default
  given permissions ``OWNER_WRITE``, ``OWNER_READ``, ``GROUP_READ``, and
  ``WORLD_READ`` if no ``PERMISSIONS`` argument is given.

  The ``PROGRAMS`` form is identical to the ``FILES`` form except that the
  default permissions for the installed file also include ``OWNER_EXECUTE``,
  ``GROUP_EXECUTE``, and ``WORLD_EXECUTE``.  This form is intended to install
  programs that are not targets, such as shell scripts.  Use the ``TARGETS``
  form to install targets built within the project.

  The list of ``files...`` given to ``FILES`` or ``PROGRAMS`` may use
  "generator expressions" with the syntax ``$<...>``.  See the
  :manual:`cmake-generator-expressions(7)` manual for available expressions.
  However, if any item begins in a generator expression it must evaluate
  to a full path.

  Either a ``TYPE`` or a ``DESTINATION`` must be provided, but not both.
  A ``TYPE`` argument specifies the generic file type of the files being
  installed.  A destination will then be set automatically by taking the
  corresponding variable from :module:`GNUInstallDirs`, or by using a
  built-in default if that variable is not defined.  See the table below for
  the supported file types and their corresponding variables and built-in
  defaults.  Projects can provide a ``DESTINATION`` argument instead of a
  file type if they wish to explicitly define the install destination.

  ======================= ================================== =========================
     ``TYPE`` Argument         GNUInstallDirs Variable           Built-In Default
  ======================= ================================== =========================
  ``BIN``                 ``${CMAKE_INSTALL_BINDIR}``        ``bin``
  ``SBIN``                ``${CMAKE_INSTALL_SBINDIR}``       ``sbin``
  ``LIB``                 ``${CMAKE_INSTALL_LIBDIR}``        ``lib``
  ``INCLUDE``             ``${CMAKE_INSTALL_INCLUDEDIR}``    ``include``
  ``SYSCONF``             ``${CMAKE_INSTALL_SYSCONFDIR}``    ``etc``
  ``SHAREDSTATE``         ``${CMAKE_INSTALL_SHARESTATEDIR}`` ``com``
  ``LOCALSTATE``          ``${CMAKE_INSTALL_LOCALSTATEDIR}`` ``var``
  ``RUNSTATE``            ``${CMAKE_INSTALL_RUNSTATEDIR}``   ``<LOCALSTATE dir>/run``
  ``DATA``                ``${CMAKE_INSTALL_DATADIR}``       ``<DATAROOT dir>``
  ``INFO``                ``${CMAKE_INSTALL_INFODIR}``       ``<DATAROOT dir>/info``
  ``LOCALE``              ``${CMAKE_INSTALL_LOCALEDIR}``     ``<DATAROOT dir>/locale``
  ``MAN``                 ``${CMAKE_INSTALL_MANDIR}``        ``<DATAROOT dir>/man``
  ``DOC``                 ``${CMAKE_INSTALL_DOCDIR}``        ``<DATAROOT dir>/doc``
  ======================= ================================== =========================

  Projects wishing to follow the common practice of installing headers into a
  project-specific subdirectory will need to provide a destination rather than
  rely on the above. Using file sets for headers instead of ``install(FILES)``
  would be even better (see :command:`target_sources(FILE_SET)`).

  Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
  a prefix. The ``DATAROOT`` prefix is calculated similarly to the types, with
  ``CMAKE_INSTALL_DATAROOTDIR`` as the variable and ``share`` as the built-in
  default. You cannot use ``DATAROOT`` as a ``TYPE`` parameter; please use
  ``DATA`` instead.

  To make packages compliant with distribution filesystem layout policies, if
  projects must specify a ``DESTINATION``, it is strongly recommended that they use
  a path that begins with the appropriate relative :module:`GNUInstallDirs` variable.
  This allows package maintainers to control the install destination by setting
  the appropriate cache variables.  The following example shows how to follow
  this advice while installing an image to a project-specific documentation
  subdirectory:

  .. code-block:: cmake

    include(GNUInstallDirs)
    install(FILES logo.png
            DESTINATION ${CMAKE_INSTALL_DOCDIR}/myproj
    )

  .. versionadded:: 3.4
    An install destination given as a ``DESTINATION`` argument may
    use "generator expressions" with the syntax ``$<...>``.  See the
    :manual:`cmake-generator-expressions(7)` manual for available expressions.

  .. versionadded:: 3.20
    An install rename given as a ``RENAME`` argument may
    use "generator expressions" with the syntax ``$<...>``.  See the
    :manual:`cmake-generator-expressions(7)` manual for available expressions.

.. signature::
  install(DIRECTORY <dir>... [...])

  .. note::

    To install a directory sub-tree of headers, consider using file sets
    defined by :command:`target_sources(FILE_SET)` instead. File sets not only
    preserve directory structure, they also associate headers with a target
    and install as part of the target.

  Install the contents of one or more directories:

  .. code-block:: cmake

    install(DIRECTORY dirs...
            TYPE <type> | DESTINATION <dir>
            [FILE_PERMISSIONS <permission>...]
            [DIRECTORY_PERMISSIONS <permission>...]
            [USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
            [CONFIGURATIONS <config>...]
            [COMPONENT <component>] [EXCLUDE_FROM_ALL]
            [FILES_MATCHING]
            [[PATTERN <pattern> | REGEX <regex>]
             [EXCLUDE] [PERMISSIONS <permission>...]] [...])

  The ``DIRECTORY`` form installs contents of one or more directories to a
  given destination.  The directory structure is copied verbatim to the
  destination.  The last component of each directory name is appended to
  the destination directory but a trailing slash may be used to avoid
  this because it leaves the last component empty.  Directory names
  given as relative paths are interpreted with respect to the current
  source directory.  If no input directory names are given the
  destination directory will be created but nothing will be installed
  into it.  The ``FILE_PERMISSIONS`` and ``DIRECTORY_PERMISSIONS`` options
  specify permissions given to files and directories in the destination.
  If ``USE_SOURCE_PERMISSIONS`` is specified and ``FILE_PERMISSIONS`` is not,
  file permissions will be copied from the source directory structure.
  If no permissions are specified files will be given the default
  permissions specified in the ``FILES`` form of the command, and the
  directories will be given the default permissions specified in the
  ``PROGRAMS`` form of the command.

  .. versionadded:: 3.1
    The ``MESSAGE_NEVER`` option disables file installation status output.

  Installation of directories may be controlled with fine granularity
  using the ``PATTERN`` or ``REGEX`` options.  These "match" options specify a
  globbing pattern or regular expression to match directories or files
  encountered within input directories.  They may be used to apply
  certain options (see below) to a subset of the files and directories
  encountered.  The full path to each input file or directory (with
  forward slashes) is matched against the expression.  A ``PATTERN`` will
  match only complete file names: the portion of the full path matching
  the pattern must occur at the end of the file name and be preceded by
  a slash.  A ``REGEX`` will match any portion of the full path but it may
  use ``/`` and ``$`` to simulate the ``PATTERN`` behavior.  By default all
  files and directories are installed whether or not they are matched.
  The ``FILES_MATCHING`` option may be given before the first match option
  to disable installation of files (but not directories) not matched by
  any expression.  For example, the code

  .. code-block:: cmake

    install(DIRECTORY src/ DESTINATION doc/myproj
            FILES_MATCHING PATTERN "*.png")

  will extract and install images from a source tree.

  Some options may follow a ``PATTERN`` or ``REGEX`` expression as described
  under :ref:`string(REGEX) <Regex Specification>` and are applied
  only to files or directories matching them.  The ``EXCLUDE`` option will
  skip the matched file or directory.  The ``PERMISSIONS`` option overrides
  the permissions setting for the matched file or directory.  For
  example the code

  .. code-block:: cmake

    install(DIRECTORY icons scripts/ DESTINATION share/myproj
            PATTERN "CVS" EXCLUDE
            PATTERN "scripts/*"
            PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
                        GROUP_EXECUTE GROUP_READ)

  will install the ``icons`` directory to ``share/myproj/icons`` and the
  ``scripts`` directory to ``share/myproj``.  The icons will get default
  file permissions, the scripts will be given specific permissions, and any
  ``CVS`` directories will be excluded.

  Either a ``TYPE`` or a ``DESTINATION`` must be provided, but not both.
  A ``TYPE`` argument specifies the generic file type of the files within the
  listed directories being installed.  A destination will then be set
  automatically by taking the corresponding variable from
  :module:`GNUInstallDirs`, or by using a built-in default if that variable
  is not defined.  See the table below for the supported file types and their
  corresponding variables and built-in defaults.  Projects can provide a
  ``DESTINATION`` argument instead of a file type if they wish to explicitly
  define the install destination.

  ======================= ================================== =========================
     ``TYPE`` Argument         GNUInstallDirs Variable           Built-In Default
  ======================= ================================== =========================
  ``BIN``                 ``${CMAKE_INSTALL_BINDIR}``        ``bin``
  ``SBIN``                ``${CMAKE_INSTALL_SBINDIR}``       ``sbin``
  ``LIB``                 ``${CMAKE_INSTALL_LIBDIR}``        ``lib``
  ``INCLUDE``             ``${CMAKE_INSTALL_INCLUDEDIR}``    ``include``
  ``SYSCONF``             ``${CMAKE_INSTALL_SYSCONFDIR}``    ``etc``
  ``SHAREDSTATE``         ``${CMAKE_INSTALL_SHARESTATEDIR}`` ``com``
  ``LOCALSTATE``          ``${CMAKE_INSTALL_LOCALSTATEDIR}`` ``var``
  ``RUNSTATE``            ``${CMAKE_INSTALL_RUNSTATEDIR}``   ``<LOCALSTATE dir>/run``
  ``DATA``                ``${CMAKE_INSTALL_DATADIR}``       ``<DATAROOT dir>``
  ``INFO``                ``${CMAKE_INSTALL_INFODIR}``       ``<DATAROOT dir>/info``
  ``LOCALE``              ``${CMAKE_INSTALL_LOCALEDIR}``     ``<DATAROOT dir>/locale``
  ``MAN``                 ``${CMAKE_INSTALL_MANDIR}``        ``<DATAROOT dir>/man``
  ``DOC``                 ``${CMAKE_INSTALL_DOCDIR}``        ``<DATAROOT dir>/doc``
  ======================= ================================== =========================

  Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
  a prefix. The ``DATAROOT`` prefix is calculated similarly to the types, with
  ``CMAKE_INSTALL_DATAROOTDIR`` as the variable and ``share`` as the built-in
  default. You cannot use ``DATAROOT`` as a ``TYPE`` parameter; please use
  ``DATA`` instead.

  To make packages compliant with distribution filesystem layout policies, if
  projects must specify a ``DESTINATION``, it is strongly recommended that they use
  a path that begins with the appropriate relative :module:`GNUInstallDirs` variable.
  This allows package maintainers to control the install destination by setting
  the appropriate cache variables.

  .. versionadded:: 3.4
    An install destination given as a ``DESTINATION`` argument may
    use "generator expressions" with the syntax ``$<...>``.  See the
    :manual:`cmake-generator-expressions(7)` manual for available expressions.

  .. versionadded:: 3.5
    The list of ``dirs...`` given to ``DIRECTORY`` may use
    "generator expressions" too.

.. signature::
  install(SCRIPT <file> [...])
  install(CODE <code> [...])

  Invoke CMake scripts or code during installation:

  .. code-block:: cmake

    install([[SCRIPT <file>] [CODE <code>]]
            [ALL_COMPONENTS | COMPONENT <component>]
            [EXCLUDE_FROM_ALL] [...])

  The ``SCRIPT`` form will invoke the given CMake script files during
  installation.  If the script file name is a relative path it will be
  interpreted with respect to the current source directory.  The ``CODE``
  form will invoke the given CMake code during installation.  Code is
  specified as a single argument inside a double-quoted string.  For
  example, the code

  .. code-block:: cmake

    install(CODE "MESSAGE(\"Sample install message.\")")

  will print a message during installation.

  .. versionadded:: 3.21
    When the ``ALL_COMPONENTS`` option is given, the custom installation
    script code will be executed for every component of a component-specific
    installation.  This option is mutually exclusive with the ``COMPONENT``
    option.

  .. versionadded:: 3.14
    ``<file>`` or ``<code>`` may use "generator expressions" with the syntax
    ``$<...>`` (in the case of ``<file>``, this refers to their use in the file
    name, not the file's contents).  See the
    :manual:`cmake-generator-expressions(7)` manual for available expressions.

.. signature::
  install(EXPORT <export-name> [...])

  Install a CMake file exporting targets for dependent projects:

  .. code-block:: cmake

    install(EXPORT <export-name> DESTINATION <dir>
            [NAMESPACE <namespace>] [FILE <name>.cmake]
            [PERMISSIONS <permission>...]
            [CONFIGURATIONS <config>...]
            [CXX_MODULES_DIRECTORY <directory>]
            [EXPORT_LINK_INTERFACE_LIBRARIES]
            [COMPONENT <component>]
            [EXCLUDE_FROM_ALL]
            [EXPORT_PACKAGE_DEPENDENCIES])
    install(EXPORT_ANDROID_MK <export-name> DESTINATION <dir> [...])

  The ``EXPORT`` form generates and installs a CMake file containing code to
  import targets from the installation tree into another project.
  Target installations are associated with the export ``<export-name>``
  using the ``EXPORT`` option of the :command:`install(TARGETS)` signature
  documented above.  The ``NAMESPACE`` option will prepend ``<namespace>`` to
  the target names as they are written to the import file.  By default
  the generated file will be called ``<export-name>.cmake`` but the ``FILE``
  option may be used to specify a different name.  The value given to
  the ``FILE`` option must be a file name with the ``.cmake`` extension.
  If a ``CONFIGURATIONS`` option is given then the file will only be installed
  when one of the named configurations is installed.  Additionally, the
  generated import file will reference only the matching target
  configurations.  See the :variable:`CMAKE_MAP_IMPORTED_CONFIG_<CONFIG>`
  variable to map configurations of dependent projects to the installed
  configurations.  The ``EXPORT_LINK_INTERFACE_LIBRARIES`` keyword, if
  present, causes the contents of the properties matching
  ``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when
  policy :policy:`CMP0022` is ``NEW``.

  .. note::
    The installed ``<export-name>.cmake`` file may come with additional
    per-configuration ``<export-name>-*.cmake`` files to be loaded by
    globbing.  Do not use an export name that is the same as the package
    name in combination with installing a ``<package-name>-config.cmake``
    file or the latter may be incorrectly matched by the glob and loaded.

  When a ``COMPONENT`` option is given, the listed ``<component>`` implicitly
  depends on all components mentioned in the export set. The exported
  ``<name>.cmake`` file will require each of the exported components to be
  present in order for dependent projects to build properly. For example, a
  project may define components ``Runtime`` and ``Development``, with shared
  libraries going into the ``Runtime`` component and static libraries and
  headers going into the ``Development`` component. The export set would also
  typically be part of the ``Development`` component, but it would export
  targets from both the ``Runtime`` and ``Development`` components. Therefore,
  the ``Runtime`` component would need to be installed if the ``Development``
  component was installed, but not vice versa. If the ``Development`` component
  was installed without the ``Runtime`` component, dependent projects that try
  to link against it would have build errors. Package managers, such as APT and
  RPM, typically handle this by listing the ``Runtime`` component as a dependency
  of the ``Development`` component in the package metadata, ensuring that the
  library is always installed if the headers and CMake export file are present.

  .. versionadded:: 3.7
    In addition to cmake language files, the ``EXPORT_ANDROID_MK`` mode may be
    used to specify an export to the android ndk build system.  This mode
    accepts the same options as the normal export mode.  The Android
    NDK supports the use of prebuilt libraries, both static and shared. This
    allows cmake to build the libraries of a project and make them available
    to an ndk build system complete with transitive dependencies, include flags
    and defines required to use the libraries.

  ``CXX_MODULES_DIRECTORY``
    .. versionadded:: 3.28

    Specify a subdirectory to store C++ module information for targets in the
    export set. This directory will be populated with files which add the
    necessary target property information to the relevant targets. Note that
    without this information, none of the C++ modules which are part of the
    targets in the export set will support being imported in consuming targets.

  ``EXPORT_PACKAGE_DEPENDENCIES``
    .. versionadded:: 3.29

    Specify that :command:`find_dependency` calls should be exported. If this
    argument is specified, CMake examines all targets in the export set and
    gathers their ``INTERFACE`` link targets. If any such targets either were
    found with :command:`find_package` or have the
    :prop_tgt:`EXPORT_FIND_PACKAGE_NAME` property set, and such package
    dependency was not disabled by passing ``ENABLED OFF`` to
    :command:`export(SETUP)`, then a :command:`find_dependency` call is
    written with the target's corresponding package name, a ``REQUIRED``
    argument, and any additional arguments specified by the ``EXTRA_ARGS``
    argument of :command:`export(SETUP)`. Any package dependencies that were
    manually specified by passing ``ENABLED ON`` to :command:`export(SETUP)`
    are also added, even if the exported targets don't depend on any targets
    from them.

    The :command:`find_dependency` calls are written in the following order:

    1. Any package dependencies that were listed in :command:`export(SETUP)`
       are written in the order they were first specified, regardless of
       whether or not they contain ``INTERFACE`` dependencies of the
       exported targets.
    2. Any package dependencies that contain ``INTERFACE`` link dependencies
       of the exported targets and that were never specified in
       :command:`export(SETUP)` are written in the order they were first
       found.

  The ``EXPORT`` form is useful to help outside projects use targets built
  and installed by the current project.  For example, the code

  .. code-block:: cmake

    install(TARGETS myexe EXPORT myproj DESTINATION bin)
    install(EXPORT myproj NAMESPACE mp_ DESTINATION lib/myproj)
    install(EXPORT_ANDROID_MK myproj DESTINATION share/ndk-modules)

  will install the executable ``myexe`` to ``<prefix>/bin`` and code to import
  it in the file ``<prefix>/lib/myproj/myproj.cmake`` and
  ``<prefix>/share/ndk-modules/Android.mk``.  An outside project
  may load this file with the include command and reference the ``myexe``
  executable from the installation tree using the imported target name
  ``mp_myexe`` as if the target were built in its own tree.

  .. note::
    This command supersedes the :command:`install_targets` command and
    the :prop_tgt:`PRE_INSTALL_SCRIPT` and :prop_tgt:`POST_INSTALL_SCRIPT`
    target properties.  It also replaces the ``FILES`` forms of the
    :command:`install_files` and :command:`install_programs` commands.
    The processing order of these install rules relative to
    those generated by :command:`install_targets`,
    :command:`install_files`, and :command:`install_programs` commands
    is not defined.

.. signature::
  install(RUNTIME_DEPENDENCY_SET <set-name> [...])

  .. versionadded:: 3.21

  Installs a runtime dependency set:

  .. code-block:: cmake

    install(RUNTIME_DEPENDENCY_SET <set-name>
            [[LIBRARY|RUNTIME|FRAMEWORK]
             [DESTINATION <dir>]
             [PERMISSIONS <permission>...]
             [CONFIGURATIONS <config>...]
             [COMPONENT <component>]
             [NAMELINK_COMPONENT <component>]
             [OPTIONAL] [EXCLUDE_FROM_ALL]
            ] [...]
            [PRE_INCLUDE_REGEXES <regex>...]
            [PRE_EXCLUDE_REGEXES <regex>...]
            [POST_INCLUDE_REGEXES <regex>...]
            [POST_EXCLUDE_REGEXES <regex>...]
            [POST_INCLUDE_FILES <file>...]
            [POST_EXCLUDE_FILES <file>...]
            [DIRECTORIES <dir>...]
            )

  Installs a runtime dependency set previously created by one or more
  :command:`install(TARGETS)` or :command:`install(IMPORTED_RUNTIME_ARTIFACTS)`
  commands.  The dependencies of targets belonging to a runtime dependency set
  are installed in the ``RUNTIME`` destination and component on DLL platforms,
  and in the ``LIBRARY`` destination and component on non-DLL platforms.
  macOS frameworks are installed in the ``FRAMEWORK`` destination and component.
  Targets built within the build tree will never be installed as runtime
  dependencies, nor will their own dependencies, unless the targets themselves
  are installed with :command:`install(TARGETS)`.

  The generated install script calls :command:`file(GET_RUNTIME_DEPENDENCIES)`
  on the build-tree files to calculate the runtime dependencies. The build-tree
  executable files are passed as the ``EXECUTABLES`` argument, the build-tree
  shared libraries as the ``LIBRARIES`` argument, and the build-tree modules as
  the ``MODULES`` argument. On macOS, if one of the executables is a
  :prop_tgt:`MACOSX_BUNDLE`, that executable is passed as the
  ``BUNDLE_EXECUTABLE`` argument. At most one such bundle executable may be in
  the runtime dependency set on macOS. The :prop_tgt:`MACOSX_BUNDLE` property
  has no effect on other platforms. Note that
  :command:`file(GET_RUNTIME_DEPENDENCIES)` only supports collecting the runtime
  dependencies for Windows, Linux and macOS platforms, so
  ``install(RUNTIME_DEPENDENCY_SET)`` has the same limitation.

  The following sub-arguments are forwarded through as the corresponding
  arguments to :command:`file(GET_RUNTIME_DEPENDENCIES)` (for those that provide
  a non-empty list of directories, regular expressions or files).  They all
  support :manual:`generator expressions <cmake-generator-expressions(7)>`.

  * ``DIRECTORIES <dir>...``
  * ``PRE_INCLUDE_REGEXES <regex>...``
  * ``PRE_EXCLUDE_REGEXES <regex>...``
  * ``POST_INCLUDE_REGEXES <regex>...``
  * ``POST_EXCLUDE_REGEXES <regex>...``
  * ``POST_INCLUDE_FILES <file>...``
  * ``POST_EXCLUDE_FILES <file>...``

Examples
^^^^^^^^

Example: Install Targets with Per-Artifact Components
"""""""""""""""""""""""""""""""""""""""""""""""""""""

Consider a project that defines targets with different artifact kinds:

.. code-block:: cmake

  add_executable(myExe myExe.c)
  add_library(myStaticLib STATIC myStaticLib.c)
  target_sources(myStaticLib PUBLIC FILE_SET HEADERS FILES myStaticLib.h)
  add_library(mySharedLib SHARED mySharedLib.c)
  target_sources(mySharedLib PUBLIC FILE_SET HEADERS FILES mySharedLib.h)
  set_property(TARGET mySharedLib PROPERTY SOVERSION 1)

We may call :command:`install(TARGETS)` with `\<artifact-kind\>`_ arguments
to specify different options for each kind of artifact:

.. code-block:: cmake

  install(TARGETS
            myExe
            mySharedLib
            myStaticLib
          RUNTIME           # Following options apply to runtime artifacts.
            COMPONENT Runtime
          LIBRARY           # Following options apply to library artifacts.
            COMPONENT Runtime
            NAMELINK_COMPONENT Development
          ARCHIVE           # Following options apply to archive artifacts.
            COMPONENT Development
            DESTINATION lib/static
          FILE_SET HEADERS  # Following options apply to file set HEADERS.
            COMPONENT Development
          )

This will:

* Install ``myExe`` to ``<prefix>/bin``, the default RUNTIME artifact
  destination, as part of the ``Runtime`` component.

* On non-DLL platforms:

  * Install ``libmySharedLib.so.1`` to ``<prefix>/lib``, the default
    LIBRARY artifact destination, as part of the ``Runtime`` component.

  * Install the ``libmySharedLib.so`` "namelink" (symbolic link) to
    ``<prefix>/lib``, the default LIBRARY artifact destination, as part
    of the ``Development`` component.

* On DLL platforms:

  * Install ``mySharedLib.dll`` to ``<prefix>/bin``, the default RUNTIME
    artifact destination, as part of the ``Runtime`` component.

  * Install ``mySharedLib.lib`` to ``<prefix>/lib/static``, the specified
    ARCHIVE artifact destination, as part of the ``Development`` component.

* Install ``myStaticLib`` to ``<prefix>/lib/static``, the specified
  ARCHIVE artifact destination, as part of the ``Development`` component.

* Install ``mySharedLib.h`` and ``myStaticLib.h`` to ``<prefix>/include``,
  the default destination for a file set of type HEADERS, as part of the
  ``Development`` component.

Example: Install Targets to Per-Config Destinations
"""""""""""""""""""""""""""""""""""""""""""""""""""

Each :command:`install(TARGETS)` call installs a given target
:ref:`output artifact <Output Artifacts>` to at most one ``DESTINATION``,
but the install rule itself may be filtered by the ``CONFIGURATIONS`` option.
In order to install to a different destination for each configuration, one
call per configuration is needed.  For example, the code:

.. code-block:: cmake

  install(TARGETS myExe
          CONFIGURATIONS Debug
          RUNTIME
            DESTINATION Debug/bin
          )
  install(TARGETS myExe
          CONFIGURATIONS Release
          RUNTIME
            DESTINATION Release/bin
          )

will install ``myExe`` to ``<prefix>/Debug/bin`` in the Debug configuration,
and to ``<prefix>/Release/bin`` in the Release configuration.

Generated Installation Script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. note::

  Use of this feature is not recommended. Please consider using the
  :option:`cmake --install` instead.

The ``install()`` command generates a file, ``cmake_install.cmake``, inside
the build directory, which is used internally by the generated install target
and by CPack. You can also invoke this script manually with
:option:`cmake -P`. This script accepts several variables:

``COMPONENT``
  Set this variable to install only a single CPack component as opposed to all
  of them. For example, if you only want to install the ``Development``
  component, run ``cmake -DCOMPONENT=Development -P cmake_install.cmake``.

``BUILD_TYPE``
  Set this variable to change the build type if you are using a multi-config
  generator. For example, to install with the ``Debug`` configuration, run
  ``cmake -DBUILD_TYPE=Debug -P cmake_install.cmake``.

``DESTDIR``
  This is an environment variable rather than a CMake variable. It allows you
  to change the installation prefix on UNIX systems. See :envvar:`DESTDIR` for
  details.


code:
install_files
-------------

.. deprecated:: 3.0

  Use the :command:`install(FILES)` command instead.

This command has been superseded by the :command:`install` command.  It is
provided for compatibility with older CMake code.  The ``FILES`` form is
directly replaced by the ``FILES`` form of the :command:`install`
command.  The regexp form can be expressed more clearly using the ``GLOB``
form of the :command:`file` command.

.. code-block:: cmake

  install_files(<dir> extension file file ...)

Create rules to install the listed files with the given extension into
the given directory.  Only files existing in the current source tree
or its corresponding location in the binary tree may be listed.  If a
file specified already has an extension, that extension will be
removed first.  This is useful for providing lists of source files
such as foo.cxx when you want the corresponding foo.h to be installed.
A typical extension is ``.h``.

.. code-block:: cmake

  install_files(<dir> regexp)

Any files in the current source directory that match the regular
expression will be installed.

.. code-block:: cmake

  install_files(<dir> FILES file file ...)

Any files listed after the ``FILES`` keyword will be installed explicitly
from the names given.  Full paths are allowed in this form.

The directory ``<dir>`` is relative to the installation prefix, which is
stored in the variable :variable:`CMAKE_INSTALL_PREFIX`.


code:
install_programs
----------------

.. deprecated:: 3.0

  Use the :command:`install(PROGRAMS)` command instead.

This command has been superseded by the :command:`install` command.  It is
provided for compatibility with older CMake code.  The ``FILES`` form is
directly replaced by the ``PROGRAMS`` form of the :command:`install`
command.  The regexp form can be expressed more clearly using the ``GLOB``
form of the :command:`file` command.

.. code-block:: cmake

  install_programs(<dir> file1 file2 [file3 ...])
  install_programs(<dir> FILES file1 [file2 ...])

Create rules to install the listed programs into the given directory.
Use the ``FILES`` argument to guarantee that the file list version of the
command will be used even when there is only one argument.

.. code-block:: cmake

  install_programs(<dir> regexp)

In the second form any program in the current source directory that
matches the regular expression will be installed.

This command is intended to install programs that are not built by
cmake, such as shell scripts.  See the ``TARGETS`` form of the
:command:`install` command to create installation rules for targets built
by cmake.

The directory ``<dir>`` is relative to the installation prefix, which is
stored in the variable :variable:`CMAKE_INSTALL_PREFIX`.


code:
install_targets
---------------

.. deprecated:: 3.0

  Use the :command:`install(TARGETS)` command instead.

This command has been superseded by the :command:`install` command.  It is
provided for compatibility with older CMake code.

.. code-block:: cmake

  install_targets(<dir> [RUNTIME_DIRECTORY dir] target target)

Create rules to install the listed targets into the given directory.
The directory ``<dir>`` is relative to the installation prefix, which is
stored in the variable :variable:`CMAKE_INSTALL_PREFIX`.  If
``RUNTIME_DIRECTORY`` is specified, then on systems with special runtime
files (Windows DLL), the files will be copied to that directory.


code:
link_directories
----------------

Add directories in which the linker will look for libraries.

.. code-block:: cmake

  link_directories([AFTER|BEFORE] directory1 [directory2 ...])

Adds the paths in which the linker should search for libraries.
Relative paths given to this command are interpreted as relative to
the current source directory, see :policy:`CMP0015`.

The command will apply only to targets created after it is called.

.. versionadded:: 3.13
  The directories are added to the :prop_dir:`LINK_DIRECTORIES` directory
  property for the current ``CMakeLists.txt`` file, converting relative
  paths to absolute as needed.  See the :manual:`cmake-buildsystem(7)`
  manual for more on defining buildsystem properties.

.. versionadded:: 3.13
  By default the directories specified are appended onto the current list of
  directories.  This default behavior can be changed by setting
  :variable:`CMAKE_LINK_DIRECTORIES_BEFORE` to ``ON``.  By using
  ``AFTER`` or ``BEFORE`` explicitly, you can select between appending and
  prepending, independent of the default.

.. versionadded:: 3.13
  Arguments to ``link_directories`` may use "generator expressions" with
  the syntax "$<...>".  See the :manual:`cmake-generator-expressions(7)`
  manual for available expressions.

.. note::

  This command is rarely necessary and should be avoided where there are
  other choices.  Prefer to pass full absolute paths to libraries where
  possible, since this ensures the correct library will always be linked.
  The :command:`find_library` command provides the full path, which can
  generally be used directly in calls to :command:`target_link_libraries`.
  Situations where a library search path may be needed include:

  - Project generators like Xcode where the user can switch target
    architecture at build time, but a full path to a library cannot
    be used because it only provides one architecture (i.e. it is not
    a universal binary).
  - Libraries may themselves have other private library dependencies
    that expect to be found via ``RPATH`` mechanisms, but some linkers
    are not able to fully decode those paths (e.g. due to the presence
    of things like ``$ORIGIN``).

  If a library search path must be provided, prefer to localize the effect
  where possible by using the :command:`target_link_directories` command
  rather than ``link_directories()``.  The target-specific command can also
  control how the search directories propagate to other dependent targets.

See Also
^^^^^^^^

* :command:`target_link_directories`
* :command:`target_link_libraries`


code:
link_libraries
--------------

Link libraries to all targets added later.

.. code-block:: cmake

  link_libraries([item1 [item2 [...]]]
                 [[debug|optimized|general] <item>] ...)

Specify libraries or flags to use when linking any targets created later in
the current directory or below by commands such as :command:`add_executable`
or :command:`add_library`.  See the :command:`target_link_libraries` command
for meaning of arguments.

.. note::
  The :command:`target_link_libraries` command should be preferred whenever
  possible.  Library dependencies are chained automatically, so directory-wide
  specification of link libraries is rarely needed.