diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /cmake/submodules.cmake | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/submodules.cmake')
-rw-r--r-- | cmake/submodules.cmake | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake new file mode 100644 index 00000000..34dcfbea --- /dev/null +++ b/cmake/submodules.cmake @@ -0,0 +1,50 @@ +# update submodules automatically + +OPTION(UPDATE_SUBMODULES "Update submodules automatically" ON) +IF(NOT UPDATE_SUBMODULES) + RETURN() +ENDIF() + +IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") + EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" config --get cmake.update-submodules + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE cmake_update_submodules + RESULT_VARIABLE git_config_get_result) + IF(cmake_update_submodules MATCHES no) + SET(update_result 0) + SET(SUBMODULE_UPDATE_CONFIG_MESSAGE +"\n\nTo update submodules automatically, set cmake.update-submodules to 'yes', or 'force' to update automatically: + ${GIT_EXECUTABLE} config cmake.update-submodules yes") + ELSEIF(git_config_get_result EQUAL 128) + SET(update_result 0) + ELSE() + SET(UPDATE_SUBMODULES_COMMAND + "${GIT_EXECUTABLE}" submodule update --init --recursive) + # Old Git may not work with "--depth 1". + # See also: https://github.com/git/git/commit/fb43e31f2b43076e7a30c9cd00d0241cb8cf97eb + IF(NOT GIT_VERSION_STRING VERSION_LESS "2.8.0") + SET(UPDATE_SUBMODULES_COMMAND ${UPDATE_SUBMODULES_COMMAND} --depth 1) + ENDIF() + IF(cmake_update_submodules MATCHES force) + MESSAGE(STATUS "Updating submodules (forced)") + EXECUTE_PROCESS(COMMAND ${UPDATE_SUBMODULES_COMMAND} --force + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE update_result) + ELSEIF(cmake_update_submodules MATCHES yes) + EXECUTE_PROCESS(COMMAND ${UPDATE_SUBMODULES_COMMAND} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE update_result) + ELSE() + MESSAGE(STATUS "Updating submodules") + EXECUTE_PROCESS(COMMAND ${UPDATE_SUBMODULES_COMMAND} + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE update_result) + ENDIF() + ENDIF() +ENDIF() + +IF(update_result OR NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt) + MESSAGE(FATAL_ERROR "No MariaDB Connector/C! Run + ${GIT_EXECUTABLE} submodule update --init --recursive +Then restart the build.${SUBMODULE_UPDATE_CONFIG_MESSAGE}") +ENDIF() |