ExternalProject: Add option GIT_SUBMODULES
This option allows to filter the submodules that are checked out. Add a simple testcase for GIT_SUBMODULES option passing an empty list.
This commit is contained in:
parent
2dfb517f73
commit
819015ef3a
|
@ -30,6 +30,7 @@
|
||||||
# [SVN_TRUST_CERT 1 ] # Trust the Subversion server site certificate
|
# [SVN_TRUST_CERT 1 ] # Trust the Subversion server site certificate
|
||||||
# [GIT_REPOSITORY url] # URL of git repo
|
# [GIT_REPOSITORY url] # URL of git repo
|
||||||
# [GIT_TAG tag] # Git branch name, commit id or tag
|
# [GIT_TAG tag] # Git branch name, commit id or tag
|
||||||
|
# [GIT_SUBMODULES modules...] # Git submodules that shall be updated, all if empty
|
||||||
# [HG_REPOSITORY url] # URL of mercurial repo
|
# [HG_REPOSITORY url] # URL of mercurial repo
|
||||||
# [HG_TAG tag] # Mercurial branch name, commit id or tag
|
# [HG_TAG tag] # Mercurial branch name, commit id or tag
|
||||||
# [URL /.../src.tgz] # Full path or URL of source
|
# [URL /.../src.tgz] # Full path or URL of source
|
||||||
|
@ -289,7 +290,7 @@ define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir gitclone_infofile gitclone_stampfile)
|
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)
|
||||||
file(WRITE ${script_filename}
|
file(WRITE ${script_filename}
|
||||||
"if(\"${git_tag}\" STREQUAL \"\")
|
"if(\"${git_tag}\" STREQUAL \"\")
|
||||||
message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
|
message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
|
||||||
|
@ -352,7 +353,7 @@ if(error_code)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND \"${git_EXECUTABLE}\" submodule update --recursive
|
COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules}
|
||||||
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
|
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
|
||||||
RESULT_VARIABLE error_code
|
RESULT_VARIABLE error_code
|
||||||
)
|
)
|
||||||
|
@ -440,7 +441,7 @@ endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_repository work_dir)
|
function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_submodules git_repository work_dir)
|
||||||
file(WRITE ${script_filename}
|
file(WRITE ${script_filename}
|
||||||
"if(\"${git_tag}\" STREQUAL \"\")
|
"if(\"${git_tag}\" STREQUAL \"\")
|
||||||
message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
|
message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
|
||||||
|
@ -499,7 +500,7 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND \"${git_EXECUTABLE}\" submodule update --recursive
|
COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules}
|
||||||
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
|
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
|
||||||
RESULT_VARIABLE error_code
|
RESULT_VARIABLE error_code
|
||||||
)
|
)
|
||||||
|
@ -1323,6 +1324,7 @@ function(_ep_add_download_command name)
|
||||||
if(NOT git_tag)
|
if(NOT git_tag)
|
||||||
set(git_tag "master")
|
set(git_tag "master")
|
||||||
endif()
|
endif()
|
||||||
|
get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -1347,7 +1349,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} ${src_name} ${work_dir}
|
${GIT_EXECUTABLE} ${git_repository} ${git_tag} "${git_submodules}" ${src_name} ${work_dir}
|
||||||
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt
|
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt
|
||||||
)
|
)
|
||||||
set(comment "Performing download step (git clone) for '${name}'")
|
set(comment "Performing download step (git clone) for '${name}'")
|
||||||
|
@ -1541,8 +1543,9 @@ function(_ep_add_update_command name)
|
||||||
if(NOT git_tag)
|
if(NOT git_tag)
|
||||||
set(git_tag "master")
|
set(git_tag "master")
|
||||||
endif()
|
endif()
|
||||||
|
get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
|
||||||
_ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
|
_ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
|
||||||
${GIT_EXECUTABLE} ${git_tag} ${git_repository} ${work_dir}
|
${GIT_EXECUTABLE} ${git_tag} "${git_submodules}" ${git_repository} ${work_dir}
|
||||||
)
|
)
|
||||||
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
|
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
|
||||||
set(always 1)
|
set(always 1)
|
||||||
|
|
|
@ -512,6 +512,22 @@ if(do_git_tests)
|
||||||
LOG_UPDATE 1
|
LOG_UPDATE 1
|
||||||
)
|
)
|
||||||
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
|
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
|
||||||
|
|
||||||
|
# git by explicit branch/tag with empty submodule list
|
||||||
|
#
|
||||||
|
set(proj TutorialStep1-GIT-bytag-withsubmodules)
|
||||||
|
ExternalProject_Add(${proj}
|
||||||
|
GIT_REPOSITORY "${local_git_repo}"
|
||||||
|
GIT_TAG "origin/master"
|
||||||
|
GIT_SUBMODULES ""
|
||||||
|
UPDATE_COMMAND ""
|
||||||
|
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
|
||||||
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
DEPENDS "SetupLocalGITRepository"
|
||||||
|
)
|
||||||
|
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(do_hg_tests 0)
|
set(do_hg_tests 0)
|
||||||
|
|
Loading…
Reference in New Issue