Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckSubmodules: Run git submodule sync #7598

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cmake/modules/CheckSubmodules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,15 @@ MACRO(GIT_SUBMODULE SUBMODULE_PATH FORCE_DEINIT FORCE_REMOTE NO_DEPTH)
SET(DEPTH_CMD "--depth")
SET(DEPTH_VAL "${DEPTH_VALUE}")
ENDIF()

# Sync submodules - required in case a submodule URL changed
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" submodule sync --recursive ${DEPTH_CMD} ${DEPTH_VAL} "${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE GIT_RESULT_SYNC
OUTPUT_VARIABLE GIT_STDOUT_SYNC
ERROR_VARIABLE GIT_STDERR_SYNC
)
# Update and init submodules
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive ${DEPTH_CMD} ${DEPTH_VAL} "${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
Expand All @@ -148,7 +156,11 @@ MACRO(GIT_SUBMODULE SUBMODULE_PATH FORCE_DEINIT FORCE_REMOTE NO_DEPTH)
ERROR_VARIABLE GIT_STDERR
)

SET(GIT_MESSAGE "${GIT_STDOUT}${GIT_STDERR}")
IF(NOT GIT_RESULT_SYNC EQUAL 0)
SET(GIT_RESULT 1)
ENDIF()

SET(GIT_MESSAGE "${GIT_STDOUT_SYNC}${GIT_STDERR_SYNC}${GIT_STDOUT}${GIT_STDERR}")
MESSAGE("${GIT_MESSAGE}")
ENDIF()
ENDMACRO()
Expand Down
Loading