From 0da7be73b2da2bacafb19f79504abef180162df6 Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Tue, 22 Jul 2025 11:59:13 +0200 Subject: [PATCH] add git_tag --- .gitmodules | 3 +++ client/CMakeLists.txt | 2 +- client/main.cpp | 3 ++- external/CMakeLists.txt | 1 + external/git_tag_cpp | 1 + server/CMakeLists.txt | 1 + server/main.cpp | 3 ++- 7 files changed, 11 insertions(+), 3 deletions(-) create mode 160000 external/git_tag_cpp diff --git a/.gitmodules b/.gitmodules index 8c4419f..204a732 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "external/json"] path = external/json url = https://github.com/nlohmann/json.git +[submodule "external/git_tag_cpp"] + path = external/git_tag_cpp + url = git@github.com:Sani7/git_tag_cpp.git diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6810819..75579a1 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -92,7 +92,7 @@ target_include_directories(client ${PROJECT_BINARY_DIR}/ ) -target_link_libraries(client PRIVATE qwt spdlog Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WebSockets magic_enum::magic_enum nlohmann_json::nlohmann_json) +target_link_libraries(client PRIVATE qwt spdlog Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::WebSockets magic_enum::magic_enum nlohmann_json::nlohmann_json git_tag) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an diff --git a/client/main.cpp b/client/main.cpp index de0951d..3f49e97 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "git_version.h" #ifdef EMSCRIPTEN #include @@ -31,7 +32,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); QCommandLineParser parser; - parser.setApplicationDescription("unisim_cpp client"); + parser.setApplicationDescription("unisim_cpp client - version: " + QString::fromStdString(Git_version::shortSha1) + QString::fromStdString(Git_version::dirty ? "-dirty" : "")); parser.addHelpOption(); QCommandLineOption host_option(QStringList() << "s" diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index be3f20e..4b781fe 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(color) add_subdirectory(cpp-templates) +add_subdirectory(git_tag_cpp) add_subdirectory(json) add_subdirectory(magic_enum) add_subdirectory(spdlog) diff --git a/external/git_tag_cpp b/external/git_tag_cpp new file mode 160000 index 0000000..9d15e60 --- /dev/null +++ b/external/git_tag_cpp @@ -0,0 +1 @@ +Subproject commit 9d15e605c412639bda1dd1cf752739b2b481583e diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index e3107b2..b15e462 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -62,6 +62,7 @@ target_link_libraries(server PRIVATE UI cpp_templates ${GPIOD_LIB} + git_tag ) diff --git a/server/main.cpp b/server/main.cpp index 1abfe7d..ce50895 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -7,6 +7,7 @@ #include "spdlog/spdlog.h" #include "simulators.hpp" +#include "git_version.h" void init_logger() { @@ -28,7 +29,7 @@ int main(int argc, char *argv[]) QCoreApplication a(argc, argv); QCommandLineParser parser; - parser.setApplicationDescription("unisim_cpp server"); + parser.setApplicationDescription("unisim_cpp server - version: " + QString::fromStdString(Git_version::shortSha1) + QString::fromStdString(Git_version::dirty ? "-dirty" : "")); parser.addHelpOption(); QCommandLineOption port_option(QStringList() << "p"