mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 03:59:58 +00:00
ExternalProject: Fix git submodule recursion on update
In commit 5bc6230741
(ExternalProject: Option to turn off recursive
update of git submodules, 2019-10-16) we implemented the feature in the
clone script written by `_ep_write_gitclone_script` but not in the
update script written by `_ep_write_gitupdate_script`. Implement the
latter by factoring out a common helper to use in both places.
Fixes: #20335
This commit is contained in:
parent
155540d89e
commit
0ba8010255
@ -1239,7 +1239,7 @@ endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules git_repository work_dir)
|
||||
function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_repository work_dir)
|
||||
if("${git_tag}" STREQUAL "")
|
||||
message(FATAL_ERROR "Tag for git checkout should not be empty.")
|
||||
endif()
|
||||
@ -2339,6 +2339,29 @@ function(_ep_is_dir_empty dir empty_var)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(_ep_get_git_submodules_recurse git_submodules_recurse)
|
||||
# Checks for GIT_SUBMODULES_RECURSE property
|
||||
# Default is ON, which sets git_submodules_recurse output variable to "--recursive"
|
||||
# Otherwise, the output variable is set to an empty value ""
|
||||
get_property(git_submodules_recurse_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE SET)
|
||||
if(NOT git_submodules_recurse_set)
|
||||
set(recurseFlag "--recursive")
|
||||
else()
|
||||
get_property(git_submodules_recurse_value TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE)
|
||||
if(git_submodules_recurse_value)
|
||||
set(recurseFlag "--recursive")
|
||||
else()
|
||||
set(recurseFlag "")
|
||||
endif()
|
||||
endif()
|
||||
set(${git_submodules_recurse} "${recurseFlag}" PARENT_SCOPE)
|
||||
|
||||
# The git submodule update '--recursive' flag requires git >= v1.6.5
|
||||
if(recurseFlag AND GIT_VERSION_STRING VERSION_LESS 1.6.5)
|
||||
message(FATAL_ERROR "error: git version 1.6.5 or later required for --recursive flag with 'git submodule ...': GIT_VERSION_STRING='${GIT_VERSION_STRING}'")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(_ep_add_download_command name)
|
||||
ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir)
|
||||
@ -2431,23 +2454,7 @@ function(_ep_add_download_command name)
|
||||
message(FATAL_ERROR "error: could not find git for clone of ${name}")
|
||||
endif()
|
||||
|
||||
get_property(git_submodules_recurse_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE SET)
|
||||
if(NOT git_submodules_recurse_set)
|
||||
set(git_submodules_recurse "--recursive")
|
||||
else()
|
||||
get_property(git_submodules_recurse_value TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE)
|
||||
if(git_submodules_recurse_value)
|
||||
set(git_submodules_recurse "--recursive")
|
||||
else()
|
||||
set(git_submodules_recurse "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The git submodule update '--recursive' flag requires git >= v1.6.5
|
||||
#
|
||||
if(git_submodules_recurse AND GIT_VERSION_STRING VERSION_LESS 1.6.5)
|
||||
message(FATAL_ERROR "error: git version 1.6.5 or later required for 'git submodule update --recursive': GIT_VERSION_STRING='${GIT_VERSION_STRING}'")
|
||||
endif()
|
||||
_ep_get_git_submodules_recurse(git_submodules_recurse)
|
||||
|
||||
get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG)
|
||||
if(NOT git_tag)
|
||||
@ -2774,8 +2781,10 @@ function(_ep_add_update_command name)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_ep_get_git_submodules_recurse(git_submodules_recurse)
|
||||
|
||||
_ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
|
||||
${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" ${git_repository} ${work_dir}
|
||||
${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules_recurse}" "${git_submodules}" ${git_repository} ${work_dir}
|
||||
)
|
||||
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
|
||||
set(always 1)
|
||||
|
Loading…
Reference in New Issue
Block a user