diff options
author | Bartosz Kosiorek <bartosz.kosiorek@tomtom.com> | 2019-03-13 14:40:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-03-14 17:44:30 (GMT) |
commit | 00b5f1a1b5f44167184e5602385986172afa7a3a (patch) | |
tree | 0607b89686fea34747400b403e553ffe00fc8da0 /Modules/ExternalProject.cmake | |
parent | 98e6822fdf02d74e1b3e3ff4b1e7ac27138654c9 (diff) | |
download | CMake-00b5f1a1b5f44167184e5602385986172afa7a3a.zip CMake-00b5f1a1b5f44167184e5602385986172afa7a3a.tar.gz CMake-00b5f1a1b5f44167184e5602385986172afa7a3a.tar.bz2 |
ExternalProject: Simplify generated 'git clone' scripts
Revise script generation to hard-code selected options instead of
building them with logic inside the script.
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r-- | Modules/ExternalProject.cmake | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 5705b3a..278020c 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1053,11 +1053,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 +1062,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 +1113,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 ) |