aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-12-01 17:52:56 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-12-02 10:37:13 +0100
commit21fea13125ff9d1ce80e23381a09a4c442fb50fe (patch)
tree823780d967be1a4f3ac1a36a599e2edd6b7ba109 /cmake
parent2218bf230b1ca48cf8cb818742a604a660389195 (diff)
Initialize missing submodules if a supermodule is present
When fetching dependencies, the submodule directory might not exist or might be empty. If so, try to initialize the submodule before trying to add the worktree. Pick-to: 6.0 Change-Id: Ie4d6ec483ac9ea3f9207d5ab4cea34d6e0fb2921 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtTopLevelHelpers.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtTopLevelHelpers.cmake b/cmake/QtTopLevelHelpers.cmake
index abc72507..920378c3 100644
--- a/cmake/QtTopLevelHelpers.cmake
+++ b/cmake/QtTopLevelHelpers.cmake
@@ -182,6 +182,21 @@ function(qt_internal_get_dependency dependent dependency)
string(SUBSTRING "${git_stdout}" 0 ${index} remote)
message(DEBUG "Will clone from ${remote}")
+ if(EXISTS "${gitdir}.gitmodules" AND NOT EXISTS "${gitdir}${dependency}/.git")
+ # super repo exists, but the submodule we need does not - try to initialize
+ message(NOTICE "Initializing submodule '${dependency}' from ${gitdir}")
+ execute_process(
+ COMMAND "git" "submodule" "update" "--init" "${dependency}"
+ WORKING_DIRECTORY "${gitdir}"
+ RESULT_VARIABLE git_result
+ ${swallow_output}
+ )
+ if (git_result)
+ # ignore errors, fall back to an independent clone instead
+ message(WARNING "Failed to initialize submodule '${dependency}' from ${gitdir}")
+ endif()
+ endif()
+
if(EXISTS "${gitdir}${dependency}")
# for the module we want, there seems to be a clone parallel to what we have
message(NOTICE "Adding worktree for ${dependency} from ${gitdir}${dependency}")