From c9db190fed4e368201703e3d1031e16abfd61e45 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 10 Jul 2017 15:06:41 +0200 Subject: cmake: update submodules automatically during the build --- cmake/mariadb_connector_c.cmake | 14 -------------- cmake/submodules.cmake | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 cmake/submodules.cmake (limited to 'cmake') 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() -- cgit v1.2.1