Skip to content

Commit

Permalink
Add git hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
EhWhoAmI committed May 24, 2023
1 parent b7b0847 commit d9c97d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
10 changes: 10 additions & 0 deletions src/test_application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
#include <string_view>
#include <thread>
#include <unordered_map>
#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;

Expand Down Expand Up @@ -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(), ' ');
Expand Down

0 comments on commit d9c97d3

Please sign in to comment.