Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git hash #235

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try using a submodule instead? This is for consistency with how all other libraries are added. It can be put it in the 3rdparty directory, and added using add_subdirectory. the other dependencies work as examples.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I'm curious/concerned about is how this library selects which git repository to read info from. Most likely, it won't select itself. It somehow has to obtain the parent that added it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright I'll do some testing and see how that works out

# 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't it have this header?

#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