From 58240fa2e1ac4234cf67374349ce606f1b6df643 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Sun, 7 Jan 2024 16:15:57 +0100 Subject: Use configure_file instead of setting compile defs This should avoid unnecessary recompiles of the whole project when the git hash changes and the project is reconfigured. --- CMakeLists.txt | 7 ++----- gen/git_version.h.in | 3 +++ src/aboutdialog.cpp | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 gen/git_version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ac0bc1d..68c3d28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,11 +119,8 @@ else() endif() endif() -if (GIT_DESCRIBE_TEXT) - target_compile_definitions(ActorViewer PRIVATE GIT_DESCRIBE_TEXT=${GIT_DESCRIBE_TEXT}) -else() - target_compile_definitions(ActorViewer PRIVATE GIT_COMMIT_HASH=${GIT_COMMIT_HASH}) -endif() +configure_file(gen/git_version.h.in gen/git_version.h) +target_include_directories(ActorViewer PRIVATE gen) target_link_libraries(ActorViewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets mastodonpp) diff --git a/gen/git_version.h.in b/gen/git_version.h.in new file mode 100644 index 0000000..8732171 --- /dev/null +++ b/gen/git_version.h.in @@ -0,0 +1,3 @@ +#pragma once +#cmakedefine GIT_DESCRIBE_TEXT ${GIT_DESCRIBE_TEXT} +#cmakedefine GIT_COMMIT_HASH ${GIT_COMMIT_HASH} diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp index 3583a5e..ac670bb 100644 --- a/src/aboutdialog.cpp +++ b/src/aboutdialog.cpp @@ -1,5 +1,6 @@ #include "aboutdialog.h" -#include +#include "gen/git_version.h" +#include AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent, Qt::Dialog), ui(new Ui::AboutDialog) -- cgit v1.2.3-54-g00ecf