chore: make use of CMake project version

This commit is contained in:
Gary Wang 2024-09-17 19:28:05 +08:00
parent 3a4ea573f6
commit 4dd3f22d88
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760
3 changed files with 8 additions and 2 deletions

View File

@ -4,7 +4,7 @@
cmake_minimum_required (VERSION 3.9.5)
project (pineapple-pictures)
project(pineapple-pictures VERSION 0.8.1) # don't forget to update NEWS file and AppStream metadata.
include (GNUInstallDirs)
include (FeatureSummary)
@ -179,6 +179,7 @@ macro (ppic_set_version_via_describe _describe_long)
endmacro ()
# Version setup
target_compile_definitions(${EXE_NAME} PRIVATE PPIC_VERSION_STRING="${CMAKE_PROJECT_VERSION}")
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
find_package(Git)
set_package_properties(Git PROPERTIES TYPE OPTIONAL PURPOSE "Determine exact build version.")

View File

@ -50,9 +50,13 @@ AboutDialog::AboutDialog(QWidget *parent)
const QStringList aboutStr {
QStringLiteral("<center><img width='128' height='128' src=':/icons/app-icon.svg'/><br/>"),
qApp->applicationDisplayName(),
(QStringLiteral("<br/>") + tr("Version: %1").arg(
#ifdef GIT_DESCRIBE_VERSION_STRING
(QStringLiteral("<br/>") + tr("Version: %1").arg(GIT_DESCRIBE_VERSION_STRING)),
GIT_DESCRIBE_VERSION_STRING
#else
qApp->applicationVersion()
#endif // GIT_DESCRIBE_VERSION_STRING
)),
QStringLiteral("<hr/>"),
tr("Copyright (c) %1 %2", "%1 is year, %2 is the name of copyright holder(s)")
.arg(QStringLiteral("2024"), QStringLiteral("<a href='https://github.com/BLumia'>@BLumia</a>")),

View File

@ -39,6 +39,7 @@ int main(int argc, char *argv[])
}
a.setApplicationName("Pineapple Pictures");
a.setApplicationDisplayName(QCoreApplication::translate("main", "Pineapple Pictures"));
a.setApplicationVersion(PPIC_VERSION_STRING);
// commandline options
QCommandLineOption supportedImageFormats(QStringLiteral("supported-image-formats"), QCoreApplication::translate("main", "List supported image format suffixes, and quit program."));