Lagrange [release]

CMake: Ensure the submodule is up to date

bc0af8f5f8e25628c7ea488fd0a2ccdfe7494bbb
diff --git a/Depends.cmake b/Depends.cmake
index b4dacf7c..c379fc6d 100644
--- a/Depends.cmake
+++ b/Depends.cmake
@@ -7,7 +7,22 @@ if (NOT EXISTS ${CMAKE_SOURCE_DIR}/lib/the_Foundation/CMakeLists.txt)
     set (INSTALL_THE_FOUNDATION YES)
     find_package (the_Foundation REQUIRED)
 else ()
-    set (INSTALL_THE_FOUNDATION NO)
+    if (EXISTS ${CMAKE_SOURCE_DIR}/lib/the_Foundation/.git)
+        # the_Foundation is checked out as a submodule, make sure it's up to date.
+        find_package (Git)
+        if (GIT_FOUND)
+            execute_process (
+                COMMAND ${GIT_EXECUTABLE} submodule update
+                WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+                OUTPUT_VARIABLE subout
+                OUTPUT_STRIP_TRAILING_WHITESPACE
+            )
+            if (subout)
+                message (FATAL_ERROR "The 'lib/the_Foundation' submodule has been updated, please re-run CMake.\n")
+            endif ()
+        endif ()
+    endif ()
+    set (INSTALL_THE_FOUNDATION OFF)
     set (TFDN_STATIC_LIBRARY    ON  CACHE BOOL "")
     set (TFDN_ENABLE_INSTALL    OFF CACHE BOOL "")
     set (TFDN_ENABLE_TESTS      OFF CACHE BOOL "")