From 1445fdfc7b076212b2747023dcb3e6c7b5d15366 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Thu, 13 Aug 2020 09:02:10 +0200 Subject: [PATCH] [CMake] Speed-up SubmoduleSetup.cmake (1.3 s -> 0.4 s). --- CMakeLists.txt | 3 --- scripts/cmake/SubmoduleSetup.cmake | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8589e083e2a..a211c7c6a0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,9 +158,6 @@ endif() # Code coverage option(OGS_COVERAGE "Enables code coverage measurements with gcov/lcov." OFF) -option(OGS_SYNC_SUBMODULES - "Sync git submodules on CMake run. Overwrites custom URLs!" ON) - # Options controlling which FEM elements will be compiled set(OGS_MAX_ELEMENT_DIM 3 diff --git a/scripts/cmake/SubmoduleSetup.cmake b/scripts/cmake/SubmoduleSetup.cmake index 7fa03a91e16..7f8b97fce7e 100644 --- a/scripts/cmake/SubmoduleSetup.cmake +++ b/scripts/cmake/SubmoduleSetup.cmake @@ -37,20 +37,20 @@ if (OGS_USE_MFRONT) list(APPEND REQUIRED_SUBMODULES ThirdParty/MGIS) endif() -# Sync submodules, which is required when a submodule changed its URL -if(OGS_SYNC_SUBMODULES) - execute_process( - COMMAND ${GIT_EXECUTABLE} submodule sync - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_QUIET - ) -endif() -foreach(SUBMODULE ${REQUIRED_SUBMODULES}) - execute_process( - COMMAND ${GIT_EXECUTABLE} submodule status ${SUBMODULE} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE SUBMODULE_STATE - ) +execute_process( + COMMAND ${GIT_EXECUTABLE} submodule status + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE SUBMODULES_STATE +) +string(REPLACE "\n" ";" SUBMODULES_LIST ${SUBMODULES_STATE}) + +foreach(SUBMODULE_STATE ${SUBMODULES_LIST}) + + string(REGEX MATCH "ThirdParty/[A-Za-z0-9_-]*" SUBMODULE ${SUBMODULE_STATE}) + if(NOT ${SUBMODULE} IN_LIST REQUIRED_SUBMODULES) + continue() + endif() + string(REGEX MATCH "^\\-" UNINITIALIZED ${SUBMODULE_STATE}) string(REGEX MATCH "^\\+" MISMATCH ${SUBMODULE_STATE}) -- GitLab