From 021f88930583b3cf0865f653dacb00bef0cb513c Mon Sep 17 00:00:00 2001 From: Bilal Kahraman Date: Fri, 16 Aug 2024 00:04:56 +0300 Subject: [PATCH] Pull submodules with cmake --- CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea5d35e..e3a16b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,25 @@ add_definitions( set(CMAKE_BUILD_TYPE Debug) # set(CMAKE_BUILD_TYPE Release) + +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") +# Update submodules as needed + option(GIT_SUBMODULE "Check submodules during build" ON) + if(GIT_SUBMODULE) + message(STATUS "Submodule update") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() +endif() + +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/uuid_v4/CMakeLists.txt") + message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") +endif() + # internal libraries add_subdirectory(app) add_subdirectory(src/Camera)