ExternalProject: Fix cache generation when last args ends with "-NOTFOUND"

This commit is contained in:
Jean-Christophe Fillion-Robin
2018-03-10 04:29:50 -05:00
committed by Brad King
parent c5541cf0da
commit 7ad981c8f7
5 changed files with 36 additions and 6 deletions

View File

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