summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/ExternalProject.cmake49
1 files changed, 36 insertions, 13 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 63f1180..0df51a8 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -30,6 +30,7 @@
# [SVN_TRUST_CERT 1 ] # Trust the Subversion server site certificate
# [GIT_REPOSITORY url] # URL of git repo
# [GIT_TAG tag] # Git branch name, commit id or tag
+# [GIT_SUBMODULES modules...] # Git submodules that shall be updated, all if empty
# [HG_REPOSITORY url] # URL of mercurial repo
# [HG_TAG tag] # Mercurial branch name, commit id or tag
# [URL /.../src.tgz] # Full path or URL of source
@@ -289,7 +290,7 @@ define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED
)
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir gitclone_infofile gitclone_stampfile)
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_submodules src_name work_dir gitclone_infofile gitclone_stampfile)
file(WRITE ${script_filename}
"if(\"${git_tag}\" STREQUAL \"\")
message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
@@ -352,7 +353,7 @@ if(error_code)
endif()
execute_process(
- COMMAND \"${git_EXECUTABLE}\" submodule update --recursive
+ COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules}
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
RESULT_VARIABLE error_code
)
@@ -440,7 +441,7 @@ endif()
endfunction()
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_repository work_dir)
+function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_submodules git_repository work_dir)
file(WRITE ${script_filename}
"if(\"${git_tag}\" STREQUAL \"\")
message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
@@ -499,7 +500,7 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"
endif()
execute_process(
- COMMAND \"${git_EXECUTABLE}\" submodule update --recursive
+ COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules}
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
RESULT_VARIABLE error_code
)
@@ -585,13 +586,30 @@ message(STATUS \"downloading... done\")
endfunction()
-function(_ep_write_verifyfile_script script_filename local hash)
+function(_ep_write_verifyfile_script script_filename local hash retries download_script)
if("${hash}" MATCHES "${_ep_hash_regex}")
set(algo "${CMAKE_MATCH_1}")
string(TOLOWER "${CMAKE_MATCH_2}" expect_value)
set(script_content "set(expect_value \"${expect_value}\")
-file(${algo} \"\${file}\" actual_value)
-if(\"\${actual_value}\" STREQUAL \"\${expect_value}\")
+set(attempt 0)
+set(succeeded 0)
+while(\${attempt} LESS ${retries} OR \${attempt} EQUAL ${retries} AND NOT \${succeeded})
+ file(${algo} \"\${file}\" actual_value)
+ if(\"\${actual_value}\" STREQUAL \"\${expect_value}\")
+ set(succeeded 1)
+ elseif(\${attempt} LESS ${retries})
+ message(STATUS \"${algo} hash of \${file}
+does not match expected value
+ expected: \${expect_value}
+ actual: \${actual_value}
+Retrying download.
+\")
+ file(REMOVE \"\${file}\")
+ execute_process(COMMAND ${CMAKE_COMMAND} -P \"${download_script}\")
+ endif()
+endwhile()
+
+if(\${succeeded})
message(STATUS \"verifying file... done\")
else()
message(FATAL_ERROR \"error: ${algo} hash of
@@ -1306,6 +1324,7 @@ function(_ep_add_download_command name)
if(NOT git_tag)
set(git_tag "master")
endif()
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
# For the download step, and the git clone operation, only the repository
# should be recorded in a configured RepositoryInfo file. If the repo
@@ -1330,7 +1349,7 @@ function(_ep_add_download_command name)
# The script will delete the source directory and then call git clone.
#
_ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
- ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${src_name} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_repository} ${git_tag} "${git_submodules}" ${src_name} ${work_dir}
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt
)
set(comment "Performing download step (git clone) for '${name}'")
@@ -1394,6 +1413,8 @@ function(_ep_add_download_command name)
set(repository "external project URL")
set(module "${url}")
set(tag "${hash}")
+ set(retries 0)
+ set(download_script "")
configure_file(
"${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-urlinfo.txt"
@@ -1423,16 +1444,17 @@ function(_ep_add_download_command name)
get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO)
- _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake"
- "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}")
- set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake
+ set(download_script "${stamp_dir}/download-${name}.cmake")
+ _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}")
+ set(cmd ${CMAKE_COMMAND} -P "${download_script}"
COMMAND)
+ set(retries 3)
set(comment "Performing download step (download, verify and extract) for '${name}'")
else()
set(file "${url}")
set(comment "Performing download step (verify and extract) for '${name}'")
endif()
- _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}")
+ _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}" "${retries}" "${download_script}")
list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake
COMMAND)
_ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")
@@ -1521,8 +1543,9 @@ function(_ep_add_update_command name)
if(NOT git_tag)
set(git_tag "master")
endif()
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
_ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
- ${GIT_EXECUTABLE} ${git_tag} ${git_repository} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_tag} "${git_submodules}" ${git_repository} ${work_dir}
)
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
set(always 1)