diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/mariadb_connector_c.cmake | 14 | ||||
-rw-r--r-- | cmake/submodules.cmake | 30 |
3 files changed, 31 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c3bb7bef9e2..ed80c5b8889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,7 +363,7 @@ ENDIF() SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "") -# mariadb_connector_c fetches submodules which is useful for plugins +INCLUDE(submodules) INCLUDE(mariadb_connector_c) # this does ADD_SUBDIRECTORY(libmariadb) # Add storage engines and plugins. diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake index 400fcda0c1a..6773314313b 100644 --- a/cmake/mariadb_connector_c.cmake +++ b/cmake/mariadb_connector_c.cmake @@ -1,17 +1,3 @@ -IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt AND GIT_EXECUTABLE) - EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule init - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") - EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") -ENDIF() -IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt) - MESSAGE(FATAL_ERROR "No MariaDB Connector/C! Run - git submodule init - git submodule update -Then restart the build. -") -ENDIF() - SET(OPT CONC_) IF (CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake new file mode 100644 index 00000000000..61eacba7c73 --- /dev/null +++ b/cmake/submodules.cmake @@ -0,0 +1,30 @@ +# 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) + IF(cmake_update_submodules MATCHES no) + SET(update_result 0) + ELSEIF (cmake_update_submodules MATCHES force) + MESSAGE("-- 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("-- 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() |