summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-12 15:25:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-01-12 15:25:07 (GMT)
commitdb8e2e711a1d34944c7939ef4e0eec1fee8e35f2 (patch)
treed3a20f5154b8f3a8b1bde89d39b1d8d25384a5ad /Help
parent462dc20efae67ccfb0f6aefc40c7e3f6ffba4b6d (diff)
parent98805a11ce8010810b9be89a019841752f6b34f4 (diff)
downloadCMake-db8e2e711a1d34944c7939ef4e0eec1fee8e35f2.zip
CMake-db8e2e711a1d34944c7939ef4e0eec1fee8e35f2.tar.gz
CMake-db8e2e711a1d34944c7939ef4e0eec1fee8e35f2.tar.bz2
Merge topic 'ninja-multi-config-post-build'
98805a11ce Ninja Multi-Config: Run POST_BUILD when BYPRODUCTS don't overlap Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5673
Diffstat (limited to 'Help')
-rw-r--r--Help/generator/Ninja Multi-Config.rst31
1 files changed, 31 insertions, 0 deletions
diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst
index d1df42b..8901192 100644
--- a/Help/generator/Ninja Multi-Config.rst
+++ b/Help/generator/Ninja Multi-Config.rst
@@ -130,3 +130,34 @@ output config using the ``Release`` command config. The ``Release`` build of
the ``generator`` target is called with ``Debug.txt Debug Release`` as
arguments. The command depends on the ``Release`` builds of ``tgt1`` and
``tgt4``, and the ``Debug`` builds of ``tgt2`` and ``tgt3``.
+
+``PRE_BUILD``, ``PRE_LINK``, and ``POST_BUILD`` custom commands for targets
+only get run in their "native" configuration (the ``Release`` configuration in
+the ``build-Release.ninja`` file) unless they have no ``BYPRODUCTS`` or their
+``BYPRODUCTS`` are unique per config. Consider the following example:
+
+.. code-block:: cmake
+
+ add_executable(exe main.c)
+ add_custom_command(
+ TARGET exe
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "Running no-byproduct command"
+ )
+ add_custom_command(
+ TARGET exe
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "Running separate-byproduct command for $<CONFIG>"
+ BYPRODUCTS $<CONFIG>.txt
+ )
+ add_custom_command(
+ TARGET exe
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "Running common-byproduct command for $<CONFIG>"
+ BYPRODUCTS exe.txt
+ )
+
+In this example, if you build ``exe:Debug`` in ``build-Release.ninja``, the
+first and second custom commands get run, since their byproducts are unique
+per-config, but the last custom command does not. However, if you build
+``exe:Release`` in ``build-Release.ninja``, all three custom commands get run.