From 9ca672821737f571daddbe8480ef1f6f998eb536 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 16 Jul 2017 19:52:05 +0100 Subject: [PATCH] CMakeLists: Check that all submodules are present --- CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad73cf495..9151ff786 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,21 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit) DESTINATION ${CMAKE_SOURCE_DIR}/.git/hooks) endif() +# Sanity check : Check that all submodules are present +# ======================================================================= + +function(check_submodules_present) + file(READ "${CMAKE_SOURCE_DIR}/.gitmodules" gitmodules) + string(REGEX MATCHALL "path *= *[^ \t\r\n]*" gitmodules ${gitmodules}) + foreach(module ${gitmodules}) + string(REGEX REPLACE "path *= *" "" module ${module}) + if (NOT EXISTS "${CMAKE_SOURCE_DIR}/${module}/.git") + message(SEND_ERROR "Git submodule ${module} not found." + "Please run: git submodule update --init --recursive") + endif() + endforeach() +endfunction() +check_submodules_present() # Detect current compilation architecture and create standard definitions # =======================================================================