summaryrefslogtreecommitdiffstats
path: root/cmake/submodules.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:07:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:07:14 +0000
commita175314c3e5827eb193872241446f2f8f5c9d33c (patch)
treecd3d60ca99ae00829c52a6ca79150a5b6e62528b /cmake/submodules.cmake
parentInitial commit. (diff)
downloadmariadb-10.5-upstream.tar.xz
mariadb-10.5-upstream.zip
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--cmake/submodules.cmake41
1 files changed, 41 insertions, 0 deletions
diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake
new file mode 100644
index 00000000..91f9f9e4
--- /dev/null
+++ b/cmake/submodules.cmake
@@ -0,0 +1,41 @@
+# 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)
+ ELSEIF (cmake_update_submodules MATCHES force)
+ MESSAGE(STATUS "Updating submodules (forced)")
+ EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --force --recursive --depth=1
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ RESULT_VARIABLE update_result)
+ ELSEIF (cmake_update_submodules MATCHES yes)
+ EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive --depth=1
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ RESULT_VARIABLE update_result)
+ ELSE()
+ MESSAGE(STATUS "Updating submodules")
+ EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive --depth=1
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ RESULT_VARIABLE update_result)
+ 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()