diff options
author | Craig Scott <craig.scott@crascit.com> | 2022-08-28 22:37:42 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-08-28 22:37:49 (GMT) |
commit | 8c381fdd41de69ad91f016d34bf67a56d856691d (patch) | |
tree | 7e2be66c0658441c2bb46c1c11faba0992678ec2 | |
parent | d6fbfc94a1923c3a92b97ad7028a77d4f0f850d2 (diff) | |
parent | b2d07c3297d1890b79f05e4d4b8ea6bf262d553b (diff) | |
download | CMake-8c381fdd41de69ad91f016d34bf67a56d856691d.zip CMake-8c381fdd41de69ad91f016d34bf67a56d856691d.tar.gz CMake-8c381fdd41de69ad91f016d34bf67a56d856691d.tar.bz2 |
Merge topic 'c-d-argument-order-doc'
b2d07c3297 Help: Clarify that the order of -C and -D arguments matters
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7614
-rw-r--r-- | Help/manual/OPTIONS_BUILD.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index 4220dc0..94adac8 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -45,6 +45,25 @@ This option may also be given as a single argument: ``-D<var>:<type>=<value>`` or ``-D<var>=<value>``. + It's important to note that the order of ``-C`` and ``-D`` arguments is + significant. They will be carried out in the order they are listed, with the + last argument taking precedence over the previous ones. For example, if you + specify ``-DCMAKE_BUILD_TYPE=Debug``, followed by a ``-C`` argument with a + file that calls: + + .. code-block:: cmake + + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) + + then the ``-C`` argument will take precedence, and ``CMAKE_BUILD_TYPE`` will + be set to ``Release``. However, if the ``-D`` argument comes after the ``-C`` + argument, it will be set to ``Debug``. + + If a ``set(... CACHE ...)`` call in the ``-C`` file does not use ``FORCE``, + and a ``-D`` argument sets the same variable, the ``-D`` argument will take + precedence regardless of order because of the nature of non-``FORCE`` + ``set(... CACHE ...)`` calls. + .. option:: -U <globbing_expr> Remove matching entries from CMake ``CACHE``. |