From d9c97d327a017ee782a7d2c0b262201d4d31d03d Mon Sep 17 00:00:00 2001 From: EhWhoAmI Date: Wed, 24 May 2023 10:38:47 +0800 Subject: [PATCH] Add git hash. Fixes #85 --- CMakeLists.txt | 8 ++++++++ src/CMakeLists.txt | 3 ++- src/test_application/main.cpp | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80a0fd24..510dd6db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,14 @@ if(NOT MSVC) add_compile_options(-fno-omit-frame-pointer) endif() +include(FetchContent) + +FetchContent_Declare(cmake_git_version_tracking + GIT_REPOSITORY https://github.com/andrew-hardin/cmake-git-version-tracking.git + GIT_TAG 904dbda1336ba4b9a1415a68d5f203f576b696bb +) +FetchContent_MakeAvailable(cmake_git_version_tracking) + # Compiler warnings can help find problems in code. IF(OSP_ENABLE_COMPILER_WARNINGS) # Enable additional warnings. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c16b8226..3ab91d06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,7 +102,8 @@ SET(OSP_MAGNUM_DEPS_LIBS dNewton dScene dModel dVehicle toml11 spdlog - longeron) + longeron + cmake_git_version_tracking) target_link_libraries(osp-magnum-deps INTERFACE ${OSP_MAGNUM_DEPS_LIBS}) add_dependencies(compile-osp-magnum-deps ${OSP_MAGNUM_DEPS_LIBS}) diff --git a/src/test_application/main.cpp b/src/test_application/main.cpp index 45f6f1df..66205d49 100644 --- a/src/test_application/main.cpp +++ b/src/test_application/main.cpp @@ -64,6 +64,14 @@ #include #include #include +#if __has_include("git.h") +#include "git.h" +#define GIT_HASH git_Describe() +#define GIT_BRANCH git_Branch() +#else +#define GIT_HASH "00000" +#define GIT_BRANCH "n/a" +#endif using namespace testapp; @@ -495,6 +503,8 @@ void debug_print_help() << "OSP-Magnum Temporary Debug CLI\n" << "Open a scenario:\n"; + std::cout << "Version: " << GIT_HASH << " (" << GIT_BRANCH << ")\n"; + for (auto const& [name, rTestScn] : scenarios()) { std::string spaces(longestName - name.length(), ' ');