ExternalProject: Switch download, update and patch to use _EP_ vars

This refactoring prepares for the download, update, and
patch steps being called directly from FetchContent instead
of always being in a sub-build. When there is no sub-build,
there will be no targets to read properties from. This commit
moves the information to _EP_... variables, which will always
be readable.

Issue: #21703
This commit is contained in:
Craig Scott
2024-05-13 20:22:12 +10:00
parent 0ccc8e340d
commit 462e583267

View File

@@ -1317,22 +1317,23 @@ macro(_ep_get_hash_regex out_var)
set(${out_var} "^(${${out_var}})=([0-9A-Fa-f]+)$") set(${out_var} "^(${${out_var}})=([0-9A-Fa-f]+)$")
endmacro() endmacro()
function(_ep_parse_arguments function(_ep_parse_arguments_to_vars
f f
keywords keywords
name name
ns ns
args args
) )
# Transfer the arguments to this function into target properties for the # Transfer the arguments into variables in the calling scope.
# new custom target we just added so that we can set up all the build steps
# correctly based on target properties.
#
# Because some keywords can be repeated, we can't use cmake_parse_arguments(). # Because some keywords can be repeated, we can't use cmake_parse_arguments().
# Instead, we loop through ARGN and consider the namespace starting with an # Instead, we loop through the args and consider the namespace starting with
# upper-case letter followed by at least two more upper-case letters, # an upper-case letter followed by at least two more upper-case letters,
# numbers or underscores to be keywords. # numbers or underscores to be keywords.
foreach(key IN LISTS keywords)
unset(${ns}${key})
endforeach()
set(key) set(key)
foreach(arg IN LISTS args) foreach(arg IN LISTS args)
@@ -1350,17 +1351,7 @@ function(_ep_parse_arguments
if(is_value) if(is_value)
if(key) if(key)
# Value # Value
if(NOT arg STREQUAL "") list(APPEND ${ns}${key} "${arg}")
set_property(TARGET ${name} APPEND PROPERTY ${ns}${key} "${arg}")
else()
get_property(have_key TARGET ${name} PROPERTY ${ns}${key} SET)
if(have_key)
get_property(value TARGET ${name} PROPERTY ${ns}${key})
set_property(TARGET ${name} PROPERTY ${ns}${key} "${value};${arg}")
else()
set_property(TARGET ${name} PROPERTY ${ns}${key} "${arg}")
endif()
endif()
else() else()
# Missing Keyword # Missing Keyword
message(AUTHOR_WARNING message(AUTHOR_WARNING
@@ -1371,6 +1362,50 @@ function(_ep_parse_arguments
set(key "${arg}") set(key "${arg}")
endif() endif()
endforeach() endforeach()
foreach(key IN LISTS keywords)
if(DEFINED ${ns}${key})
set(${ns}${key} "${${ns}${key}}" PARENT_SCOPE)
else()
unset(${ns}${key} PARENT_SCOPE)
endif()
endforeach()
endfunction()
# NOTE: This cannot be a macro because that will evaluate anything that looks
# like a CMake variable in any of the args.
function(_ep_parse_arguments
f
keywords
name
ns
args
)
_ep_parse_arguments_to_vars(
"${f}"
"${keywords}"
${name}
${ns}
"${args}"
)
foreach(key IN LISTS keywords)
if(DEFINED ${ns}${key})
set(${ns}${key} "${${ns}${key}}" PARENT_SCOPE)
else()
unset(${ns}${key} PARENT_SCOPE)
endif()
endforeach()
# Transfer the arguments to the target as target properties. These are
# read by the various steps, potentially from different scopes.
foreach(key IN LISTS keywords)
if(DEFINED ${ns}${key})
set_property(TARGET ${name} PROPERTY ${ns}${key} "${${ns}${key}}")
endif()
endforeach()
endfunction() endfunction()
@@ -1381,8 +1416,11 @@ define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED)
define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED) define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED)
function(_ep_get_tls_version name tls_version_var) function(_ep_get_tls_version name tls_version_var)
# Note that the arguments are assumed to have already been parsed and have
# been translated into variables with the prefix _EP_... by a call to
# ep_parse_arguments() or ep_parse_arguments_to_vars().
set(tls_version_regex "^1\\.[0-3]$") set(tls_version_regex "^1\\.[0-3]$")
get_property(tls_version TARGET ${name} PROPERTY _EP_TLS_VERSION) set(tls_version "${_EP_TLS_VERSION}")
if(NOT "x${tls_version}" STREQUAL "x") if(NOT "x${tls_version}" STREQUAL "x")
if(NOT tls_version MATCHES "${tls_version_regex}") if(NOT tls_version MATCHES "${tls_version_regex}")
message(FATAL_ERROR "TLS_VERSION '${tls_version}' not known") message(FATAL_ERROR "TLS_VERSION '${tls_version}' not known")
@@ -1402,7 +1440,10 @@ function(_ep_get_tls_version name tls_version_var)
endfunction() endfunction()
function(_ep_get_tls_verify name tls_verify_var) function(_ep_get_tls_verify name tls_verify_var)
get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) # Note that the arguments are assumed to have already been parsed and have
# been translated into variables with the prefix _EP_... by a call to
# ep_parse_arguments() or ep_parse_arguments_to_vars().
set(tls_verify "${_EP_TLS_VERIFY}")
if("x${tls_verify}" STREQUAL "x") if("x${tls_verify}" STREQUAL "x")
if(NOT "x${CMAKE_TLS_VERIFY}" STREQUAL "x") if(NOT "x${CMAKE_TLS_VERIFY}" STREQUAL "x")
set(tls_verify "${CMAKE_TLS_VERIFY}") set(tls_verify "${CMAKE_TLS_VERIFY}")
@@ -1414,7 +1455,10 @@ function(_ep_get_tls_verify name tls_verify_var)
endfunction() endfunction()
function(_ep_get_tls_cainfo name tls_cainfo_var) function(_ep_get_tls_cainfo name tls_cainfo_var)
get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) # Note that the arguments are assumed to have already been parsed and have
# been translated into variables with the prefix _EP_... by a call to
# ep_parse_arguments() or ep_parse_arguments_to_vars().
set(tls_cainfo "${_EP_TLS_CAINFO}")
if("x${tls_cainfo}" STREQUAL "x" AND DEFINED CMAKE_TLS_CAINFO) if("x${tls_cainfo}" STREQUAL "x" AND DEFINED CMAKE_TLS_CAINFO)
set(tls_cainfo "${CMAKE_TLS_CAINFO}") set(tls_cainfo "${CMAKE_TLS_CAINFO}")
endif() endif()
@@ -1422,7 +1466,10 @@ function(_ep_get_tls_cainfo name tls_cainfo_var)
endfunction() endfunction()
function(_ep_get_netrc name netrc_var) function(_ep_get_netrc name netrc_var)
get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) # Note that the arguments are assumed to have already been parsed and have
# been translated into variables with the prefix _EP_... by a call to
# ep_parse_arguments() or ep_parse_arguments_to_vars().
set(netrc "${_EP_NETRC}")
if("x${netrc}" STREQUAL "x" AND DEFINED CMAKE_NETRC) if("x${netrc}" STREQUAL "x" AND DEFINED CMAKE_NETRC)
set(netrc "${CMAKE_NETRC}") set(netrc "${CMAKE_NETRC}")
endif() endif()
@@ -1430,7 +1477,10 @@ function(_ep_get_netrc name netrc_var)
endfunction() endfunction()
function(_ep_get_netrc_file name netrc_file_var) function(_ep_get_netrc_file name netrc_file_var)
get_property(netrc_file TARGET ${name} PROPERTY _EP_NETRC_FILE) # Note that the arguments are assumed to have already been parsed and have
# been translated into variables with the prefix _EP_... by a call to
# ep_parse_arguments() or ep_parse_arguments_to_vars().
set(netrc_file "${_EP_NETRC_FILE}")
if("x${netrc_file}" STREQUAL "x" AND DEFINED CMAKE_NETRC_FILE) if("x${netrc_file}" STREQUAL "x" AND DEFINED CMAKE_NETRC_FILE)
set(netrc_file "${CMAKE_NETRC_FILE}") set(netrc_file "${CMAKE_NETRC_FILE}")
endif() endif()
@@ -1835,6 +1885,7 @@ function(_ep_set_directories name)
endif() endif()
file(TO_CMAKE_PATH "${${var}_dir}" ${var}_dir) file(TO_CMAKE_PATH "${${var}_dir}" ${var}_dir)
set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}") set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
set(_EP_${VAR}_DIR "${${var}_dir}" PARENT_SCOPE)
endforeach() endforeach()
# Special case for default log directory based on stamp directory. # Special case for default log directory based on stamp directory.
@@ -1847,10 +1898,12 @@ function(_ep_set_directories name)
endif() endif()
file(TO_CMAKE_PATH "${log_dir}" log_dir) file(TO_CMAKE_PATH "${log_dir}" log_dir)
set_property(TARGET ${name} PROPERTY _EP_LOG_DIR "${log_dir}") set_property(TARGET ${name} PROPERTY _EP_LOG_DIR "${log_dir}")
set(_EP_LOG_DIR "${log_dir}" PARENT_SCOPE)
get_property(source_subdir TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR) get_property(source_subdir TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR)
if(NOT source_subdir) if(NOT source_subdir)
set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "") set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "")
set(_EP_SOURCE_SUBDIR "" PARENT_SCOPE)
elseif(IS_ABSOLUTE "${source_subdir}") elseif(IS_ABSOLUTE "${source_subdir}")
message(FATAL_ERROR message(FATAL_ERROR
"External project ${name} has non-relative SOURCE_SUBDIR!" "External project ${name} has non-relative SOURCE_SUBDIR!"
@@ -1860,6 +1913,7 @@ function(_ep_set_directories name)
# behaves as expected. # behaves as expected.
file(TO_CMAKE_PATH "${source_subdir}" source_subdir) file(TO_CMAKE_PATH "${source_subdir}" source_subdir)
set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "/${source_subdir}") set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "/${source_subdir}")
set(_EP_SOURCE_SUBDIR "/${source_subdir}" PARENT_SCOPE)
endif() endif()
if(build_in_source) if(build_in_source)
get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR) get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR)
@@ -1867,10 +1921,12 @@ function(_ep_set_directories name)
set_property(TARGET ${name} PROPERTY set_property(TARGET ${name} PROPERTY
_EP_BINARY_DIR "${source_dir}/${source_subdir}" _EP_BINARY_DIR "${source_dir}/${source_subdir}"
) )
set(_EP_BINARY_DIR "${source_dir}/${source_subdir}" PARENT_SCOPE)
else() else()
set_property(TARGET ${name} PROPERTY set_property(TARGET ${name} PROPERTY
_EP_BINARY_DIR "${source_dir}" _EP_BINARY_DIR "${source_dir}"
) )
set(_EP_BINARY_DIR "${source_dir}" PARENT_SCOPE)
endif() endif()
endif() endif()
@@ -2877,22 +2933,16 @@ function(_ep_is_dir_empty dir empty_var)
endfunction() endfunction()
function(_ep_get_git_submodules_recurse git_submodules_recurse) function(_ep_get_git_submodules_recurse git_submodules_recurse)
# Checks for GIT_SUBMODULES_RECURSE property. Default is ON, which sets # Checks for GIT_SUBMODULES_RECURSE argument. Default is ON, which sets
# git_submodules_recurse output variable to "--recursive". Otherwise, the # git_submodules_recurse output variable to "--recursive". Otherwise, the
# output variable is set to an empty value "". # output variable is set to an empty value "".
get_property(git_submodules_recurse_set # Note that the arguments are assumed to have already been parsed and have
TARGET ${name} # been translated into variables with the prefix _EP_... by a call to
PROPERTY _EP_GIT_SUBMODULES_RECURSE # ep_parse_arguments() or ep_parse_arguments_to_vars().
SET if(NOT DEFINED _EP_GIT_SUBMODULES_RECURSE)
)
if(NOT git_submodules_recurse_set)
set(recurseFlag "--recursive") set(recurseFlag "--recursive")
else() else()
get_property(git_submodules_recurse_value if(_EP_GIT_SUBMODULES_RECURSE)
TARGET ${name}
PROPERTY _EP_GIT_SUBMODULES_RECURSE
)
if(git_submodules_recurse_value)
set(recurseFlag "--recursive") set(recurseFlag "--recursive")
else() else()
set(recurseFlag "") set(recurseFlag "")
@@ -2911,21 +2961,24 @@ endfunction()
function(_ep_add_download_command name) function(_ep_add_download_command name)
ExternalProject_Get_Property(${name} # The various _EP_... variables mentioned here and throughout this function
source_dir # are expected to already have been set by the caller via a call to
stamp_dir # _ep_parse_arguments() or ep_parse_arguments_to_vars(). Other variables
download_dir # with different names are assigned to for historical reasons only to keep
tmp_dir # the code more readable and minimize change.
)
get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET) set(source_dir "${_EP_SOURCE_DIR}")
get_property(cmd TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND) set(stamp_dir "${_EP_STAMP_DIR}")
get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY) set(download_dir "${_EP_DOWNLOAD_DIR}")
get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY) set(tmp_dir "${_EP_TMP_DIR}")
get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY)
get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY ) set(cmd "${_EP_DOWNLOAD_COMMAND}")
get_property(url TARGET ${name} PROPERTY _EP_URL) set(cvs_repository "${_EP_CVS_REPOSITORY}")
get_property(fname TARGET ${name} PROPERTY _EP_DOWNLOAD_NAME) set(svn_repository "${_EP_SVN_REPOSITORY}")
set(git_repository "${_EP_GIT_REPOSITORY}")
set(hg_repository "${_EP_HG_REPOSITORY}")
set(url "${_EP_URL}")
set(fname "${_EP_DOWNLOAD_NAME}")
# TODO: Perhaps file:// should be copied to download dir before extraction. # TODO: Perhaps file:// should be copied to download dir before extraction.
string(REGEX REPLACE "file://" "" url "${url}") string(REGEX REPLACE "file://" "" url "${url}")
@@ -2935,7 +2988,7 @@ function(_ep_add_download_command name)
set(work_dir) set(work_dir)
set(extra_repo_info) set(extra_repo_info)
if(cmd_set) if(DEFINED _EP_DOWNLOAD_COMMAND)
set(work_dir ${download_dir}) set(work_dir ${download_dir})
set(method custom) set(method custom)
elseif(cvs_repository) elseif(cvs_repository)
@@ -2945,12 +2998,12 @@ function(_ep_add_download_command name)
message(FATAL_ERROR "error: could not find cvs for checkout of ${name}") message(FATAL_ERROR "error: could not find cvs for checkout of ${name}")
endif() endif()
get_target_property(cvs_module ${name} _EP_CVS_MODULE) set(cvs_module "${_EP_CVS_MODULE}")
if(NOT cvs_module) if(NOT cvs_module)
message(FATAL_ERROR "error: no CVS_MODULE") message(FATAL_ERROR "error: no CVS_MODULE")
endif() endif()
get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG) set(cvs_tag "${_EP_CVS_TAG}")
get_filename_component(src_name "${source_dir}" NAME) get_filename_component(src_name "${source_dir}" NAME)
get_filename_component(work_dir "${source_dir}" PATH) get_filename_component(work_dir "${source_dir}" PATH)
set(comment "Performing download step (CVS checkout) for '${name}'") set(comment "Performing download step (CVS checkout) for '${name}'")
@@ -2970,14 +3023,11 @@ function(_ep_add_download_command name)
message(FATAL_ERROR "error: could not find svn for checkout of ${name}") message(FATAL_ERROR "error: could not find svn for checkout of ${name}")
endif() endif()
get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION) set(svn_revision "${_EP_SVN_REVISION}")
get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) set(svn_username "${_EP_SVN_USERNAME}")
get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) set(svn_password "${_EP_SVN_PASSWORD}")
get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) set(svn_trust_cert "${_EP_SVN_TRUST_CERT}")
get_property(uses_terminal set(uses_terminal "${_EP_USES_TERMINAL_DOWNLOAD}")
TARGET ${name}
PROPERTY _EP_USES_TERMINAL_DOWNLOAD
)
# The --trust-server-cert option requires --non-interactive # The --trust-server-cert option requires --non-interactive
if(uses_terminal AND NOT svn_trust_cert) if(uses_terminal AND NOT svn_trust_cert)
set(svn_interactive_args "") set(svn_interactive_args "")
@@ -2989,10 +3039,10 @@ function(_ep_add_download_command name)
get_filename_component(work_dir "${source_dir}" PATH) get_filename_component(work_dir "${source_dir}" PATH)
set(comment "Performing download step (SVN checkout) for '${name}'") set(comment "Performing download step (SVN checkout) for '${name}'")
set(svn_user_pw_args "") set(svn_user_pw_args "")
if(DEFINED svn_username) if(DEFINED _EP_SVN_USERNAME)
set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}") set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}")
endif() endif()
if(DEFINED svn_password) if(DEFINED _EP_SVN_PASSWORD)
set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}") set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}")
endif() endif()
if(svn_trust_cert) if(svn_trust_cert)
@@ -3022,33 +3072,29 @@ function(_ep_add_download_command name)
_ep_get_git_submodules_recurse(git_submodules_recurse) _ep_get_git_submodules_recurse(git_submodules_recurse)
get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG) set(git_tag "${_EP_GIT_TAG}")
if(NOT git_tag) if(NOT git_tag)
set(git_tag "master") set(git_tag "master")
endif() endif()
set(git_init_submodules TRUE) set(git_init_submodules TRUE)
get_property(git_submodules_set if(DEFINED _EP_GIT_SUBMODULES)
TARGET ${name} set(git_submodules "${_EP_GIT_SUBMODULES}")
PROPERTY _EP_GIT_SUBMODULES SET if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
)
if(git_submodules_set)
get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
set(git_init_submodules FALSE) set(git_init_submodules FALSE)
endif() endif()
endif() endif()
get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME) set(git_remote_name "${_EP_GIT_REMOTE_NAME}")
if(NOT git_remote_name) if(NOT git_remote_name)
set(git_remote_name "origin") set(git_remote_name "origin")
endif() endif()
_ep_get_tls_version(${name} tls_version) _ep_get_tls_version(${name} tls_version)
_ep_get_tls_verify(${name} tls_verify) _ep_get_tls_verify(${name} tls_verify)
get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW) set(git_shallow "${_EP_GIT_SHALLOW}")
get_property(git_progress TARGET ${name} PROPERTY _EP_GIT_PROGRESS) set(git_progress "${_EP_GIT_PROGRESS}")
get_property(git_config TARGET ${name} PROPERTY _EP_GIT_CONFIG) set(git_config "${_EP_GIT_CONFIG}")
# If git supports it, make checkouts quiet when checking out a git hash. # If git supports it, make checkouts quiet when checking out a git hash.
# This avoids the very noisy detached head message. # This avoids the very noisy detached head message.
@@ -3108,7 +3154,7 @@ CMP0097=${_EP_CMP0097}
message(FATAL_ERROR "error: could not find hg for clone of ${name}") message(FATAL_ERROR "error: could not find hg for clone of ${name}")
endif() endif()
get_property(hg_tag TARGET ${name} PROPERTY _EP_HG_TAG) set(hg_tag "${_EP_HG_TAG}")
if(NOT hg_tag) if(NOT hg_tag)
set(hg_tag "tip") set(hg_tag "tip")
endif() endif()
@@ -3145,7 +3191,7 @@ CMP0097=${_EP_CMP0097}
elseif(url) elseif(url)
set(method url) set(method url)
get_filename_component(work_dir "${source_dir}" PATH) get_filename_component(work_dir "${source_dir}" PATH)
get_property(hash TARGET ${name} PROPERTY _EP_URL_HASH) set(hash "${_EP_URL_HASH}")
_ep_get_hash_regex(_ep_hash_regex) _ep_get_hash_regex(_ep_hash_regex)
if(hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}") if(hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}")
_ep_get_hash_algos(_ep_hash_algos) _ep_get_hash_algos(_ep_hash_algos)
@@ -3158,7 +3204,7 @@ CMP0097=${_EP_CMP0097}
"and value is a hex string." "and value is a hex string."
) )
endif() endif()
get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5) set(md5 "${_EP_URL_MD5}")
if(md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}") if(md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}")
message(FATAL_ERROR message(FATAL_ERROR
"URL_MD5 is set to\n" "URL_MD5 is set to\n"
@@ -3196,10 +3242,7 @@ hash=${hash}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir} COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir}
) )
else() else()
get_property(no_extract set(no_extract "${_EP_DOWNLOAD_NO_EXTRACT}")
TARGET "${name}"
PROPERTY _EP_DOWNLOAD_NO_EXTRACT
)
string(APPEND extra_repo_info "no_extract=${no_extract}\n") string(APPEND extra_repo_info "no_extract=${no_extract}\n")
if("${url}" MATCHES "^[a-z]+://") if("${url}" MATCHES "^[a-z]+://")
# TODO: Should download and extraction be different steps? # TODO: Should download and extraction be different steps?
@@ -3221,23 +3264,17 @@ hash=${hash}
endif() endif()
string(REPLACE ";" "-" fname "${fname}") string(REPLACE ";" "-" fname "${fname}")
set(file ${download_dir}/${fname}) set(file ${download_dir}/${fname})
get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) set(timeout "${_EP_TIMEOUT}")
get_property(inactivity_timeout set(inactivity_timeout "${_EP_INACTIVITY_TIMEOUT}")
TARGET ${name} set(no_progress "${_EP_DOWNLOAD_NO_PROGRESS}")
PROPERTY _EP_INACTIVITY_TIMEOUT
)
get_property(no_progress
TARGET ${name}
PROPERTY _EP_DOWNLOAD_NO_PROGRESS
)
_ep_get_tls_version(${name} tls_version) _ep_get_tls_version(${name} tls_version)
_ep_get_tls_verify(${name} tls_verify) _ep_get_tls_verify(${name} tls_verify)
_ep_get_tls_cainfo(${name} tls_cainfo) _ep_get_tls_cainfo(${name} tls_cainfo)
_ep_get_netrc(${name} netrc) _ep_get_netrc(${name} netrc)
_ep_get_netrc_file(${name} netrc_file) _ep_get_netrc_file(${name} netrc_file)
get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME) set(http_username "${_EP_HTTP_USERNAME}")
get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) set(http_password "${_EP_HTTP_PASSWORD}")
get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) set(http_headers "${_EP_HTTP_HEADER}")
set(download_script "${stamp_dir}/download-${name}.cmake") set(download_script "${stamp_dir}/download-${name}.cmake")
_ep_write_downloadfile_script( _ep_write_downloadfile_script(
"${download_script}" "${download_script}"
@@ -3287,11 +3324,9 @@ hash=${hash}
) )
endif() endif()
list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake) list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake)
get_target_property(extract_timestamp ${name} set(extract_timestamp "${_EP_DOWNLOAD_EXTRACT_TIMESTAMP}")
_EP_DOWNLOAD_EXTRACT_TIMESTAMP
)
if(no_extract) if(no_extract)
if(NOT extract_timestamp STREQUAL "extract_timestamp-NOTFOUND") if(DEFINED _EP_DOWNLOAD_EXTRACT_TIMESTAMP)
message(FATAL_ERROR message(FATAL_ERROR
"Cannot specify DOWNLOAD_EXTRACT_TIMESTAMP when using " "Cannot specify DOWNLOAD_EXTRACT_TIMESTAMP when using "
"DOWNLOAD_NO_EXTRACT TRUE" "DOWNLOAD_NO_EXTRACT TRUE"
@@ -3299,7 +3334,7 @@ hash=${hash}
endif() endif()
set_property(TARGET ${name} PROPERTY _EP_DOWNLOADED_FILE ${file}) set_property(TARGET ${name} PROPERTY _EP_DOWNLOADED_FILE ${file})
else() else()
if(extract_timestamp STREQUAL "extract_timestamp-NOTFOUND") if(NOT DEFINED _EP_DOWNLOAD_EXTRACT_TIMESTAMP)
# Default depends on policy CMP0135 # Default depends on policy CMP0135
if(_EP_CMP0135 STREQUAL "") if(_EP_CMP0135 STREQUAL "")
message(AUTHOR_WARNING message(AUTHOR_WARNING
@@ -3368,21 +3403,13 @@ hash=${hash}
@ONLY @ONLY
) )
get_property(log if(_EP_LOG_DOWNLOAD)
TARGET ${name}
PROPERTY _EP_LOG_DOWNLOAD
)
if(log)
set(log LOG 1) set(log LOG 1)
else() else()
set(log "") set(log "")
endif() endif()
get_property(uses_terminal if(_EP_USES_TERMINAL_DOWNLOAD)
TARGET ${name}
PROPERTY _EP_USES_TERMINAL_DOWNLOAD
)
if(uses_terminal)
set(uses_terminal USES_TERMINAL 1) set(uses_terminal USES_TERMINAL 1)
else() else()
set(uses_terminal "") set(uses_terminal "")
@@ -3407,16 +3434,11 @@ hash=${hash}
endfunction() endfunction()
function(_ep_get_update_disconnected var name) function(_ep_get_update_disconnected var name)
get_property(update_disconnected_set # Note that the arguments are assumed to have already been parsed and have
TARGET ${name} # been translated into variables with the prefix _EP_... by a call to
PROPERTY _EP_UPDATE_DISCONNECTED # ep_parse_arguments() or ep_parse_arguments_to_vars().
SET if(DEFINED _EP_UPDATE_DISCONNECTED)
) set(update_disconnected "${_EP_UPDATE_DISCONNECTED}")
if(update_disconnected_set)
get_property(update_disconnected
TARGET ${name}
PROPERTY _EP_UPDATE_DISCONNECTED
)
else() else()
get_property(update_disconnected get_property(update_disconnected
DIRECTORY DIRECTORY
@@ -3427,14 +3449,21 @@ function(_ep_get_update_disconnected var name)
endfunction() endfunction()
function(_ep_add_update_command name) function(_ep_add_update_command name)
ExternalProject_Get_Property(${name} source_dir stamp_dir tmp_dir) # The various _EP_... variables mentioned here and throughout this function
# are expected to already have been set by the caller via a call to
# _ep_parse_arguments() or ep_parse_arguments_to_vars(). Other variables
# with different names are assigned to for historical reasons only to keep
# the code more readable and minimize change.
get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET) set(source_dir "${_EP_SOURCE_DIR}")
get_property(cmd TARGET ${name} PROPERTY _EP_UPDATE_COMMAND) set(stamp_dir "${_EP_STAMP_DIR}")
get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY) set(tmp_dir "${_EP_TMP_DIR}")
get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY)
get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY) set(cmd "${_EP_UPDATE_COMMAND}")
get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY ) set(cvs_repository "${_EP_CVS_REPOSITORY}")
set(svn_repository "${_EP_SVN_REPOSITORY}")
set(git_repository "${_EP_GIT_REPOSITORY}")
set(hg_repository "${_EP_HG_REPOSITORY}")
_ep_get_update_disconnected(update_disconnected ${name}) _ep_get_update_disconnected(update_disconnected ${name})
@@ -3443,7 +3472,7 @@ function(_ep_add_update_command name)
set(always) set(always)
set(file_deps) set(file_deps)
if(cmd_set) if(DEFINED _EP_UPDATE_COMMAND)
set(work_dir ${source_dir}) set(work_dir ${source_dir})
if(NOT "x${cmd}" STREQUAL "x") if(NOT "x${cmd}" STREQUAL "x")
set(always 1) set(always 1)
@@ -3454,7 +3483,7 @@ function(_ep_add_update_command name)
endif() endif()
set(work_dir ${source_dir}) set(work_dir ${source_dir})
set(comment "Performing update step (CVS update) for '${name}'") set(comment "Performing update step (CVS update) for '${name}'")
get_property(cvs_tag TARGET ${name} PROPERTY _EP_CVS_TAG) set(cvs_tag "${_EP_CVS_TAG}")
set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q up -dP ${cvs_tag}) set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q up -dP ${cvs_tag})
set(always 1) set(always 1)
elseif(svn_repository) elseif(svn_repository)
@@ -3463,11 +3492,11 @@ function(_ep_add_update_command name)
endif() endif()
set(work_dir ${source_dir}) set(work_dir ${source_dir})
set(comment "Performing update step (SVN update) for '${name}'") set(comment "Performing update step (SVN update) for '${name}'")
get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION) set(svn_revision "${_EP_SVN_REVISION}")
get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) set(svn_username "${_EP_SVN_USERNAME}")
get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) set(svn_password "${_EP_SVN_PASSWORD}")
get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) set(svn_trust_cert "${_EP_SVN_TRUST_CERT}")
get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_UPDATE) set(uses_terminal "${_EP_USES_TERMINAL_UPDATE}")
# The --trust-server-cert option requires --non-interactive # The --trust-server-cert option requires --non-interactive
if(uses_terminal AND NOT svn_trust_cert) if(uses_terminal AND NOT svn_trust_cert)
set(svn_interactive_args "") set(svn_interactive_args "")
@@ -3506,42 +3535,25 @@ function(_ep_add_update_command name)
set(comment "Performing update step for '${name}'") set(comment "Performing update step for '${name}'")
set(comment_disconnected "Performing disconnected update step for '${name}'") set(comment_disconnected "Performing disconnected update step for '${name}'")
get_property(git_tag set(git_tag "${_EP_GIT_TAG}")
TARGET ${name}
PROPERTY _EP_GIT_TAG
)
if(NOT git_tag) if(NOT git_tag)
set(git_tag "master") set(git_tag "master")
endif() endif()
get_property(git_remote_name set(git_remote_name "${_EP_GIT_REMOTE_NAME}")
TARGET ${name}
PROPERTY _EP_GIT_REMOTE_NAME
)
if(NOT git_remote_name) if(NOT git_remote_name)
set(git_remote_name "origin") set(git_remote_name "origin")
endif() endif()
set(git_init_submodules TRUE) set(git_init_submodules TRUE)
get_property(git_submodules_set if(DEFINED _EP_GIT_SUBMODULES)
TARGET ${name} set(git_submodules "${_EP_GIT_SUBMODULES}")
PROPERTY _EP_GIT_SUBMODULES if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
SET
)
if(git_submodules_set)
get_property(git_submodules
TARGET ${name}
PROPERTY _EP_GIT_SUBMODULES
)
if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
set(git_init_submodules FALSE) set(git_init_submodules FALSE)
endif() endif()
endif() endif()
get_property(git_update_strategy set(git_update_strategy "${_EP_GIT_REMOTE_UPDATE_STRATEGY}")
TARGET ${name}
PROPERTY _EP_GIT_REMOTE_UPDATE_STRATEGY
)
if(NOT git_update_strategy) if(NOT git_update_strategy)
set(git_update_strategy "${CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY}") set(git_update_strategy "${CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY}")
endif() endif()
@@ -3588,10 +3600,7 @@ function(_ep_add_update_command name)
set(comment "Performing update step (hg pull) for '${name}'") set(comment "Performing update step (hg pull) for '${name}'")
set(comment_disconnected "Performing disconnected update step for '${name}'") set(comment_disconnected "Performing disconnected update step for '${name}'")
get_property(hg_tag set(hg_tag "${_EP_HG_TAG}")
TARGET ${name}
PROPERTY _EP_HG_TAG
)
if(NOT hg_tag) if(NOT hg_tag)
set(hg_tag "tip") set(hg_tag "tip")
endif() endif()
@@ -3629,21 +3638,13 @@ Update to Mercurial >= 2.1.1.
@ONLY @ONLY
) )
get_property(log if(_EP_LOG_UPDATE)
TARGET ${name}
PROPERTY _EP_LOG_UPDATE
)
if(log)
set(log LOG 1) set(log LOG 1)
else() else()
set(log "") set(log "")
endif() endif()
get_property(uses_terminal if(_EP_USES_TERMINAL_UPDATE)
TARGET ${name}
PROPERTY _EP_USES_TERMINAL_UPDATE
)
if(uses_terminal)
set(uses_terminal USES_TERMINAL 1) set(uses_terminal USES_TERMINAL 1)
else() else()
set(uses_terminal "") set(uses_terminal "")
@@ -3694,14 +3695,19 @@ endfunction()
function(_ep_add_patch_command name) function(_ep_add_patch_command name)
ExternalProject_Get_Property(${name} source_dir stamp_dir) # The various _EP_... variables mentioned here and throughout this function
# are expected to already have been set by the caller via a call to
# _ep_parse_arguments() or ep_parse_arguments_to_vars(). Other variables
# with different names are assigned to for historical reasons only to keep
# the code more readable and minimize change.
get_property(cmd_set TARGET ${name} PROPERTY _EP_PATCH_COMMAND SET) set(source_dir "${_EP_SOURCE_DIR}")
get_property(cmd TARGET ${name} PROPERTY _EP_PATCH_COMMAND) set(stamp_dir "${_EP_STAMP_DIR}")
set(cmd "${_EP_PATCH_COMMAND}")
set(work_dir) set(work_dir)
if(DEFINED _EP_PATCH_COMMAND)
if(cmd_set)
set(work_dir ${source_dir}) set(work_dir ${source_dir})
endif() endif()
@@ -3714,21 +3720,13 @@ function(_ep_add_patch_command name)
@ONLY @ONLY
) )
get_property(log if(_EP_LOG_PATCH)
TARGET ${name}
PROPERTY _EP_LOG_PATCH
)
if(log)
set(log LOG 1) set(log LOG 1)
else() else()
set(log "") set(log "")
endif() endif()
get_property(uses_terminal if(_EP_USES_TERMINAL_PATCH)
TARGET ${name}
PROPERTY _EP_USES_TERMINAL_PATCH
)
if(uses_terminal)
set(uses_terminal USES_TERMINAL 1) set(uses_terminal USES_TERMINAL 1)
else() else()
set(uses_terminal "") set(uses_terminal "")
@@ -4491,6 +4489,7 @@ function(ExternalProject_Add name)
get_filename_component(work_dir "${source_dir}" PATH) get_filename_component(work_dir "${source_dir}" PATH)
_ep_resolve_git_remote(resolved_git_repository "${repo}" "${cmp0150}" "${work_dir}") _ep_resolve_git_remote(resolved_git_repository "${repo}" "${cmp0150}" "${work_dir}")
set_property(TARGET ${name} PROPERTY _EP_GIT_REPOSITORY ${resolved_git_repository}) set_property(TARGET ${name} PROPERTY _EP_GIT_REPOSITORY ${resolved_git_repository})
set(_EP_GIT_REPOSITORY "${resolved_git_repository}")
endif() endif()
# The 'complete' step depends on all other steps and creates a # The 'complete' step depends on all other steps and creates a