diff options
author | Brad King <brad.king@kitware.com> | 2024-06-03 13:07:35 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-06-03 13:07:46 (GMT) |
commit | 640a167d0360e6be10fbeadd80c5c28a14e3ea5c (patch) | |
tree | 84845745b0c95eca0e09f8473a39fb1375bab734 /Tests/RunCMake | |
parent | 833b880906090f7359def32a515c7de75100f4c8 (diff) | |
parent | 0cc1b550ddc7cb677ce45fd54f6bbb92f3ff2268 (diff) | |
download | CMake-640a167d0360e6be10fbeadd80c5c28a14e3ea5c.zip CMake-640a167d0360e6be10fbeadd80c5c28a14e3ea5c.tar.gz CMake-640a167d0360e6be10fbeadd80c5c28a14e3ea5c.tar.bz2 |
Merge topic 'ep-disable-source-changes'
0cc1b550dd ExternalProject,FetchContent: Avoid CMAKE_DISABLE_SOURCE_CHANGES error
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9569
Diffstat (limited to 'Tests/RunCMake')
4 files changed, 37 insertions, 0 deletions
diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 44c6f74..3c7cd68 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -21,6 +21,7 @@ run_cmake(TLSVersionBadEnv) run_cmake(NoOptions) run_cmake(SourceEmpty) run_cmake(SourceMissing) +run_cmake(SourceDirExisting) run_cmake(CMAKE_CACHE_ARGS) run_cmake(CMAKE_CACHE_DEFAULT_ARGS) run_cmake(CMAKE_CACHE_mix) diff --git a/Tests/RunCMake/ExternalProject/SourceDirExisting.cmake b/Tests/RunCMake/ExternalProject/SourceDirExisting.cmake new file mode 100644 index 0000000..761bb8e --- /dev/null +++ b/Tests/RunCMake/ExternalProject/SourceDirExisting.cmake @@ -0,0 +1,16 @@ +# We're providing a pre-existing source directory. Make sure we don't trigger +# an error if the undocumented but used-in-the-wild CMAKE_DISABLE_SOURCE_CHANGES +# variable is set. +set(CMAKE_DISABLE_SOURCE_CHANGES TRUE) + +include(ExternalProject) + +ExternalProject_Add(source_dir_existing + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Foo" + DOWNLOAD_COMMAND "${CMAKE_COMMAND}" -E echo "Download command executed" + UPDATE_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + TEST_COMMAND "" + INSTALL_COMMAND "" +) diff --git a/Tests/RunCMake/FetchContent/DisableSourceChanges.cmake b/Tests/RunCMake/FetchContent/DisableSourceChanges.cmake new file mode 100644 index 0000000..a144005 --- /dev/null +++ b/Tests/RunCMake/FetchContent/DisableSourceChanges.cmake @@ -0,0 +1,18 @@ +cmake_policy(SET CMP0168 NEW) + +# Undocumented variable used to catch attempts to write to anywhere under the +# source directory that isn't under the build directory. In order for this +# code path to be checked for direct population mode, we need a non-empty +# download, update, or patch command so that the population code path is used. +# Custom commands might not write to the source directory and instead just +# print messages or other non-modifying tasks, like is done here. +set(CMAKE_DISABLE_SOURCE_CHANGES TRUE) + +include(FetchContent) + +FetchContent_Declare( + WithProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject # This exists + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Download command executed" +) +FetchContent_MakeAvailable(WithProject) diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake index 72a458c..d0ec638 100644 --- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake @@ -106,3 +106,5 @@ run_cmake_command(ScriptMode-direct -DCMP0168=NEW -P ${CMAKE_CURRENT_LIST_DIR}/ScriptMode.cmake ) + +run_cmake(DisableSourceChanges) |