mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-19 21:01:05 -05:00
ExternalProject: Allow passing config flags to git clone
Add a `GIT_CONFIG` parameter that allows to specify `--config` flags that are passed to the git clone command. This can be used to specify for example `core.autocrlf=true`. The `--config` parameter is supported since Git 1.7.7.
This commit is contained in:
committed by
Brad King
parent
88f38a2bb4
commit
2be9d85af8
5
Help/release/dev/ExternalProject-GIT_CONFIG.rst
Normal file
5
Help/release/dev/ExternalProject-GIT_CONFIG.rst
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
ExternalProject-GIT_CONFIG
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
* The :module:`ExternalProject` module gained a ``GIT_CONFIG`` option
|
||||||
|
to pass ``--config`` options to Git when cloning repositories.
|
||||||
@@ -73,6 +73,10 @@ Create custom targets to build projects in external trees
|
|||||||
does not output anything which can make the build appear to have stalled.
|
does not output anything which can make the build appear to have stalled.
|
||||||
This option forces Git to output progress information during the clone step
|
This option forces Git to output progress information during the clone step
|
||||||
so that forward progress is indicated.
|
so that forward progress is indicated.
|
||||||
|
``GIT_CONFIG <option>...``
|
||||||
|
Tell Git to clone with ``--config <option>``. Use additional configuration
|
||||||
|
parameters when cloning the project (``key=value`` as expected by ``git
|
||||||
|
config``).
|
||||||
``HG_REPOSITORY <url>``
|
``HG_REPOSITORY <url>``
|
||||||
URL of mercurial repo
|
URL of mercurial repo
|
||||||
``HG_TAG <tag>``
|
``HG_TAG <tag>``
|
||||||
@@ -514,7 +518,7 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
|
|||||||
"ExternalProject module."
|
"ExternalProject module."
|
||||||
)
|
)
|
||||||
|
|
||||||
function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
|
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)
|
if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
|
||||||
set(git_clone_shallow_options "--depth 1 --no-single-branch")
|
set(git_clone_shallow_options "--depth 1 --no-single-branch")
|
||||||
else()
|
else()
|
||||||
@@ -565,6 +569,11 @@ if(git_progress)
|
|||||||
list(APPEND git_clone_options --progress)
|
list(APPEND git_clone_options --progress)
|
||||||
endif()
|
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 incase there is an odd git clone issue
|
# try the clone 3 times incase there is an odd git clone issue
|
||||||
set(error_code 1)
|
set(error_code 1)
|
||||||
set(number_of_tries 0)
|
set(number_of_tries 0)
|
||||||
@@ -1812,6 +1821,7 @@ function(_ep_add_download_command name)
|
|||||||
endif()
|
endif()
|
||||||
get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW)
|
get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW)
|
||||||
get_property(git_progress TARGET ${name} PROPERTY _EP_GIT_PROGRESS)
|
get_property(git_progress TARGET ${name} PROPERTY _EP_GIT_PROGRESS)
|
||||||
|
get_property(git_config TARGET ${name} PROPERTY _EP_GIT_CONFIG)
|
||||||
|
|
||||||
# For the download step, and the git clone operation, only the repository
|
# For the download step, and the git clone operation, only the repository
|
||||||
# should be recorded in a configured RepositoryInfo file. If the repo
|
# should be recorded in a configured RepositoryInfo file. If the repo
|
||||||
@@ -1836,7 +1846,7 @@ function(_ep_add_download_command name)
|
|||||||
# The script will delete the source directory and then call git clone.
|
# The script will delete the source directory and then call git clone.
|
||||||
#
|
#
|
||||||
_ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
|
_ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
|
||||||
${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" "${git_progress}" ${src_name} ${work_dir}
|
${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir}
|
||||||
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
|
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
|
||||||
)
|
)
|
||||||
set(comment "Performing download step (git clone) for '${name}'")
|
set(comment "Performing download step (git clone) for '${name}'")
|
||||||
|
|||||||
@@ -363,6 +363,23 @@ if(do_git_tests)
|
|||||||
)
|
)
|
||||||
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
|
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
|
||||||
|
|
||||||
|
# Live git / master (no GIT_TAG), but git config flags
|
||||||
|
#
|
||||||
|
# The `git clone --config` parameter has been introduced in Git 1.7.7
|
||||||
|
if(NOT git_version VERSION_LESS 1.7.7)
|
||||||
|
set(proj TutorialStep1-GIT-config)
|
||||||
|
ExternalProject_Add(${proj}
|
||||||
|
GIT_REPOSITORY "${local_git_repo}"
|
||||||
|
GIT_CONFIG core.eol=lf core.autocrlf=input
|
||||||
|
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
|
||||||
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
DEPENDS "SetupLocalGITRepository"
|
||||||
|
LOG_UPDATE 1
|
||||||
|
)
|
||||||
|
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
|
||||||
|
endif()
|
||||||
|
|
||||||
# git by explicit branch/tag with empty submodule list
|
# git by explicit branch/tag with empty submodule list
|
||||||
#
|
#
|
||||||
set(proj TutorialStep1-GIT-bytag-withsubmodules)
|
set(proj TutorialStep1-GIT-bytag-withsubmodules)
|
||||||
|
|||||||
Reference in New Issue
Block a user