summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject.cmake
diff options
context:
space:
mode:
authorMarcus D. Hanwell <marcus.hanwell@kitware.com>2010-12-11 01:03:58 (GMT)
committerMarcus D. Hanwell <marcus.hanwell@kitware.com>2010-12-11 17:11:27 (GMT)
commitb316087c095e23e131bf2ccf5eb7110b35df0e29 (patch)
treeff08ebe2b3ed6961328c20f9885fc918d966be2b /Modules/ExternalProject.cmake
parent68cd3fe038471b5a60d396eac141a69414b3064d (diff)
downloadCMake-b316087c095e23e131bf2ccf5eb7110b35df0e29.zip
CMake-b316087c095e23e131bf2ccf5eb7110b35df0e29.tar.gz
CMake-b316087c095e23e131bf2ccf5eb7110b35df0e29.tar.bz2
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.
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r--Modules/ExternalProject.cmake37
1 files changed, 25 insertions, 12 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index c575a73..542dbc2 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -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
set(script_initial_cache "")
set(regex "^([^:]+):([^=]+)=(.*)$")
+ set(setArg "")
foreach(line ${args})
- string(REGEX REPLACE "^-D" "" line ${line})
- if("${line}" MATCHES "${regex}")
- string(REGEX MATCH "${regex}" match "${line}")
- set(name "${CMAKE_MATCH_1}")
- set(type "${CMAKE_MATCH_2}")
- set(value "${CMAKE_MATCH_3}")
- set(setArg "set(${name} \"${value}\" CACHE ${type} \"Initial cache\" FORCE)")
- set(script_initial_cache "${script_initial_cache}\n${setArg}")
+ 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})
+ if("${line}" MATCHES "${regex}")
+ string(REGEX MATCH "${regex}" match "${line}")
+ set(name "${CMAKE_MATCH_1}")
+ set(type "${CMAKE_MATCH_2}")
+ set(value "${CMAKE_MATCH_3}")
+ set(setArg "set(${name} \"${value}")
+ 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()
endforeach()
# Write out the initial cache file to the location specified.
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()
configure_file("${script_filename}.in" "${script_filename}")
-
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
get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_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}")
list(APPEND cmd "-C${_ep_cache_args_script}")
endif()
@@ -1274,7 +1287,7 @@ function(_ep_add_configure_command name)
# Fixes issue http://public.kitware.com/Bug/view.php?id=10258
#
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()
configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt)
list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt)