From 14e2c3ad181e2090cb0846fb87743f7543484d08 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Thu, 28 May 2015 16:22:28 +0200 Subject: ExternalProject: Initialize only selected git submodules (#15590) Honor the GIT_SUBMODULES option added by commit v3.0.0-rc1~92^2 (ExternalProject: Add option GIT_SUBMODULES, 2014-01-09) during the 'git submodule init' step to avoid initalizing all modules since we are only going to update the specified subset anyway. This will be useful for project repositories that have many submodules (e.g. https://github.com/boostorg/boost). Reviewed-by: Daniele E. Domenichelli --- Modules/ExternalProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 11a24b8..eee1841 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -529,7 +529,7 @@ if(error_code) endif() execute_process( - COMMAND \"${git_EXECUTABLE}\" submodule init + COMMAND \"${git_EXECUTABLE}\" submodule init ${git_submodules} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) -- cgit v0.12 From 124243c0eb6977690d4f99f17e8019c748af3668 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Thu, 28 May 2015 19:39:19 +0200 Subject: ExternalProject: Add unit tests for GIT_SUBMODULES argument --- Tests/ExternalProject/CMakeLists.txt | 60 ++++++++++++++++++++++++++++++++++ Tests/ExternalProject/gitrepo-sub.tgz | Bin 0 -> 1911 bytes 2 files changed, 60 insertions(+) create mode 100644 Tests/ExternalProject/gitrepo-sub.tgz diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index de62ce7..b5041c7 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -364,6 +364,66 @@ if(do_git_tests) ) set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + # Unzip/untar the git repository in our source folder so that other + # projects below may use it to test git args of ExternalProject_Add + # + set(proj SetupLocalGITRepositoryWithSubmodules) + ExternalProject_Add(${proj} + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/GIT-with-submodules + URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo-sub.tgz + BUILD_COMMAND "" + CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version + INSTALL_COMMAND "" + ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + + set(local_git_repo "../../LocalRepositories/GIT-with-submodules") + + set(proj TS1-GIT-no-GIT_SUBMODULES) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + -DWITH_m1:BOOL=ON + -DWITH_m2:BOOL=ON + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + "SetupLocalGITRepositoryWithSubmodules" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + + set(proj TS1-GIT-empty-GIT_SUBMODULES) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_SUBMODULES "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + -DWITH_m1:BOOL=ON + -DWITH_m2:BOOL=ON + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + "SetupLocalGITRepositoryWithSubmodules" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + + set(proj TS1-GIT-some-GIT_SUBMODULES) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_SUBMODULES "m/m1" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + -DWITH_m1:BOOL=ON + -DWITH_m2:BOOL=OFF + BUILD_COMMAND "" + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + "SetupLocalGITRepositoryWithSubmodules" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") + endif() set(do_hg_tests 0) diff --git a/Tests/ExternalProject/gitrepo-sub.tgz b/Tests/ExternalProject/gitrepo-sub.tgz new file mode 100644 index 0000000..c0b5360 Binary files /dev/null and b/Tests/ExternalProject/gitrepo-sub.tgz differ -- cgit v0.12 From 77ee6db50529abc784408d10156d5e4be61b8f18 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 2 Jun 2015 14:29:45 -0400 Subject: Help: Add notes for topic 'ExternalProject_init_selected_submodules' --- Help/release/dev/ExternalProject_init_selected_submodules.rst | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Help/release/dev/ExternalProject_init_selected_submodules.rst diff --git a/Help/release/dev/ExternalProject_init_selected_submodules.rst b/Help/release/dev/ExternalProject_init_selected_submodules.rst new file mode 100644 index 0000000..e642c19 --- /dev/null +++ b/Help/release/dev/ExternalProject_init_selected_submodules.rst @@ -0,0 +1,7 @@ +ExternalProject_init_selected_submodules +---------------------------------------- + +* The :module:`ExternalProject` module :command:`ExternalProject_Add` + function ``GIT_SUBMODULES`` option now also limits the set of + submodules that are initialized in addition to the prior behavior + of limiting the set of submodules that are updated. -- cgit v0.12