1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 22:37:30 +08:00

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
This commit is contained in:
Ben Boeckel
2020-05-05 09:44:54 -04:00
parent 615129f3eb
commit 0199dd9f1b
8 changed files with 52 additions and 0 deletions

View File

@@ -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>")

View File

@@ -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 ()

View File

@@ -0,0 +1,2 @@
.*configured with: first
.*second_cache_arg is undefined

View File

@@ -0,0 +1,2 @@
.*configured with: first
.*configured again with: second

View File

@@ -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}\"
)
")

View File

@@ -0,0 +1,3 @@
file(WRITE "${RunCMake_TEST_BINARY_DIR}/data.cmake"
"set(cache_args -Dcache_arg:STRING=first)
")

View File

@@ -0,0 +1,3 @@
file(WRITE "${RunCMake_TEST_BINARY_DIR}/data.cmake"
"set(cache_args -Dsecond_cache_arg:STRING=second)
")

View File

@@ -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")