2017-07-10 15:06:41 +02:00
|
|
|
# update submodules automatically
|
2018-10-03 15:29:16 +02:00
|
|
|
|
|
|
|
OPTION(UPDATE_SUBMODULES "Update submodules automatically" ON)
|
|
|
|
IF(NOT UPDATE_SUBMODULES)
|
|
|
|
RETURN()
|
|
|
|
ENDIF()
|
|
|
|
|
2017-07-10 15:06:41 +02:00
|
|
|
IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" config --get cmake.update-submodules
|
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
2017-08-22 07:56:53 +02:00
|
|
|
OUTPUT_VARIABLE cmake_update_submodules
|
|
|
|
RESULT_VARIABLE git_config_get_result)
|
2019-02-12 23:03:12 +01:00
|
|
|
IF(cmake_update_submodules MATCHES no)
|
|
|
|
SET(update_result 0)
|
|
|
|
SET(SUBMODULE_UPDATE_CONFIG_MESSAGE
|
2019-02-13 07:48:12 +01:00
|
|
|
"\n\nTo update submodules automatically, set cmake.update-submodules to 'yes', or 'force' to update automatically:
|
2019-02-12 23:03:12 +01:00
|
|
|
${GIT_EXECUTABLE} config cmake.update-submodules yes")
|
|
|
|
ELSEIF(git_config_get_result EQUAL 128)
|
2017-07-10 15:06:41 +02:00
|
|
|
SET(update_result 0)
|
|
|
|
ELSE()
|
2022-03-10 04:07:38 +01:00
|
|
|
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()
|
2017-07-10 15:06:41 +02:00
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(update_result OR NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt)
|
|
|
|
MESSAGE(FATAL_ERROR "No MariaDB Connector/C! Run
|
2019-02-21 14:40:52 +01:00
|
|
|
${GIT_EXECUTABLE} submodule update --init --recursive
|
2019-02-12 23:03:12 +01:00
|
|
|
Then restart the build.${SUBMODULE_UPDATE_CONFIG_MESSAGE}")
|
2017-07-10 15:06:41 +02:00
|
|
|
ENDIF()
|