diff options
5 files changed, 36 insertions, 6 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 30176bb..db19691 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1707,7 +1707,7 @@ function(_ep_command_line_to_initial_cache var args force) endif() endforeach() # Catch the final line of the args - if(setArg) + if(NOT "${setArg}" STREQUAL "") string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") string(APPEND script_initial_cache "\n${setArg}") endif() @@ -2750,12 +2750,22 @@ function(_ep_extract_configure_command var name) get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS) get_property(cmake_cache_default_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS) - if(cmake_cache_args OR cmake_cache_default_args) + set(has_cmake_cache_args 0) + if(NOT "${cmake_cache_args}" STREQUAL "") + set(has_cmake_cache_args 1) + endif() + + set(has_cmake_cache_default_args 0) + if(NOT "${cmake_cache_default_args}" STREQUAL "") + set(has_cmake_cache_default_args 1) + endif() + + if(has_cmake_cache_args OR has_cmake_cache_default_args) set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake") - if(cmake_cache_args) + if(has_cmake_cache_args) _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1) endif() - if(cmake_cache_default_args) + if(has_cmake_cache_default_args) _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0) endif() _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}") diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake index cb48be7..cc5521e 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake @@ -24,3 +24,12 @@ if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) set(RunCMake_TEST_FAILED "Expected forced TEST_LIST argument") return() endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache") + return() +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected forced TEST_OPTIONAL argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake index dcb992d..a583e31 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake @@ -8,4 +8,5 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" CMAKE_CACHE_ARGS "-DFOO:STRING=$<1:BAR>$<0:BAD>" - "-DTEST_LIST:STRING=A;B;C") + "-DTEST_LIST:STRING=A;B;C" + "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND") diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake index c84932d..2bef56e 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake @@ -24,3 +24,12 @@ if("${CMAKE_MATCH_0}" MATCHES FORCE) set(RunCMake_TEST_FAILED "Expected not forced TEST_LIST argument") return() endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache") + return() +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected not forced TEST_OPTIONAL argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake index 4b4b40e..d388315 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake @@ -8,4 +8,5 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" CMAKE_CACHE_DEFAULT_ARGS "-DFOO:STRING=$<1:BAR>$<0:BAD>" - "-DTEST_LIST:STRING=A;B;C") + "-DTEST_LIST:STRING=A;B;C" + "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND") |