summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r--Modules/ExternalProject.cmake55
1 files changed, 36 insertions, 19 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 2ff18fc..44bf957 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -69,8 +69,8 @@ Create custom targets to build projects in external trees
URL of mercurial repo
``HG_TAG <tag>``
Mercurial branch name, commit id or tag
- ``URL /.../src.tgz``
- Full path or URL of source
+ ``URL /.../src.tgz [/.../src.tgz]...``
+ Full path or URL(s) of source. Multiple URLs are allowed as mirrors.
``URL_HASH ALGO=value``
Hash of file at URL
``URL_MD5 md5``
@@ -993,6 +993,7 @@ endif()
#
message(STATUS \"extracting... [analysis]\")
file(GLOB contents \"\${ut_dir}/*\")
+list(REMOVE_ITEM contents \"\${ut_dir}/.DS_Store\")
list(LENGTH contents n)
if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
set(contents \"\${ut_dir}\")
@@ -1117,8 +1118,8 @@ function(_ep_command_line_to_initial_cache var args force)
set(line "${CMAKE_MATCH_1}")
if(setArg)
# This is required to build up lists in variables, or complete an entry
- set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
- set(script_initial_cache "${script_initial_cache}\n${setArg}")
+ string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
+ string(APPEND script_initial_cache "\n${setArg}")
set(accumulator "")
set(setArg "")
endif()
@@ -1132,13 +1133,13 @@ function(_ep_command_line_to_initial_cache var args force)
endif()
else()
# Assume this is a list to append to the last var
- set(accumulator "${accumulator};${line}")
+ string(APPEND accumulator ";${line}")
endif()
endforeach()
# Catch the final line of the args
if(setArg)
- set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
- set(script_initial_cache "${script_initial_cache}\n${setArg}")
+ string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
+ string(APPEND script_initial_cache "\n${setArg}")
endif()
set(${var} ${script_initial_cache} PARENT_SCOPE)
endfunction()
@@ -1332,16 +1333,16 @@ endif()
foreach(arg IN LISTS command)
if("x${arg}" STREQUAL "xCOMMAND")
if(NOT "x${cmd}" STREQUAL "x")
- set(code "${code}set(command \"${cmd}\")${code_execute_process}")
+ string(APPEND code "set(command \"${cmd}\")${code_execute_process}")
endif()
set(cmd "")
set(sep "")
else()
- set(cmd "${cmd}${sep}${arg}")
+ string(APPEND cmd "${sep}${arg}")
set(sep ";")
endif()
endforeach()
- set(code "${code}set(command \"${cmd}\")${code_execute_process}")
+ string(APPEND code "set(command \"${cmd}\")${code_execute_process}")
file(GENERATE OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" CONTENT "${code}")
set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake)
endif()
@@ -1667,7 +1668,7 @@ function(_ep_add_download_command name)
get_property(fname TARGET ${name} PROPERTY _EP_DOWNLOAD_NAME)
# TODO: Perhaps file:// should be copied to download dir before extraction.
- string(REGEX REPLACE "^file://" "" url "${url}")
+ string(REGEX REPLACE "file://" "" url "${url}")
set(depends)
set(comment)
@@ -1861,6 +1862,19 @@ function(_ep_add_download_command name)
@ONLY
)
list(APPEND depends ${stamp_dir}/${name}-urlinfo.txt)
+
+ list(LENGTH url url_list_length)
+ if(NOT "${url_list_length}" STREQUAL "1")
+ foreach(entry ${url})
+ if(NOT "${entry}" MATCHES "^[a-z]+://")
+ message(FATAL_ERROR "At least one entry of URL is a path (invalid in a list)")
+ endif()
+ endforeach()
+ if("x${fname}" STREQUAL "x")
+ list(GET url 0 fname)
+ endif()
+ endif()
+
if(IS_DIRECTORY "${url}")
get_filename_component(abs_dir "${url}" ABSOLUTE)
set(comment "Performing download step (DIR copy) for '${name}'")
@@ -1871,16 +1885,19 @@ function(_ep_add_download_command name)
if("${url}" MATCHES "^[a-z]+://")
# TODO: Should download and extraction be different steps?
if("x${fname}" STREQUAL "x")
- string(REGEX MATCH "[^/\\?]*$" fname "${url}")
+ set(fname "${url}")
endif()
- if(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
- string(REGEX MATCH "([^/\\?]+(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip))/.*$" match_result "${url}")
+ if("${fname}" MATCHES [[([^/\?#]+(\.|=)(7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip))([/?#].*)?$]])
set(fname "${CMAKE_MATCH_1}")
- endif()
- if (no_extract)
- get_filename_component(fname "${url}" NAME)
- elseif(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
- message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}")
+ elseif(no_extract)
+ get_filename_component(fname "${fname}" NAME)
+ else()
+ # Fall back to a default file name. The actual file name does not
+ # matter because it is used only internally and our extraction tool
+ # inspects the file content directly. If it turns out the wrong URL
+ # was given that will be revealed during the build which is an easier
+ # place for users to diagnose than an error here anyway.
+ set(fname "archive.tar")
endif()
string(REPLACE ";" "-" fname "${fname}")
set(file ${download_dir}/${fname})