Escape file write expansion, and build up lists.
Escaped the @var@ in the file writes - this was being expanded at file write and so not causing a reconfigure at the right time. I also took care of build up lists of lists in the variables, especially important for things like MPI_EXTRA_LIBRARY. Added some error checking, and use the tmp_dir for initial cache file.
This commit is contained in:
parent
68cd3fe038
commit
b316087c09
|
@ -554,23 +554,36 @@ function(_ep_write_initial_cache script_filename args)
|
||||||
# Write out values into an initial cache, that will be passed to CMake with -C
|
# Write out values into an initial cache, that will be passed to CMake with -C
|
||||||
set(script_initial_cache "")
|
set(script_initial_cache "")
|
||||||
set(regex "^([^:]+):([^=]+)=(.*)$")
|
set(regex "^([^:]+):([^=]+)=(.*)$")
|
||||||
|
set(setArg "")
|
||||||
foreach(line ${args})
|
foreach(line ${args})
|
||||||
|
if("${line}" MATCHES "^-D")
|
||||||
|
if(setArg)
|
||||||
|
# This is required to build up lists in variables, or complete an entry
|
||||||
|
set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)")
|
||||||
|
set(script_initial_cache "${script_initial_cache}\n${setArg}")
|
||||||
|
set(accumulator "")
|
||||||
|
set(setArg "")
|
||||||
|
endif()
|
||||||
string(REGEX REPLACE "^-D" "" line ${line})
|
string(REGEX REPLACE "^-D" "" line ${line})
|
||||||
if("${line}" MATCHES "${regex}")
|
if("${line}" MATCHES "${regex}")
|
||||||
string(REGEX MATCH "${regex}" match "${line}")
|
string(REGEX MATCH "${regex}" match "${line}")
|
||||||
set(name "${CMAKE_MATCH_1}")
|
set(name "${CMAKE_MATCH_1}")
|
||||||
set(type "${CMAKE_MATCH_2}")
|
set(type "${CMAKE_MATCH_2}")
|
||||||
set(value "${CMAKE_MATCH_3}")
|
set(value "${CMAKE_MATCH_3}")
|
||||||
set(setArg "set(${name} \"${value}\" CACHE ${type} \"Initial cache\" FORCE)")
|
set(setArg "set(${name} \"${value}")
|
||||||
set(script_initial_cache "${script_initial_cache}\n${setArg}")
|
else()
|
||||||
|
message(WARNING "Line '${line}' does not match regex. Ignoring.")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Assume this is a list to append to the last var
|
||||||
|
set(accumulator "${accumulator};${line}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
# Write out the initial cache file to the location specified.
|
# Write out the initial cache file to the location specified.
|
||||||
if(NOT EXISTS "${script_filename}.in")
|
if(NOT EXISTS "${script_filename}.in")
|
||||||
file(WRITE "${script_filename}.in" "@script_initial_cache@\n")
|
file(WRITE "${script_filename}.in" "\@script_initial_cache\@\n")
|
||||||
endif()
|
endif()
|
||||||
configure_file("${script_filename}.in" "${script_filename}")
|
configure_file("${script_filename}.in" "${script_filename}")
|
||||||
|
|
||||||
endfunction(_ep_write_initial_cache)
|
endfunction(_ep_write_initial_cache)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1251,7 +1264,7 @@ function(_ep_add_configure_command name)
|
||||||
# If there are any CMAKE_CACHE_ARGS, write an initial cache and use it
|
# If there are any CMAKE_CACHE_ARGS, write an initial cache and use it
|
||||||
get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS)
|
get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS)
|
||||||
if(cmake_cache_args)
|
if(cmake_cache_args)
|
||||||
set(_ep_cache_args_script "${CMAKE_CURRENT_BINARY_DIR}/${name}-cache.cmake")
|
set(_ep_cache_args_script "${tmp_dir}/${name}-cache.cmake")
|
||||||
_ep_write_initial_cache("${_ep_cache_args_script}" "${cmake_cache_args}")
|
_ep_write_initial_cache("${_ep_cache_args_script}" "${cmake_cache_args}")
|
||||||
list(APPEND cmd "-C${_ep_cache_args_script}")
|
list(APPEND cmd "-C${_ep_cache_args_script}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -1274,7 +1287,7 @@ function(_ep_add_configure_command name)
|
||||||
# Fixes issue http://public.kitware.com/Bug/view.php?id=10258
|
# Fixes issue http://public.kitware.com/Bug/view.php?id=10258
|
||||||
#
|
#
|
||||||
if(NOT EXISTS ${tmp_dir}/${name}-cfgcmd.txt.in)
|
if(NOT EXISTS ${tmp_dir}/${name}-cfgcmd.txt.in)
|
||||||
file(WRITE ${tmp_dir}/${name}-cfgcmd.txt.in "cmd='@cmd@'\n")
|
file(WRITE ${tmp_dir}/${name}-cfgcmd.txt.in "cmd='\@cmd\@'\n")
|
||||||
endif()
|
endif()
|
||||||
configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt)
|
configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt)
|
||||||
list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt)
|
list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt)
|
||||||
|
|
Loading…
Reference in New Issue