From f0a36b1a7636e827893df9adc6c472023605e67e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 28 Feb 2024 19:10:29 -0500 Subject: ExternalProject: Factor out helper to get NETRC options --- Modules/ExternalProject.cmake | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index a21741d..2844b93 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1361,6 +1361,22 @@ function(_ep_get_tls_cainfo name tls_cainfo_var) set("${tls_cainfo_var}" "${tls_cainfo}" PARENT_SCOPE) endfunction() +function(_ep_get_netrc name netrc_var) + get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) + if("x${netrc}" STREQUAL "x" AND DEFINED CMAKE_NETRC) + set(netrc "${CMAKE_NETRC}") + endif() + set("${netrc_var}" "${netrc}" PARENT_SCOPE) +endfunction() + +function(_ep_get_netrc_file name netrc_file_var) + get_property(netrc_file TARGET ${name} PROPERTY _EP_NETRC_FILE) + if("x${netrc_file}" STREQUAL "x" AND DEFINED CMAKE_NETRC_FILE) + set(netrc_file "${CMAKE_NETRC_FILE}") + endif() + set("${netrc_file_var}" "${netrc_file}" PARENT_SCOPE) +endfunction() + function(_ep_write_gitclone_script script_filename source_dir @@ -1589,27 +1605,12 @@ function(_ep_write_downloadfile_script endif() set(NETRC_CODE "") - set(NETRC_FILE_CODE "") - - # check for curl globals in the project - if(DEFINED CMAKE_NETRC) - set(NETRC_CODE "set(CMAKE_NETRC \"${CMAKE_NETRC}\")") - endif() - if(DEFINED CMAKE_NETRC_FILE) - set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${CMAKE_NETRC_FILE}\")") - endif() - - # now check for curl locals so that the local values - # will override the globals - - # check for netrc argument - string(LENGTH "${netrc}" netrc_len) - if(netrc_len GREATER 0) + if(NOT "x${netrc}" STREQUAL "x") set(NETRC_CODE "set(CMAKE_NETRC \"${netrc}\")") endif() - # check for netrc_file argument - string(LENGTH "${netrc_file}" netrc_file_len) - if(netrc_file_len GREATER 0) + + set(NETRC_FILE_CODE "") + if(NOT "x${netrc_file}" STREQUAL "x") set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${netrc_file}\")") endif() @@ -3152,8 +3153,8 @@ hash=${hash} ) _ep_get_tls_verify(${name} tls_verify) _ep_get_tls_cainfo(${name} tls_cainfo) - get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) - get_property(netrc_file TARGET ${name} PROPERTY _EP_NETRC_FILE) + _ep_get_netrc(${name} netrc) + _ep_get_netrc_file(${name} netrc_file) get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME) get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER) -- cgit v0.12