diff options
author | Brad King <brad.king@kitware.com> | 2022-02-02 13:17:25 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-02-02 13:17:51 (GMT) |
commit | 1e1e04db758685a9114daad7894d4a7e073ccdbf (patch) | |
tree | 97b75bc9786c97a93d19a91773de9bd0a1971cf2 /Tests | |
parent | 9e76b4cde6817fb63193362823333a0c7ecb910b (diff) | |
parent | d3477eba067c22f7b2986caa573754fd2b84c8ef (diff) | |
download | CMake-1e1e04db758685a9114daad7894d4a7e073ccdbf.zip CMake-1e1e04db758685a9114daad7894d4a7e073ccdbf.tar.gz CMake-1e1e04db758685a9114daad7894d4a7e073ccdbf.tar.bz2 |
Merge topic 'ep-redownload-on-SOURCE_DIR-change'
d3477eba06 ExternalProject: Rerun download on SOURCE_DIR change
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6926
Diffstat (limited to 'Tests')
4 files changed, 45 insertions, 5 deletions
diff --git a/Tests/RunCMake/ExternalProject/MultiCommand.cmake b/Tests/RunCMake/ExternalProject/MultiCommand.cmake index 0849658..3e8bd94 100644 --- a/Tests/RunCMake/ExternalProject/MultiCommand.cmake +++ b/Tests/RunCMake/ExternalProject/MultiCommand.cmake @@ -1,5 +1,12 @@ include(ExternalProject) +# Force all steps to be re-run by removing timestamps from any previous run. +# This has to happen before we call ExternalProject_Add() because that command +# writes some files to the stamp directory for recording repository details. +set(STAMP_DIR ${CMAKE_BINARY_DIR}/multiCommand-prefix/src/multiCommand-stamp) +file(REMOVE_RECURSE "${STAMP_DIR}") +file(MAKE_DIRECTORY "${STAMP_DIR}") + # Verify COMMAND keyword is recognized after various *_COMMAND options ExternalProject_Add(multiCommand DOWNLOAD_COMMAND "${CMAKE_COMMAND}" -E echo "download 1" @@ -17,8 +24,3 @@ ExternalProject_Add(multiCommand INSTALL_COMMAND "${CMAKE_COMMAND}" -E echo "install 1" COMMAND "${CMAKE_COMMAND}" -E echo "install 2" ) - -# Force all steps to be re-run by removing timestamps from any previous run -ExternalProject_Get_Property(multiCommand STAMP_DIR) -file(REMOVE_RECURSE "${STAMP_DIR}") -file(MAKE_DIRECTORY "${STAMP_DIR}") diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 48f8b23..fde384f 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -61,6 +61,23 @@ if(NOT XCODE_VERSION OR XCODE_VERSION VERSION_LESS 12) endif() run_steps_CMP0114(NEW) +function(__ep_test_source_dir_change) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SourceDirChange-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(SourceDirChange) + run_cmake_command(SourceDirChange-build1 ${CMAKE_COMMAND} --build .) + # Because some file systems have timestamps with only one second resolution, + # we have to ensure we don't re-run the configure stage too quickly after the + # first build. Otherwise, the modified RepositoryInfo.txt files the next + # configure writes might still have the same timestamp as the previous one. + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) + run_cmake_command(SourceDirChange-change ${CMAKE_COMMAND} -DSOURCE_DIR_CHANGE=YES .) + run_cmake_command(SourceDirChange-build2 ${CMAKE_COMMAND} --build .) +endfunction() +__ep_test_source_dir_change() + # Run both cmake and build steps. We always do a clean before the # build to ensure that the download step re-runs each time. function(__ep_test_with_build testName) diff --git a/Tests/RunCMake/ExternalProject/SourceDirChange-build2-stdout.txt b/Tests/RunCMake/ExternalProject/SourceDirChange-build2-stdout.txt new file mode 100644 index 0000000..22dac9d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/SourceDirChange-build2-stdout.txt @@ -0,0 +1 @@ +Download command executed diff --git a/Tests/RunCMake/ExternalProject/SourceDirChange.cmake b/Tests/RunCMake/ExternalProject/SourceDirChange.cmake new file mode 100644 index 0000000..62213cd --- /dev/null +++ b/Tests/RunCMake/ExternalProject/SourceDirChange.cmake @@ -0,0 +1,20 @@ +include(ExternalProject) + +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/first") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/second") + +if("${SOURCE_DIR_CHANGE}" STREQUAL "") + set(source_dir first) +else() + set(source_dir second) +endif() + +ExternalProject_Add(source_dir_change + SOURCE_DIR "${CMAKE_BINARY_DIR}/${source_dir}" + DOWNLOAD_COMMAND "${CMAKE_COMMAND}" -E echo "Download command executed" + UPDATE_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + TEST_COMMAND "" + INSTALL_COMMAND "" +) |