diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-01-07 16:03:25 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2021-01-07 16:26:17 (GMT) |
commit | 98805a11ce8010810b9be89a019841752f6b34f4 (patch) | |
tree | ff59ce61bb1c6eccc82295aaee3f09c06d544787 /Help/generator/Ninja Multi-Config.rst | |
parent | 1c9b61c23edb8200400ac77585f94ccd9fe0e58f (diff) | |
download | CMake-98805a11ce8010810b9be89a019841752f6b34f4.zip CMake-98805a11ce8010810b9be89a019841752f6b34f4.tar.gz CMake-98805a11ce8010810b9be89a019841752f6b34f4.tar.bz2 |
Ninja Multi-Config: Run POST_BUILD when BYPRODUCTS don't overlap
Fixes: #21252
Diffstat (limited to 'Help/generator/Ninja Multi-Config.rst')
-rw-r--r-- | Help/generator/Ninja Multi-Config.rst | 31 |
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. |