Merge topic 'ep-url-special-characters'
54cb65b197
ExternalProject: Prevent URL list-splitting on special charactersaab6be9aad
ExternalProject: Catch empty REMOTE or LOCAL earliere72791ecf6
ExternalProject: Update foreach() calls to use IN LISTS and IN ITEMS873b2ad2eb
ExternalProject: Remove N^2 add_dependencies() calls Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9193
This commit is contained in:
commit
09c5fb83dd
@ -1518,6 +1518,21 @@ function(_ep_write_downloadfile_script
|
|||||||
netrc
|
netrc
|
||||||
netrc_file
|
netrc_file
|
||||||
)
|
)
|
||||||
|
if("x${REMOTE}" STREQUAL "x")
|
||||||
|
message(FATAL_ERROR "REMOTE can't be empty")
|
||||||
|
endif()
|
||||||
|
if("x${LOCAL}" STREQUAL "x")
|
||||||
|
message(FATAL_ERROR "LOCAL can't be empty")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# REMOTE could contain special characters that parse as separate arguments.
|
||||||
|
# Things like parentheses are legitimate characters in a URL, but would be
|
||||||
|
# seen as the start of a new unquoted argument by the cmake language parser.
|
||||||
|
# Avoid those special cases by preparing quoted strings for direct inclusion
|
||||||
|
# in the foreach() call that iterates over the set of URLs in REMOTE.
|
||||||
|
set(REMOTE "[====[${REMOTE}]====]")
|
||||||
|
string(REPLACE ";" "]====] [====[" REMOTE "${REMOTE}")
|
||||||
|
|
||||||
if(timeout)
|
if(timeout)
|
||||||
set(TIMEOUT_ARGS TIMEOUT ${timeout})
|
set(TIMEOUT_ARGS TIMEOUT ${timeout})
|
||||||
set(TIMEOUT_MSG "${timeout} seconds")
|
set(TIMEOUT_MSG "${timeout} seconds")
|
||||||
@ -1599,7 +1614,7 @@ function(_ep_write_downloadfile_script
|
|||||||
|
|
||||||
set(HTTP_HEADERS_ARGS "")
|
set(HTTP_HEADERS_ARGS "")
|
||||||
if(NOT http_headers STREQUAL "")
|
if(NOT http_headers STREQUAL "")
|
||||||
foreach(header ${http_headers})
|
foreach(header IN LISTS http_headers)
|
||||||
string(PREPEND HTTP_HEADERS_ARGS
|
string(PREPEND HTTP_HEADERS_ARGS
|
||||||
"HTTPHEADER \"${header}\"\n "
|
"HTTPHEADER \"${header}\"\n "
|
||||||
)
|
)
|
||||||
@ -1724,7 +1739,7 @@ function(_ep_set_directories name)
|
|||||||
|
|
||||||
# Apply defaults and convert to absolute paths.
|
# Apply defaults and convert to absolute paths.
|
||||||
set(places stamp download source binary install tmp)
|
set(places stamp download source binary install tmp)
|
||||||
foreach(var ${places})
|
foreach(var IN LISTS places)
|
||||||
string(TOUPPER "${var}" VAR)
|
string(TOUPPER "${var}" VAR)
|
||||||
get_property(${var}_dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
|
get_property(${var}_dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
|
||||||
if(NOT ${var}_dir)
|
if(NOT ${var}_dir)
|
||||||
@ -1796,9 +1811,9 @@ endfunction()
|
|||||||
#
|
#
|
||||||
macro(_ep_replace_location_tags target_name)
|
macro(_ep_replace_location_tags target_name)
|
||||||
set(vars ${ARGN})
|
set(vars ${ARGN})
|
||||||
foreach(var ${vars})
|
foreach(var IN LISTS vars)
|
||||||
if(${var})
|
if(var)
|
||||||
foreach(dir
|
foreach(dir IN ITEMS
|
||||||
SOURCE_DIR
|
SOURCE_DIR
|
||||||
SOURCE_SUBDIR
|
SOURCE_SUBDIR
|
||||||
BINARY_DIR
|
BINARY_DIR
|
||||||
@ -1828,7 +1843,7 @@ function(_ep_command_line_to_initial_cache
|
|||||||
if(force)
|
if(force)
|
||||||
set(forceArg "FORCE")
|
set(forceArg "FORCE")
|
||||||
endif()
|
endif()
|
||||||
foreach(line ${args})
|
foreach(line IN LISTS args)
|
||||||
if("${line}" MATCHES "^-D(.*)")
|
if("${line}" MATCHES "^-D(.*)")
|
||||||
set(line "${CMAKE_MATCH_1}")
|
set(line "${CMAKE_MATCH_1}")
|
||||||
if(NOT "${setArg}" STREQUAL "")
|
if(NOT "${setArg}" STREQUAL "")
|
||||||
@ -1884,7 +1899,7 @@ endfunction()
|
|||||||
|
|
||||||
|
|
||||||
function(ExternalProject_Get_Property name)
|
function(ExternalProject_Get_Property name)
|
||||||
foreach(var ${ARGN})
|
foreach(var IN LISTS ARGN)
|
||||||
string(TOUPPER "${var}" VAR)
|
string(TOUPPER "${var}" VAR)
|
||||||
get_property(is_set TARGET ${name} PROPERTY _EP_${VAR} SET)
|
get_property(is_set TARGET ${name} PROPERTY _EP_${VAR} SET)
|
||||||
if(NOT is_set)
|
if(NOT is_set)
|
||||||
@ -2372,7 +2387,7 @@ function(ExternalProject_Add_StepTargets name)
|
|||||||
endif()
|
endif()
|
||||||
message(AUTHOR_WARNING "${_cmp0114_warning}")
|
message(AUTHOR_WARNING "${_cmp0114_warning}")
|
||||||
endif()
|
endif()
|
||||||
foreach(step ${steps})
|
foreach(step IN LISTS steps)
|
||||||
_ep_step_add_target("${name}" "${step}" "${no_deps}")
|
_ep_step_add_target("${name}" "${step}" "${no_deps}")
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
@ -2553,7 +2568,7 @@ function(ExternalProject_Add_Step name step)
|
|||||||
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||||
if(_isMultiConfig)
|
if(_isMultiConfig)
|
||||||
_ep_get_configuration_subdir_genex(cfgdir)
|
_ep_get_configuration_subdir_genex(cfgdir)
|
||||||
foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
|
foreach(cfg IN LISTS CMAKE_CONFIGURATION_TYPES)
|
||||||
string(REPLACE "${cfgdir}" "/${cfg}"
|
string(REPLACE "${cfgdir}" "/${cfg}"
|
||||||
stamp_file_config "${stamp_file}"
|
stamp_file_config "${stamp_file}"
|
||||||
)
|
)
|
||||||
@ -2628,7 +2643,7 @@ function(ExternalProject_Add_Step name step)
|
|||||||
PROPERTY EP_STEP_TARGETS
|
PROPERTY EP_STEP_TARGETS
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
foreach(st ${step_targets})
|
foreach(st IN LISTS step_targets)
|
||||||
if("${st}" STREQUAL "${step}")
|
if("${st}" STREQUAL "${step}")
|
||||||
_ep_step_add_target("${name}" "${step}" "FALSE")
|
_ep_step_add_target("${name}" "${step}" "FALSE")
|
||||||
break()
|
break()
|
||||||
@ -2675,7 +2690,7 @@ function(ExternalProject_Add_Step name step)
|
|||||||
message(AUTHOR_WARNING "${_cmp0114_warning}")
|
message(AUTHOR_WARNING "${_cmp0114_warning}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
foreach(st ${independent_step_targets})
|
foreach(st IN LISTS independent_step_targets)
|
||||||
if("${st}" STREQUAL "${step}")
|
if("${st}" STREQUAL "${step}")
|
||||||
_ep_step_add_target("${name}" "${step}" "TRUE")
|
_ep_step_add_target("${name}" "${step}" "TRUE")
|
||||||
break()
|
break()
|
||||||
@ -2741,17 +2756,15 @@ function(ExternalProject_Add_StepDependencies name step)
|
|||||||
# Always add file-level dependency, but add target-level dependency
|
# Always add file-level dependency, but add target-level dependency
|
||||||
# only if the target exists for that step.
|
# only if the target exists for that step.
|
||||||
_ep_get_step_stampfile(${name} ${step} stamp_file)
|
_ep_get_step_stampfile(${name} ${step} stamp_file)
|
||||||
foreach(dep ${dependencies})
|
foreach(dep IN LISTS dependencies)
|
||||||
add_custom_command(APPEND
|
add_custom_command(APPEND
|
||||||
OUTPUT ${stamp_file}
|
OUTPUT ${stamp_file}
|
||||||
DEPENDS ${dep}
|
DEPENDS ${dep}
|
||||||
)
|
)
|
||||||
if(TARGET ${name}-${step})
|
|
||||||
foreach(dep ${dependencies})
|
|
||||||
add_dependencies(${name}-${step} ${dep})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
if(TARGET ${name}-${step})
|
||||||
|
add_dependencies(${name}-${step} ${dependencies})
|
||||||
|
endif()
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@ -3079,7 +3092,7 @@ hash=${hash}
|
|||||||
|
|
||||||
list(LENGTH url url_list_length)
|
list(LENGTH url url_list_length)
|
||||||
if(NOT "${url_list_length}" STREQUAL "1")
|
if(NOT "${url_list_length}" STREQUAL "1")
|
||||||
foreach(entry ${url})
|
foreach(entry IN LISTS url)
|
||||||
if(NOT "${entry}" MATCHES "^[a-z]+://")
|
if(NOT "${entry}" MATCHES "^[a-z]+://")
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"At least one entry of URL is a path (invalid in a list)"
|
"At least one entry of URL is a path (invalid in a list)"
|
||||||
|
@ -71,14 +71,6 @@ function(sleep_before_download attempt)
|
|||||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep "${sleep_seconds}")
|
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep "${sleep_seconds}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if("@LOCAL@" STREQUAL "")
|
|
||||||
message(FATAL_ERROR "LOCAL can't be empty")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("@REMOTE@" STREQUAL "")
|
|
||||||
message(FATAL_ERROR "REMOTE can't be empty")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(EXISTS "@LOCAL@")
|
if(EXISTS "@LOCAL@")
|
||||||
check_file_hash(has_hash hash_is_good)
|
check_file_hash(has_hash hash_is_good)
|
||||||
if(has_hash)
|
if(has_hash)
|
||||||
@ -115,7 +107,7 @@ foreach(i RANGE ${retry_number})
|
|||||||
if(status_code IN_LIST download_retry_codes)
|
if(status_code IN_LIST download_retry_codes)
|
||||||
sleep_before_download(${i})
|
sleep_before_download(${i})
|
||||||
endif()
|
endif()
|
||||||
foreach(url @REMOTE@)
|
foreach(url IN ITEMS @REMOTE@)
|
||||||
if(NOT url IN_LIST skip_url_list)
|
if(NOT url IN_LIST skip_url_list)
|
||||||
message(STATUS "Using src='${url}'")
|
message(STATUS "Using src='${url}'")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user