summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-03-18 15:27:42 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-03-18 15:27:59 (GMT)
commitf6cbb02b59d179c572c347461e81201bdd2337ed (patch)
tree6d033d52111970035216f72e7b16b4d91c4b5705 /Modules
parent23874e407839bdd93a05285c65a5dc20c225ac24 (diff)
parentc58f5e116e0fd4fd883320812bfb052582005e90 (diff)
downloadCMake-f6cbb02b59d179c572c347461e81201bdd2337ed.zip
CMake-f6cbb02b59d179c572c347461e81201bdd2337ed.tar.gz
CMake-f6cbb02b59d179c572c347461e81201bdd2337ed.tar.bz2
Merge topic 'ExternalProject-optimize-git'
c58f5e116e ExternalProject: Extend documentation about GIT_TAG usage 8355665f8d ExternalProject: Drop unnecessary 'git submodule init' 00b5f1a1b5 ExternalProject: Simplify generated 'git clone' scripts 98e6822fdf ExternalProject: Re-run 'git clone' when GIT_REMOTE_NAME changes Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3095
Diffstat (limited to 'Modules')
-rw-r--r--Modules/ExternalProject.cmake66
1 files changed, 28 insertions, 38 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 22e0523..4344bdb 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -251,6 +251,9 @@ External Project Definition
The lack of such deterministic behavior makes the main project lose
traceability and repeatability.
+ If ``GIT_SHALLOW`` is enabled then ``GIT_TAG`` works only with
+ branch names and tags. A commit hash is not allowed.
+
``GIT_REMOTE_NAME <name>``
The optional name of the remote. If this option is not specified, it
defaults to ``origin``.
@@ -1053,11 +1056,6 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
)
function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
- if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
- set(git_clone_shallow_options "--depth 1 --no-single-branch")
- else()
- set(git_clone_shallow_options "--depth 1")
- endif()
if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5)
# Use `git checkout <tree-ish> --` to avoid ambiguity with a local path.
set(git_checkout_explicit-- "--")
@@ -1067,12 +1065,30 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git
# because that will not search for remote branch names, a common use case.
set(git_checkout_explicit-- "")
endif()
- file(WRITE ${script_filename}
-"if(\"${git_tag}\" STREQUAL \"\")
- message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
-endif()
+ if("${git_tag}" STREQUAL "")
+ message(FATAL_ERROR "Tag for git checkout should not be empty.")
+ endif()
-set(run 0)
+ set(git_clone_options)
+ if(git_shallow)
+ if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
+ list(APPEND git_clone_options "--depth 1 --no-single-branch")
+ else()
+ list(APPEND git_clone_options "--depth 1")
+ endif()
+ endif()
+ if(git_progress)
+ list(APPEND git_clone_options --progress)
+ endif()
+ foreach(config IN LISTS git_config)
+ list(APPEND git_clone_options --config ${config})
+ endforeach()
+ if(NOT ${git_remote_name} STREQUAL "origin")
+ list(APPEND git_clone_options --origin \"${git_remote_name}\")
+ endif()
+ string (REPLACE ";" " " git_clone_options "${git_clone_options}")
+ file(WRITE ${script_filename}
+"set(run 0)
if(\"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\")
set(run 1)
@@ -1100,29 +1116,12 @@ if(NOT \"x${tls_verify}\" STREQUAL \"x\" AND NOT tls_verify)
-c http.sslVerify=false)
endif()
-set(git_clone_options)
-
-set(git_shallow \"${git_shallow}\")
-if(git_shallow)
- list(APPEND git_clone_options ${git_clone_shallow_options})
-endif()
-
-set(git_progress \"${git_progress}\")
-if(git_progress)
- list(APPEND git_clone_options --progress)
-endif()
-
-set(git_config \"${git_config}\")
-foreach(config IN LISTS git_config)
- list(APPEND git_clone_options --config \${config})
-endforeach()
-
# try the clone 3 times in case there is an odd git clone issue
set(error_code 1)
set(number_of_tries 0)
while(error_code AND number_of_tries LESS 3)
execute_process(
- COMMAND \"${git_EXECUTABLE}\" \${git_options} clone \${git_clone_options} --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
+ COMMAND \"${git_EXECUTABLE}\" \${git_options} clone ${git_clone_options} \"${git_repository}\" \"${src_name}\"
WORKING_DIRECTORY \"${work_dir}\"
RESULT_VARIABLE error_code
)
@@ -1146,15 +1145,6 @@ if(error_code)
endif()
execute_process(
- COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to init submodules in: '${work_dir}/${src_name}'\")
-endif()
-
-execute_process(
COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule update --recursive --init ${git_submodules}
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
RESULT_VARIABLE error_code
@@ -2460,7 +2450,7 @@ function(_ep_add_download_command name)
#
set(repository ${git_repository})
set(module)
- set(tag)
+ set(tag ${git_remote_name})
configure_file(
"${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-gitinfo.txt"