summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-12 17:50:45 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-12 17:50:45 (GMT)
commitbab82b0935e543ceceddf8e339dd026d201692fe (patch)
tree0117eaf5284e838b635d371efa01c3a3bd94a723
parentc6e8442e4c433ed943cda33b9d446f4383af0a88 (diff)
parent7ad981c8f705ef563b8ca0bf3da98f6902fa56fe (diff)
downloadCMake-bab82b0935e543ceceddf8e339dd026d201692fe.zip
CMake-bab82b0935e543ceceddf8e339dd026d201692fe.tar.gz
CMake-bab82b0935e543ceceddf8e339dd026d201692fe.tar.bz2
Merge branch 'ep-support-passing-var-ending-with-notfound' into release-3.11
Merge-request: !1838
-rw-r--r--Modules/ExternalProject.cmake18
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake9
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake3
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake9
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake3
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")