summaryrefslogtreecommitdiff
path: root/cmake/submodules.cmake
blob: 672a3affc1d501b6a76789871076bbc40cb7479f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# update submodules automatically
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(git_config_get_result EQUAL 128 OR cmake_update_submodules MATCHES no)
    SET(update_result 0)
  ELSEIF (cmake_update_submodules MATCHES force)
    MESSAGE(STATUS "Updating submodules (forced)")
    EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --force
                    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
                    RESULT_VARIABLE update_result)
  ELSEIF (cmake_update_submodules MATCHES yes)
    EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init
                    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
                    RESULT_VARIABLE update_result)
  ELSE()
    MESSAGE(STATUS "Updating submodules")
    EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init
                    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 submodule update --init
Then restart the build.
")
ENDIF()