summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject.cmake
diff options
context:
space:
mode:
authorAdam Rankin <adam.rankin@gmail.com>2016-01-15 17:34:46 (GMT)
committerBrad King <brad.king@kitware.com>2016-01-15 19:20:04 (GMT)
commit83d633919a75bde05acdf642ff79c5b310fce824 (patch)
treee95b96d91534131ced33d33f11d38a1d94e3724e /Modules/ExternalProject.cmake
parentb8d002af1aeefb435a9560b056f081e5d8dff734 (diff)
downloadCMake-83d633919a75bde05acdf642ff79c5b310fce824.zip
CMake-83d633919a75bde05acdf642ff79c5b310fce824.tar.gz
CMake-83d633919a75bde05acdf642ff79c5b310fce824.tar.bz2
ExternalProject: Add option to set `git clone -o` argument
Add a `GIT_REMOTE_NAME` option to `ExternalProject_Add` to support git clone --origin <name> Default to `origin` if not specified.
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r--Modules/ExternalProject.cmake23
1 files changed, 17 insertions, 6 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index c822bdb..5c5c54a 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -57,6 +57,8 @@ Create custom targets to build projects in external trees
URL of git repo
``GIT_TAG <tag>``
Git branch name, commit id or tag
+ ``GIT_REMOTE_NAME <name>``
+ The optional name of the remote, default to ``origin``
``GIT_SUBMODULES <module>...``
Git submodules that shall be updated, all if empty
``HG_REPOSITORY <url>``
@@ -494,7 +496,7 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
"ExternalProject module."
)
-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)
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name 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.\")
@@ -524,7 +526,7 @@ set(error_code 1)
set(number_of_tries 0)
while(error_code AND number_of_tries LESS 3)
execute_process(
- COMMAND \"${git_EXECUTABLE}\" clone \"${git_repository}\" \"${src_name}\"
+ COMMAND \"${git_EXECUTABLE}\" clone --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
WORKING_DIRECTORY \"${work_dir}\"
RESULT_VARIABLE error_code
)
@@ -645,7 +647,7 @@ endif()
endfunction()
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_submodules git_repository work_dir)
+function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name git_submodules git_repository work_dir)
if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.6)
set(git_stash_save_options --all --quiet)
else()
@@ -687,7 +689,7 @@ if(\"\${show_ref_output}\" MATCHES \"refs/remotes/${git_tag}\")
set(git_remote \"\${CMAKE_MATCH_1}\")
set(git_tag \"\${CMAKE_MATCH_2}\")
else()
- set(git_remote \"origin\")
+ set(git_remote \"${git_remote_name}\")
set(git_tag \"${git_tag}\")
endif()
@@ -1749,6 +1751,11 @@ function(_ep_add_download_command name)
endif()
get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+ get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
+ if(NOT git_remote_name)
+ set(git_remote_name "origin")
+ endif()
+
# For the download step, and the git clone operation, only the repository
# should be recorded in a configured RepositoryInfo file. If the repo
# changes, the clone script should be run again. But if only the tag
@@ -1772,7 +1779,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} "${git_submodules}" ${src_name} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${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}'")
@@ -1993,9 +2000,13 @@ function(_ep_add_update_command name)
if(NOT git_tag)
set(git_tag "master")
endif()
+ get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
+ if(NOT git_remote_name)
+ set(git_remote_name "origin")
+ 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_submodules}" ${git_repository} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} "${git_submodules}" ${git_repository} ${work_dir}
)
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
set(always 1)