From 494d078db6e44360135be804c4fbe1aa5573f054 Mon Sep 17 00:00:00 2001 From: Rob Baruch Date: Mon, 18 Jul 2022 22:55:36 -0400 Subject: [PATCH] modified version switch to build without .git repo directory and added -DMANUAL_GITINFO define to manual add git tagging data on the cmake command line --- CMakeLists.txt | 2 ++ git.cc.in | 6 +++++- git_watcher.cmake | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 263b02a38..fde4ae6f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ cmake_minimum_required(VERSION 3.2) project(Trunk-Recorder LANGUAGES CXX C VERSION "4.3.2") configure_file(cmake.h.in "${PROJECT_SOURCE_DIR}/cmake.h" @ONLY) +ADD_COMPILE_DEFINITIONS(MANUAL_GITINFO="${MANUAL_GITINFO}") + # Define the two required variables before including # the source code for watching a git repository. diff --git a/git.cc.in b/git.cc.in index 881e79316..59bda979f 100644 --- a/git.cc.in +++ b/git.cc.in @@ -50,7 +50,11 @@ void GitMetadata::VersionInfo() { << "\t" << GitMetadata::CommitSubject() << "\n" << GitMetadata::CommitBody() << std::endl; } else { - std::cerr << "WARN: failed to get the current git state. Is this a git repo?" << std::endl; +#ifdef MANUAL_GITINFO + std::cerr << "INFO: manual git info: " << MANUAL_GITINFO << std::endl; +#else + std::cerr << "WARN: no manual git info defined " << std::endl; +#endif } } diff --git a/git_watcher.cmake b/git_watcher.cmake index 4d67e6849..fb2058bcf 100644 --- a/git_watcher.cmake +++ b/git_watcher.cmake @@ -136,7 +136,7 @@ macro(RunGitCommand) # those default values. if(GIT_FAIL_IF_NONZERO_EXIT ) string(REPLACE ";" " " args_with_spaces "${ARGV}") - message(FATAL_ERROR "${stderr} (${GIT_EXECUTABLE} ${args_with_spaces})") + message("${stderr} (${GIT_EXECUTABLE} ${args_with_spaces})") endif() endif() endmacro()