summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-06 16:15:35 -0500
committerBrad King <brad.king@kitware.com>2021-01-06 18:46:30 -0500
commitb8b6573db81327fc1800d9b1a92eb97820d7f972 (patch)
tree47a062d7060f00bf4d0eedd6a8bbd6426a4fac14 /Tests
parent2892228dc9e70aab3a724058a043068f87c860f6 (diff)
downloadcmake-b8b6573db81327fc1800d9b1a92eb97820d7f972.tar.gz
Xcode: Use deterministic object ids for script build phases
The Xcode "new build system" only considers a script build phase up to date if it has run before, even if outputs are newer than inputs. Use a deterministic object id for script build phases associated with custom commands so that they do not need to re-run after CMake re-generates the project. Fixes: #21669
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/BuildDepends/RepeatCMake-Custom-Script.cmake4
-rw-r--r--Tests/RunCMake/BuildDepends/RepeatCMake-Custom.cmake5
-rw-r--r--Tests/RunCMake/BuildDepends/RunCMakeTest.cmake17
3 files changed, 26 insertions, 0 deletions
diff --git a/Tests/RunCMake/BuildDepends/RepeatCMake-Custom-Script.cmake b/Tests/RunCMake/BuildDepends/RepeatCMake-Custom-Script.cmake
new file mode 100644
index 0000000000..3e953b349e
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/RepeatCMake-Custom-Script.cmake
@@ -0,0 +1,4 @@
+if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/exists-for-build2")
+ message(FATAL_ERROR "Custom command incorrectly re-ran after CMake re-ran!")
+endif()
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/out.txt")
diff --git a/Tests/RunCMake/BuildDepends/RepeatCMake-Custom.cmake b/Tests/RunCMake/BuildDepends/RepeatCMake-Custom.cmake
new file mode 100644
index 0000000000..697e485467
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/RepeatCMake-Custom.cmake
@@ -0,0 +1,5 @@
+add_custom_command(OUTPUT out.txt
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/RepeatCMake-Custom-Script.cmake
+ DEPENDS ${CMAKE_CURRENT_LIST_DIR}/RepeatCMake-Custom-Script.cmake
+ )
+add_custom_target(drive ALL DEPENDS out.txt)
diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
index 7a68c4bd8a..6c6d548d77 100644
--- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
+++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
@@ -70,6 +70,23 @@ if(RunCMake_GENERATOR MATCHES "Make")
endif()
endif()
+function(run_RepeatCMake CASE)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build)
+ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)
+ else()
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ run_cmake(${CASE})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${CASE}-build1 ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(${CASE}-rerun1 ${CMAKE_COMMAND} .)
+ file(WRITE ${RunCMake_TEST_BINARY_DIR}/exists-for-build2 "")
+ run_cmake_command(${CASE}-build2 ${CMAKE_COMMAND} --build . --config Debug)
+endfunction()
+
+run_RepeatCMake(RepeatCMake-Custom)
+
function(run_ReGeneration)
# test re-generation of project even if CMakeLists.txt files disappeared