diff --git a/cmake/modules/CheckSubmodules.cmake b/cmake/modules/CheckSubmodules.cmake index b9ea2077874..37300801ca2 100644 --- a/cmake/modules/CheckSubmodules.cmake +++ b/cmake/modules/CheckSubmodules.cmake @@ -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}" @@ -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()