diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2020-05-05 09:44:54 -0400 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2020-05-12 10:34:23 -0400 |
commit | 0199dd9f1b48b47ae63547ffe737ea9169caf511 (patch) | |
tree | a7a7c504915a027a699a92b098a553fd2e554a64 | |
parent | 615129f3ebd308abeaaee7f5f0689e7fc4616c28 (diff) | |
download | cmake-0199dd9f1b48b47ae63547ffe737ea9169caf511.tar.gz |
ExternalProject: expose _ep_cache_args_script to the caller
This is needed so that the caller can add a dependency on the cache
file.
Fixes: #20668
8 files changed, 52 insertions, 0 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index a9448e5e08..12a91b32fe 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -2974,6 +2974,10 @@ function(_ep_extract_configure_command var name) endif() _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}") list(APPEND cmd "-C${_ep_cache_args_script}") + _ep_replace_location_tags(${name} _ep_cache_args_script) + set(_ep_cache_args_script + "${_ep_cache_args_script}" + PARENT_SCOPE) endif() list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>") diff --git a/Tests/RunCMake/BuildDepends/ExternalProject/CMakeLists.txt b/Tests/RunCMake/BuildDepends/ExternalProject/CMakeLists.txt new file mode 100644 index 0000000000..57a0f6e6b7 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProject/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.12) +project(External NONE) + +if (DEFINED cache_arg) + message("configured with: ${cache_arg}") +else () + message("cache_arg is undefined") +endif () + +if (DEFINED second_cache_arg) + message("configured again with: ${second_cache_arg}") +else () + message("second_cache_arg is undefined") +endif () diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build1-stdout.txt b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build1-stdout.txt new file mode 100644 index 0000000000..fea7fd972a --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build1-stdout.txt @@ -0,0 +1,2 @@ +.*configured with: first +.*second_cache_arg is undefined diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build2-stdout.txt b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build2-stdout.txt new file mode 100644 index 0000000000..e19e743d68 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs-build2-stdout.txt @@ -0,0 +1,2 @@ +.*configured with: first +.*configured again with: second diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.cmake b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.cmake new file mode 100644 index 0000000000..fe69426119 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.cmake @@ -0,0 +1,19 @@ +include("${CMAKE_CURRENT_BINARY_DIR}/data.cmake") + +include(ExternalProject) +ExternalProject_add(external + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/ExternalProject" + CMAKE_CACHE_ARGS + ${cache_args} + BUILD_COMMAND "" + INSTALL_COMMAND "") + +set(cache_args_path "<TMP_DIR>/external-cache-$<CONFIG>.cmake") +set(cmake_cache_path "<BINARY_DIR>/CMakeCache.txt") +_ep_replace_location_tags(external cache_args_path cmake_cache_path) + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake" CONTENT " +set(check_pairs + \"${cmake_cache_path}|${cache_args_path}\" +) +") diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step1.cmake b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step1.cmake new file mode 100644 index 0000000000..57c7ab7bcb --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/data.cmake" + "set(cache_args -Dcache_arg:STRING=first) +") diff --git a/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step2.cmake b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step2.cmake new file mode 100644 index 0000000000..cbb79e136f --- /dev/null +++ b/Tests/RunCMake/BuildDepends/ExternalProjectCacheArgs.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/data.cmake" + "set(cache_args -Dsecond_cache_arg:STRING=second) +") diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 14ae2439b7..e4d71776ad 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -46,6 +46,11 @@ endif() run_BuildDepends(Custom-Symbolic-and-Byproduct) run_BuildDepends(Custom-Always) +set(RunCMake_TEST_OUTPUT_MERGE_save "${RunCMake_TEST_OUTPUT_MERGE}") +set(RunCMake_TEST_OUTPUT_MERGE 1) +run_BuildDepends(ExternalProjectCacheArgs) +set(RunCMake_TEST_OUTPUT_MERGE "${RunCMake_TEST_OUTPUT_MERGE_save}") + # Test header dependencies with a build tree underneath a source tree. set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource") set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource/build") |