From 19c04c281a90a3ef11f53b12f9ef30c9fd0abd99 Mon Sep 17 00:00:00 2001 From: Cloudwalk Date: Thu, 16 Sep 2021 20:55:27 -0400 Subject: [PATCH] cmake: Don't try setting revision if git isn't found --- buildsys/target/engine.cmake | 38 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/buildsys/target/engine.cmake b/buildsys/target/engine.cmake index bc2ee5fd..191f176a 100644 --- a/buildsys/target/engine.cmake +++ b/buildsys/target/engine.cmake @@ -3,20 +3,30 @@ target_compile_definitions(common INTERFACE -D_FILE_OFFSET_BITS=64 -D__KERNEL_ST set(ENV{TZ} "UTC") -# Build a version string for the engine. -execute_process( - COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE revision - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -execute_process( - COMMAND "git show -s --format=%ad --date='format-local:%a %b %d %Y %H:%M:%S UTC'" - OUTPUT_VARIABLE timestamp - OUTPUT_STRIP_TRAILING_WHITESPACE -) -set(DP_BUILD_REVISION "${timestamp} - ${revision}") +find_package(Git) + +if(NOT GIT_FOUND AND NOT EXISTS ${CMAKE_SOURCE_DIR}/.git) + message(WARNING "Both the .git directory and Git itself were not found. Commit-based version strings are unavailable. Consider installing git and downloading the repository using it") +elseif(NOT GIT_FOUND) + message(WARNING "Git not found. Commit-based version strings are unavailable. Consider installing git.") +elseif(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git) + message(WARNING ".git directory not found. Commit-based version strings are unavailable. Consider downloading the repository using git") +else() + # Build a version string for the engine + execute_process( + COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE revision + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + execute_process( + COMMAND "git show -s --format=%ad --date='format-local:%a %b %d %Y %H:%M:%S UTC'" + OUTPUT_VARIABLE timestamp + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(DP_BUILD_REVISION "${timestamp} - ${revision}") +endif() if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x|i[36])86|AMD64") option(ENGINE_CONFIG_SSE "Build with SSE support (x86 and x86_64 only)" ON) -- 2.39.2