From 13f1086690302d38e8dd2f81839bfa285f514596 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Thu, 13 Aug 2020 09:07:53 +0200 Subject: [PATCH] [CMake] Speed-up PreFind.cmake (0.3 s -> 0.1 s) --- scripts/cmake/PreFind.cmake | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/scripts/cmake/PreFind.cmake b/scripts/cmake/PreFind.cmake index e0b08c78904..58aa681e37f 100644 --- a/scripts/cmake/PreFind.cmake +++ b/scripts/cmake/PreFind.cmake @@ -1,22 +1,24 @@ find_package(Git REQUIRED) -execute_process(COMMAND ${GIT_EXECUTABLE} status - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE IS_GIT_REPO - OUTPUT_QUIET) -if(IS_GIT_REPO GREATER 0) - set(IS_GIT_REPO FALSE CACHE INTERNAL "") - if(DEFINED OGS_VERSION) - message(WARNING "Using user-provided OGS_VERSION: ${OGS_VERSION}!") - message(WARNING "Submodule setup is skipped!") +if(NOT IS_GIT_REPO) + execute_process(COMMAND ${GIT_EXECUTABLE} status + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + RESULT_VARIABLE IS_GIT_REPO + OUTPUT_QUIET) + if(IS_GIT_REPO GREATER 0) + set(IS_GIT_REPO FALSE CACHE INTERNAL "") + if(DEFINED OGS_VERSION) + message(WARNING "Using user-provided OGS_VERSION: ${OGS_VERSION}!") + message(WARNING "Submodule setup is skipped!") + else() + message(FATAL_ERROR "No git repository found at ${PROJECT_SOURCE_DIR}! " + "Please use git to obtain the source code! See " + "https://www.opengeosys.org/docs/devguide/getting-started/get-the-source-code/" + " OR manually set the OGS_VERSION variable.") + endif() else() - message(FATAL_ERROR "No git repository found at ${PROJECT_SOURCE_DIR}! " - "Please use git to obtain the source code! See " - "https://www.opengeosys.org/docs/devguide/getting-started/get-the-source-code/" - " OR manually set the OGS_VERSION variable.") + set(IS_GIT_REPO TRUE CACHE INTERNAL "") endif() -else() -set(IS_GIT_REPO TRUE CACHE INTERNAL "") endif() if(OGS_USE_PYTHON) -- GitLab