ExternalProject: Use uppercase placeholders for script generation

Use uppercase variables for future 'configure_file' command.
This commit is contained in:
Ruslan Baratov 2016-05-19 14:38:06 +03:00 committed by Brad King
parent e0da6c3b56
commit d610407cca

View File

@ -847,25 +847,25 @@ endif()
endfunction(_ep_write_gitupdate_script) endfunction(_ep_write_gitupdate_script)
function(_ep_write_downloadfile_script script_filename remote local timeout no_progress hash tls_verify tls_cainfo) function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo)
if(timeout) if(timeout)
set(timeout_args TIMEOUT ${timeout}) set(TIMEOUT_ARGS TIMEOUT ${timeout})
set(timeout_msg "${timeout} seconds") set(TIMEOUT_MSG "${timeout} seconds")
else() else()
set(timeout_args "# no TIMEOUT") set(TIMEOUT_ARGS "# no TIMEOUT")
set(timeout_msg "none") set(TIMEOUT_MSG "none")
endif() endif()
if(no_progress) if(no_progress)
set(show_progress "") set(SHOW_PROGRESS "")
else() else()
set(show_progress "SHOW_PROGRESS") set(SHOW_PROGRESS "SHOW_PROGRESS")
endif() endif()
if("${hash}" MATCHES "${_ep_hash_regex}") if("${hash}" MATCHES "${_ep_hash_regex}")
string(CONCAT hash_check string(CONCAT hash_check
"if(EXISTS \"${local}\")\n" "if(EXISTS \"${LOCAL}\")\n"
" file(\"${CMAKE_MATCH_1}\" \"${local}\" hash_value)\n" " file(\"${CMAKE_MATCH_1}\" \"${LOCAL}\" hash_value)\n"
" if(\"x\${hash_value}\" STREQUAL \"x${CMAKE_MATCH_2}\")\n" " if(\"x\${hash_value}\" STREQUAL \"x${CMAKE_MATCH_2}\")\n"
" return()\n" " return()\n"
" endif()\n" " endif()\n"
@ -875,15 +875,15 @@ function(_ep_write_downloadfile_script script_filename remote local timeout no_p
set(hash_check "") set(hash_check "")
endif() endif()
set(tls_verify_code "") set(TLS_VERIFY_CODE "")
set(tls_cainfo_code "") set(TLS_CAINFO_CODE "")
# check for curl globals in the project # check for curl globals in the project
if(DEFINED CMAKE_TLS_VERIFY) if(DEFINED CMAKE_TLS_VERIFY)
set(tls_verify_code "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})") set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})")
endif() endif()
if(DEFINED CMAKE_TLS_CAINFO) if(DEFINED CMAKE_TLS_CAINFO)
set(tls_cainfo_code "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")") set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")")
endif() endif()
# now check for curl locals so that the local values # now check for curl locals so that the local values
@ -892,28 +892,28 @@ function(_ep_write_downloadfile_script script_filename remote local timeout no_p
# check for tls_verify argument # check for tls_verify argument
string(LENGTH "${tls_verify}" tls_verify_len) string(LENGTH "${tls_verify}" tls_verify_len)
if(tls_verify_len GREATER 0) if(tls_verify_len GREATER 0)
set(tls_verify_code "set(CMAKE_TLS_VERIFY ${tls_verify})") set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${tls_verify})")
endif() endif()
# check for tls_cainfo argument # check for tls_cainfo argument
string(LENGTH "${tls_cainfo}" tls_cainfo_len) string(LENGTH "${tls_cainfo}" tls_cainfo_len)
if(tls_cainfo_len GREATER 0) if(tls_cainfo_len GREATER 0)
set(tls_cainfo_code "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")") set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")")
endif() endif()
file(WRITE ${script_filename} file(WRITE ${script_filename}
"${hash_check}message(STATUS \"downloading... "${hash_check}message(STATUS \"downloading...
src='${remote}' src='${REMOTE}'
dst='${local}' dst='${LOCAL}'
timeout='${timeout_msg}'\") timeout='${TIMEOUT_MSG}'\")
${tls_verify_code} ${TLS_VERIFY_CODE}
${tls_cainfo_code} ${TLS_CAINFO_CODE}
file(DOWNLOAD file(DOWNLOAD
\"${remote}\" \"${REMOTE}\"
\"${local}\" \"${LOCAL}\"
${show_progress} ${SHOW_PROGRESS}
${timeout_args} ${TIMEOUT_ARGS}
STATUS status STATUS status
LOG log) LOG log)
@ -921,7 +921,7 @@ list(GET status 0 status_code)
list(GET status 1 status_string) list(GET status 1 status_string)
if(NOT status_code EQUAL 0) if(NOT status_code EQUAL 0)
message(FATAL_ERROR \"error: downloading '${remote}' failed message(FATAL_ERROR \"error: downloading '${REMOTE}' failed
status_code: \${status_code} status_code: \${status_code}
status_string: \${status_string} status_string: \${status_string}
log: \${log} log: \${log}
@ -935,7 +935,7 @@ message(STATUS \"downloading... done\")
endfunction() endfunction()
function(_ep_write_verifyfile_script script_filename local hash retries download_script) function(_ep_write_verifyfile_script script_filename LOCAL hash retries download_script)
if("${hash}" MATCHES "${_ep_hash_regex}") if("${hash}" MATCHES "${_ep_hash_regex}")
set(algo "${CMAKE_MATCH_1}") set(algo "${CMAKE_MATCH_1}")
string(TOLOWER "${CMAKE_MATCH_2}" expect_value) string(TOLOWER "${CMAKE_MATCH_2}" expect_value)
@ -972,7 +972,7 @@ endif()")
else() else()
set(script_content "message(STATUS \"verifying file... warning: did not verify file - no URL_HASH specified?\")") set(script_content "message(STATUS \"verifying file... warning: did not verify file - no URL_HASH specified?\")")
endif() endif()
file(WRITE ${script_filename} "set(file \"${local}\") file(WRITE ${script_filename} "set(file \"${LOCAL}\")
message(STATUS \"verifying file... message(STATUS \"verifying file...
file='\${file}'\") file='\${file}'\")
${script_content} ${script_content}