From 50feacad133e818aedbe50e4b5079c2fa065e79e Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 14 Nov 2021 18:59:41 -0500 Subject: [PATCH] [all] cmake: fail if wrong submodule version is checked out This runs `git submodule summary` and fails the build if there is any output. For developers, use `cmake -DDEVELOPER=yes` to bypass this check. --- cmake/CheckSubmodule.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/CheckSubmodule.cmake b/cmake/CheckSubmodule.cmake index 75490b14..6e18abde 100644 --- a/cmake/CheckSubmodule.cmake +++ b/cmake/CheckSubmodule.cmake @@ -6,3 +6,14 @@ if (EXISTS "${PROJECT_TOP}/.git" AND ( )) message(FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive") endif() + +if (EXISTS "${PROJECT_TOP}/.git" AND NOT DEFINED DEVELOPER) + execute_process( + COMMAND git submodule summary + WORKING_DIRECTORY "${PROJECT_TOP}" + OUTPUT_VARIABLE SUBMODULE_SUMMARY + ) + if (NOT "${SUBMODULE_SUMMARY}" STREQUAL "") + message(FATAL_ERROR "Wrong submodule version checked out. Run\n\tgit submodule update --init --recursive") + endif() +endif()