diff options
author | Brad King <brad.king@kitware.com> | 2011-01-11 20:52:36 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2011-01-11 20:52:36 (GMT) |
commit | 9a81f0dd0cd45715456b4d298403833b22832cf0 (patch) | |
tree | 282d0c90da626631e7ad51780b1fdf943f2e8620 /Modules | |
parent | c39abc24111ecdfc1e8d6cb29c7687430e9aaca0 (diff) | |
parent | d67a5134471dadb8b9578d598002832114a171b4 (diff) | |
download | CMake-9a81f0dd0cd45715456b4d298403833b22832cf0.zip CMake-9a81f0dd0cd45715456b4d298403833b22832cf0.tar.gz CMake-9a81f0dd0cd45715456b4d298403833b22832cf0.tar.bz2 |
Merge topic 'ep-fix-substitutions'
d67a513 ExternalProject: Replace location tags in CMAKE_CACHE_ARGS
d7a87b5 Merge branch 'ep-log-output-under-vs' into ep-fix-substitutions
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/ExternalProject.cmake | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 1f8844e..3de6b7e 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -550,7 +550,24 @@ function(_ep_set_directories name) endforeach() endfunction(_ep_set_directories) -function(_ep_write_initial_cache script_filename args) + +# IMPORTANT: this MUST be a macro and not a function because of the +# in-place replacements that occur in each ${var} +# +macro(_ep_replace_location_tags target_name) + set(vars ${ARGN}) + foreach(var ${vars}) + if(${var}) + foreach(dir SOURCE_DIR BINARY_DIR INSTALL_DIR TMP_DIR) + get_property(val TARGET ${target_name} PROPERTY _EP_${dir}) + string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}") + endforeach() + endif() + endforeach() +endmacro() + + +function(_ep_write_initial_cache target_name script_filename args) # Write out values into an initial cache, that will be passed to CMake with -C set(script_initial_cache "") set(regex "^([^:]+):([^=]+)=(.*)$") @@ -584,6 +601,8 @@ function(_ep_write_initial_cache script_filename args) set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)") set(script_initial_cache "${script_initial_cache}\n${setArg}") endif() + # Replace location tags. + _ep_replace_location_tags(${target_name} script_initial_cache) # 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") @@ -864,14 +883,7 @@ function(ExternalProject_Add_Step name step) endif() # Replace location tags. - foreach(var comment command work_dir) - if(${var}) - foreach(dir SOURCE_DIR BINARY_DIR INSTALL_DIR TMP_DIR) - get_property(val TARGET ${name} PROPERTY _EP_${dir}) - string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}") - endforeach() - endif() - endforeach() + _ep_replace_location_tags(${name} comment command work_dir) # Custom comment? get_property(comment_set TARGET ${name} PROPERTY _EP_${step}_COMMENT SET) @@ -1271,7 +1283,7 @@ function(_ep_add_configure_command name) get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS) if(cmake_cache_args) 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(${name} "${_ep_cache_args_script}" "${cmake_cache_args}") list(APPEND cmd "-C${_ep_cache_args_script}") endif() |