summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject.cmake
diff options
context:
space:
mode:
authorMarcus D. Hanwell <marcus.hanwell@kitware.com>2010-12-10 22:41:41 (GMT)
committerMarcus D. Hanwell <marcus.hanwell@kitware.com>2010-12-10 22:41:41 (GMT)
commit68cd3fe038471b5a60d396eac141a69414b3064d (patch)
tree14d63d6db3f30aedb861e7a2021869026923ef39 /Modules/ExternalProject.cmake
parentb90e9f9c3a61294b40bd45cada70c24d35bc705d (diff)
downloadCMake-68cd3fe038471b5a60d396eac141a69414b3064d.zip
CMake-68cd3fe038471b5a60d396eac141a69414b3064d.tar.gz
CMake-68cd3fe038471b5a60d396eac141a69414b3064d.tar.bz2
Added CMAKE_CACHE_ARGS to ExternalProject.
On Windows the limit for command line arguments is 8192 characters, and this was limiting longer paths with some of our more nested projects such as Library. Placing the -D arguments into CMAKE_CACHE_ARGS will write out an initial cache file, that will be passed to CMake with a -C argument as the initial cache. By forcing the cache variables we preserve the existing behavior with -D, to change the values of cache variables in our inner projects.
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r--Modules/ExternalProject.cmake33
1 files changed, 33 insertions, 0 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 1be6cfd..c575a73 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -32,6 +32,7 @@
# [CMAKE_COMMAND /.../cmake] # Specify alternative cmake executable
# [CMAKE_GENERATOR gen] # Specify generator for native build
# [CMAKE_ARGS args...] # Arguments to CMake command line
+# [CMAKE_CACHE_ARGS args...] # Initial cache arguments, of the form -Dvar:string=on
# #--Build step-----------------
# [BINARY_DIR dir] # Specify build dir location
# [BUILD_COMMAND cmd...] # Command to drive the native build
@@ -549,6 +550,29 @@ function(_ep_set_directories name)
endforeach()
endfunction(_ep_set_directories)
+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 "^([^:]+):([^=]+)=(.*)$")
+ 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}")
+ 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")
+ endif()
+ configure_file("${script_filename}.in" "${script_filename}")
+
+endfunction(_ep_write_initial_cache)
+
function(ExternalProject_Get_Property name)
foreach(var ${ARGN})
@@ -1224,6 +1248,14 @@ function(_ep_add_configure_command name)
get_property(cmake_args TARGET ${name} PROPERTY _EP_CMAKE_ARGS)
list(APPEND cmd ${cmake_args})
+ # 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")
+ _ep_write_initial_cache("${_ep_cache_args_script}" "${cmake_cache_args}")
+ list(APPEND cmd "-C${_ep_cache_args_script}")
+ endif()
+
get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
if(cmake_generator)
list(APPEND cmd "-G${cmake_generator}" "${source_dir}")
@@ -1246,6 +1278,7 @@ function(_ep_add_configure_command name)
endif()
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 ${_ep_cache_args_script})
get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE)
if(log)