diff --git a/CMakeLists.txt b/CMakeLists.txt index 4084b35b..b50ce25b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,13 +67,11 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.git") message(STATUS "GIT not found!?") endif() endif() -add_definitions(-DKNUT_VERSION_STRING="${KNUT_VERSION_STRING}") # Generate build date for the about dialog Note: This is the simplest way to get # a build date out of CMake Drawbacks: The timestamp is only updated when CMake # is rerun. But this should sufficient for our use-case. string(TIMESTAMP KNUT_BUILDDATE "%Y-%m-%d") -add_definitions(-DKNUT_BUILDDATE="${KNUT_BUILDDATE}") # Qt # ############################################################################## diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index eee09984..5fb293a0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -10,6 +10,8 @@ project(knut-core LANGUAGES CXX) +configure_file(version.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/version.cpp) + set(PROJECT_SOURCES astnode.h astnode.cpp @@ -104,6 +106,8 @@ set(PROJECT_SOURCES userdialog.cpp utils.h utils.cpp + version.h + ${CMAKE_CURRENT_BINARY_DIR}/version.cpp core.qrc) add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES}) diff --git a/src/core/version.cpp.in b/src/core/version.cpp.in new file mode 100644 index 00000000..15c04a8a --- /dev/null +++ b/src/core/version.cpp.in @@ -0,0 +1,12 @@ +#include "core/version.h" + +namespace core { + QString knut_version() + { + return "${KNUT_VERSION_STRING}"; + } + + QString knut_build_date() { + return "${KNUT_BUILDDATE}"; + } +} diff --git a/src/core/version.h b/src/core/version.h new file mode 100644 index 00000000..ff16cf50 --- /dev/null +++ b/src/core/version.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace core { +QString knut_version(); +QString knut_build_date(); +} diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index e242aaab..3e1bc107 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -20,6 +20,7 @@ #include "core/slintdocument.h" #include "core/textdocument.h" #include "core/uidocument.h" +#include "core/version.h" #include "documentpalette.h" #include "guisettings.h" #include "historypanel.h" @@ -572,7 +573,7 @@ Build date: %2

Knut name has nothing to do with Knut Irvin, nor with Knut the polar bear.
The name Knut is coming from St Knut, which marks the end of the Christmas and holiday season in Sweden.
See Wikipedia article: Saint Knut's Day.)") - .arg(KNUT_VERSION_STRING, KNUT_BUILDDATE); + .arg(core::knut_version(), core::knut_build_date()); QMessageBox dialog(QMessageBox::Information, tr("About Knut"), text, QMessageBox::Ok, this); dialog.setIconPixmap(QPixmap(":/gui/icons/knut-64.png")); dialog.exec(); diff --git a/src/main.cpp b/src/main.cpp index 75624e47..bb2116ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ Contact KDAB at for commercial licensing options. */ +#include "core/version.h" #include "gui/knutmain.h" #include @@ -19,7 +20,7 @@ int main(int argc, char *argv[]) QApplication::setOrganizationName("KDAB"); QApplication::setApplicationName("knut"); - QApplication::setApplicationVersion(KNUT_VERSION_STRING); + QApplication::setApplicationVersion(core::knut_version()); QApplication::setWindowIcon(QIcon(":/gui/icons/knut-64.png")); Q_INIT_RESOURCE(core);