Browse Source

FetchContent: Restore patch command support

The refactoring in 17e5516e60 (FetchContent: Invoke steps directly and
avoid a separate sub-build, 2021-01-29) contained a typo which resulted
in any PATCH_COMMAND being ignored. Fix the typo and add a test case
that would have caught the regression.
Craig Scott 4 years ago
parent
commit
bd876f3849

+ 1 - 1
Modules/ExternalProject.cmake

@@ -3897,7 +3897,7 @@ function(_ep_do_preconfigure_steps_now name)
 
   # Once any step has to run, all later steps have to be run too
   set(need_to_run FALSE)
-  foreach(step IN ITEMS download update parse)
+  foreach(step IN ITEMS download update patch)
     if(update_disconnected AND "${step}" STREQUAL "update")
       continue()
     endif()

+ 6 - 0
Tests/RunCMake/FetchContent/MultiCommand-stdout.txt

@@ -0,0 +1,6 @@
+.* *download 1
+.* *download 2
+.* *update 1
+.* *update 2
+.* *patch 1
+.* *patch 2

+ 18 - 0
Tests/RunCMake/FetchContent/MultiCommand.cmake

@@ -0,0 +1,18 @@
+include(FetchContent)
+
+# Verify COMMAND keyword is recognised after various *_COMMAND options
+FetchContent_Declare(multiCommand
+  DOWNLOAD_COMMAND  "${CMAKE_COMMAND}" -E echo "download 1"
+           COMMAND  "${CMAKE_COMMAND}" -E echo "download 2"
+  UPDATE_COMMAND    "${CMAKE_COMMAND}" -E echo "update 1"
+         COMMAND    "${CMAKE_COMMAND}" -E echo "update 2"
+  PATCH_COMMAND     "${CMAKE_COMMAND}" -E echo "patch 1"
+        COMMAND     "${CMAKE_COMMAND}" -E echo "patch 2"
+)
+
+# Force all steps to be re-run by removing timestamps, scripts, etc. from any
+# previous run
+file(REMOVE_RECURSE "${FETCHCONTENT_BASE_DIR}/multiCommand-subbuild")
+
+set(FETCHCONTENT_QUIET FALSE)
+FetchContent_MakeAvailable(multiCommand)

+ 1 - 0
Tests/RunCMake/FetchContent/RunCMakeTest.cmake

@@ -2,6 +2,7 @@ include(RunCMake)
 
 unset(RunCMake_TEST_NO_CLEAN)
 
+run_cmake(MultiCommand)
 run_cmake(MissingDetails)
 run_cmake(DirectIgnoresDetails)
 run_cmake(FirstDetailsWin)