From 81fd0d6e265985213ec3d0c1db4b8a6f314481ea Mon Sep 17 00:00:00 2001 From: Maik Nijhuis Date: Thu, 4 Aug 2022 16:09:20 +0200 Subject: ExternalProject: Fix install on BUILD_ALWAYS+BUILD_BYPRODUCTS with Ninja The `BUILD_BYPRODUCTS` option causes the ExternalProject's `build` step in `build.ninja` to have `restat = 1`, so its "always out-of-date" status caused by `BUILD_ALWAYS` does not propagate to the `install` step. Mark the latter step as explicitly always out-of-date too. Fixes: #23820 --- Modules/ExternalProject.cmake | 14 ++++++++++++++ Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake | 3 +++ 2 files changed, 17 insertions(+) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index c7948cd..2520cf3 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -3829,6 +3829,19 @@ function(_ep_add_install_command name) set(uses_terminal "") endif() + # With BUILD_ALWAYS+BUILD_BYPRODUCTS, Ninja restats the + # build step outputs and may not consider this step to + # be out-of-date. Explicitly mark it out-of-date too. + get_property(build_always + TARGET ${name} + PROPERTY _EP_BUILD_ALWAYS + ) + if(build_always) + set(always 1) + else() + set(always 0) + endif() + set(__cmdQuoted) foreach(__item IN LISTS cmd) string(APPEND __cmdQuoted " [==[${__item}]==]") @@ -3839,6 +3852,7 @@ function(_ep_add_install_command name) COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${binary_dir} DEPENDEES build + ALWAYS \${always} ${log} ${uses_terminal} )" diff --git a/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake index fdd3ad9..2e5fc6f 100644 --- a/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake +++ b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake @@ -12,6 +12,9 @@ ExternalProject_Add(always DOWNLOAD_COMMAND "" CONFIGURE_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/always-configure.cmake BUILD_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/always-build.cmake + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${CMAKE_CURRENT_LIST_FILE} + "${CMAKE_CURRENT_BINARY_DIR}/byproduct.txt" + BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/byproduct.txt" BUILD_ALWAYS 1 INSTALL_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/always-install.cmake ) -- cgit v0.12