summaryrefslogtreecommitdiff
path: root/Modules/ExternalProject.cmake
diff options
context:
space:
mode:
authorAlois Klink <alois@aloisklink.com>2022-11-03 15:40:30 +0000
committerAlois Klink <alois@aloisklink.com>2022-11-05 16:26:45 +0000
commit8c6b2928f4b71f87ba6ef6ccfaa7ba1c767f3097 (patch)
treecd3a42e8ea2a38a6a5583f03920d6577ac9b736d /Modules/ExternalProject.cmake
parent6d6baffb85ab4e02848fa7a3752f967d6ecb9518 (diff)
downloadcmake-8c6b2928f4b71f87ba6ef6ccfaa7ba1c767f3097.tar.gz
ExternalProject: Add `INSTALL_BYPRODUCTS` option
Add an `INSTALL_BYPRODUCTS` option to `ExternalProject_Add` that can be used to declare that files are `BYPRODUCTS` of the ExternalProject install step. This is often required by the Ninja generator to explicitly declare dependencies. Previously, many users used `BUILD_BYPRODUCTS`, even if their files were created by the install step, not the build step. This commit essentially just copies the code for `BUILD_BYPRODUCTS`. Fixes: #24120 Fixes: #23056
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r--Modules/ExternalProject.cmake18
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 4af0952173..9fecd8f840 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -664,6 +664,17 @@ External Project Definition
supported). Passing an empty string as the ``<cmd>`` makes the install
step do nothing.
+ ``INSTALL_BYPRODUCTS <file>...``
+ .. versionadded:: 3.26
+
+ Specifies files that will be generated by the install command but which
+ might or might not have their modification time updated by subsequent
+ installs. This may also be required to explicitly declare dependencies
+ when using the :generator:`Ninja` generator.
+ These ultimately get passed through as ``BYPRODUCTS`` to the
+ install step's own underlying call to :command:`add_custom_command`, which
+ has additional documentation.
+
.. note::
If the :envvar:`CMAKE_INSTALL_MODE` environment variable is set when the
main project is built, it will only have an effect if the following
@@ -3852,6 +3863,11 @@ function(_ep_add_install_command name)
set(always 0)
endif()
+ get_property(install_byproducts
+ TARGET ${name}
+ PROPERTY _EP_INSTALL_BYPRODUCTS
+ )
+
set(__cmdQuoted)
foreach(__item IN LISTS cmd)
string(APPEND __cmdQuoted " [==[${__item}]==]")
@@ -3860,6 +3876,7 @@ function(_ep_add_install_command name)
ExternalProject_Add_Step(${name} install
INDEPENDENT FALSE
COMMAND ${__cmdQuoted}
+ BYPRODUCTS \${install_byproducts}
WORKING_DIRECTORY \${binary_dir}
DEPENDEES build
ALWAYS \${always}
@@ -4087,6 +4104,7 @@ function(ExternalProject_Add name)
# Install step options
#
INSTALL_COMMAND
+ INSTALL_BYPRODUCTS
#
# Test step options
#