build: generate version info, use it for all sources of version
This commit is contained in:
parent
f321f6596b
commit
4a83eb711f
15 changed files with 39 additions and 114 deletions
|
|
@ -64,8 +64,6 @@ set(DESKFLOW_VERSION_MS_CSV
|
||||||
"${DESKFLOW_VERSION_MAJOR},${DESKFLOW_VERSION_MINOR},${DESKFLOW_VERSION_PATCH},${DESKFLOW_VERSION_TWEAK}"
|
"${DESKFLOW_VERSION_MAJOR},${DESKFLOW_VERSION_MINOR},${DESKFLOW_VERSION_PATCH},${DESKFLOW_VERSION_TWEAK}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(-DDESKFLOW_VERSION="${DESKFLOW_VERSION}")
|
|
||||||
|
|
||||||
#Define our project
|
#Define our project
|
||||||
project(
|
project(
|
||||||
deskflow
|
deskflow
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ macro(configure_definitions)
|
||||||
# Shorten the Git SHA to 8 chars for readability
|
# Shorten the Git SHA to 8 chars for readability
|
||||||
string(SUBSTRING "$ENV{GIT_SHA}" 0 8 GIT_SHA_SHORT)
|
string(SUBSTRING "$ENV{GIT_SHA}" 0 8 GIT_SHA_SHORT)
|
||||||
message(STATUS "Short Git SHA: ${GIT_SHA_SHORT}")
|
message(STATUS "Short Git SHA: ${GIT_SHA_SHORT}")
|
||||||
add_definitions(-DGIT_SHA_SHORT="${GIT_SHA_SHORT}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,6 @@ macro(configure_windows_libs)
|
||||||
/DWIN32
|
/DWIN32
|
||||||
/D_WINDOWS
|
/D_WINDOWS
|
||||||
/D_CRT_SECURE_NO_WARNINGS
|
/D_CRT_SECURE_NO_WARNINGS
|
||||||
/DDESKFLOW_VERSION=\"${DESKFLOW_VERSION}\"
|
|
||||||
/D_XKEYCHECK_H)
|
/D_XKEYCHECK_H)
|
||||||
|
|
||||||
configure_openssl()
|
configure_openssl()
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ elseif(APPLE)
|
||||||
MACOSX_BUNDLE_ICON_FILE Deskflow.icns
|
MACOSX_BUNDLE_ICON_FILE Deskflow.icns
|
||||||
MACOSX_BUNDLE_INFO_STRING "${CMAKE_PROJECT_DESCRIPTION}"
|
MACOSX_BUNDLE_INFO_STRING "${CMAKE_PROJECT_DESCRIPTION}"
|
||||||
MACOSX_BUNDLE_COPYRIGHT "© 2024 Deskflow Developers"
|
MACOSX_BUNDLE_COPYRIGHT "© 2024 Deskflow Developers"
|
||||||
MACOSX_BUNDLE_BUNDLE_VERSION ${DESKFLOW_VERSION}
|
MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}
|
||||||
MACOSX_BUNDLE_LONG_VERSION_STRING ${DESKFLOW_VERSION}
|
MACOSX_BUNDLE_LONG_VERSION_STRING ${CMAKE_PROJECT_VERSION}
|
||||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${DESKFLOW_VERSION}
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${CMAKE_PROJECT_VERSION}
|
||||||
)
|
)
|
||||||
find_program(MACDEPLOYQT_BIN macdeployqt6)
|
find_program(MACDEPLOYQT_BIN macdeployqt6)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
|
|
||||||
|
|
@ -155,8 +155,8 @@ void MainWindow::setupControls()
|
||||||
|
|
||||||
ui->m_pLabelIpAddresses->setText(QString("This computer's IP addresses: %1").arg(getIPAddresses()));
|
ui->m_pLabelIpAddresses->setText(QString("This computer's IP addresses: %1").arg(getIPAddresses()));
|
||||||
|
|
||||||
if (m_AppConfig.lastVersion() != DESKFLOW_VERSION) {
|
if (m_AppConfig.lastVersion() != kVersion) {
|
||||||
m_AppConfig.setLastVersion(DESKFLOW_VERSION);
|
m_AppConfig.setLastVersion(kVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
#include "AboutDialog.h"
|
#include "AboutDialog.h"
|
||||||
|
|
||||||
|
#include "common/constants.h"
|
||||||
#include "common/copyright.h"
|
#include "common/copyright.h"
|
||||||
#include "common/version.h"
|
|
||||||
#include "gui/style_utils.h"
|
#include "gui/style_utils.h"
|
||||||
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
|
@ -34,19 +34,21 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("About Deskflow"));
|
setWindowTitle(tr("About Deskflow"));
|
||||||
|
|
||||||
QString version = QString::fromStdString(deskflow::version());
|
|
||||||
|
|
||||||
auto copyIcon = QIcon::fromTheme(
|
auto copyIcon = QIcon::fromTheme(
|
||||||
QIcon::ThemeIcon::EditCopy, deskflow::gui::isDarkMode() ? QIcon(s_darkCopy) : QIcon(s_lightCopy)
|
QIcon::ThemeIcon::EditCopy, deskflow::gui::isDarkMode() ? QIcon(s_darkCopy) : QIcon(s_lightCopy)
|
||||||
);
|
);
|
||||||
|
|
||||||
auto btnCopyVersion = new QPushButton(copyIcon, QString(), this);
|
auto btnCopyVersion = new QPushButton(copyIcon, QString(), this);
|
||||||
btnCopyVersion->setFlat(true);
|
btnCopyVersion->setFlat(true);
|
||||||
connect(btnCopyVersion, &QPushButton::clicked, this, [version] { qApp->clipboard()->setText(version); });
|
connect(btnCopyVersion, &QPushButton::clicked, this, [] { QGuiApplication::clipboard()->setText(kVersion); });
|
||||||
|
|
||||||
|
auto versionString = QString(kVersion);
|
||||||
|
if (!QString(kVersionGitSha).isEmpty())
|
||||||
|
versionString.append(QStringLiteral(" (%1)").arg(kVersionGitSha));
|
||||||
|
|
||||||
auto versionLayout = new QHBoxLayout();
|
auto versionLayout = new QHBoxLayout();
|
||||||
versionLayout->addWidget(new QLabel(tr("Version:")));
|
versionLayout->addWidget(new QLabel(tr("Version:")));
|
||||||
versionLayout->addWidget(new QLabel(version));
|
versionLayout->addWidget(new QLabel(versionString, this));
|
||||||
versionLayout->addWidget(btnCopyVersion);
|
versionLayout->addWidget(btnCopyVersion);
|
||||||
versionLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
versionLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "SetupWizard.h"
|
#include "SetupWizard.h"
|
||||||
#include "common/constants.h"
|
#include "common/constants.h"
|
||||||
#include "common/version.h"
|
|
||||||
#include "gui/Logger.h"
|
#include "gui/Logger.h"
|
||||||
#include "gui/config/AppConfig.h"
|
#include "gui/config/AppConfig.h"
|
||||||
#include "gui/config/ConfigScopes.h"
|
#include "gui/config/ConfigScopes.h"
|
||||||
|
|
@ -92,8 +91,7 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qInstallMessageHandler(deskflow::gui::messages::messageHandler);
|
qInstallMessageHandler(deskflow::gui::messages::messageHandler);
|
||||||
QString version = QString::fromStdString(deskflow::version());
|
qInfo("%s v%s", kAppName, qPrintable(kVersion));
|
||||||
qInfo("%s v%s", kAppName, qPrintable(version));
|
|
||||||
|
|
||||||
dotenv();
|
dotenv();
|
||||||
Logger::instance().loadEnvVars();
|
Logger::instance().loadEnvVars();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
# SPDX-FileCopyrightText: (C) 2024 Chris Rizzitello <sithlord48@gmail.com>
|
# SPDX-FileCopyrightText: (C) 2024 Chris Rizzitello <sithlord48@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
|
||||||
|
|
||||||
|
configure_file(constants.h.in constants.h @ONLY)
|
||||||
|
|
||||||
add_library(common INTERFACE
|
add_library(common INTERFACE
|
||||||
basic_types.h
|
basic_types.h
|
||||||
common.h
|
common.h
|
||||||
constants.h
|
|
||||||
copyright.h
|
copyright.h
|
||||||
IInterface.h
|
IInterface.h
|
||||||
ipc.h
|
ipc.h
|
||||||
|
|
@ -23,15 +25,10 @@ add_library(common INTERFACE
|
||||||
stdsstream.h
|
stdsstream.h
|
||||||
stdstring.h
|
stdstring.h
|
||||||
stdvector.h
|
stdvector.h
|
||||||
version.h
|
${CMAKE_CURRENT_BINARY_DIR}/constants.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
target_sources(common INTERFACE MacOSXPrecomp.h)
|
target_sources(common INTERFACE MacOSXPrecomp.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(common
|
|
||||||
INTERFACE
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* Copyright (C) 2012 Symless Ltd.
|
|
||||||
* Copyright (C) 2002 Chris Schoeneman
|
|
||||||
*
|
|
||||||
* This package is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* found in the file LICENSE that should have accompanied this file.
|
|
||||||
*
|
|
||||||
* This package is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if !defined(DESKFLOW_VERSION)
|
|
||||||
#error version was not passed to the compiler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const auto kAppName = "Deskflow";
|
|
||||||
const auto kAppId = "deskflow";
|
|
||||||
const auto kAppDescription = "Mouse and keyboard sharing utility";
|
|
||||||
const auto kVersion = DESKFLOW_VERSION;
|
|
||||||
|
|
||||||
#ifdef GIT_SHA_SHORT
|
|
||||||
const auto kVersionGitSha = GIT_SHA_SHORT;
|
|
||||||
#else
|
|
||||||
const auto kVersionGitSha = "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
const auto kDebugBuild = true;
|
|
||||||
#else
|
|
||||||
const auto kDebugBuild = false;
|
|
||||||
#endif
|
|
||||||
19
src/lib/common/constants.h.in
Normal file
19
src/lib/common/constants.h.in
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
// SPDX-FileCopyrightText: (C) 2024 Chris Rizzitello <sithlord48@gmail.com>
|
||||||
|
// SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
||||||
|
// SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
const auto kAppName = "Deskflow";
|
||||||
|
const auto kAppId = "deskflow";
|
||||||
|
const auto kAppDescription = "@CMAKE_PROJECT_DESCRIPTION@";
|
||||||
|
const auto kVersion = "@CMAKE_PROJECT_VERSION@";
|
||||||
|
const auto kVersionGitSha = "@GIT_SHA_SHORT@";
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
const auto kDebugBuild = true;
|
||||||
|
#else
|
||||||
|
const auto kDebugBuild = false;
|
||||||
|
#endif
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* Copyright (C) 2024 Symless Ltd.
|
|
||||||
*
|
|
||||||
* This package is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* found in the file LICENSE that should have accompanied this file.
|
|
||||||
*
|
|
||||||
* This package is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace deskflow {
|
|
||||||
|
|
||||||
inline std::string version()
|
|
||||||
{
|
|
||||||
std::string result = kVersion;
|
|
||||||
std::string gitSha = kVersionGitSha;
|
|
||||||
if (!gitSha.empty()) {
|
|
||||||
result.append(" (");
|
|
||||||
result.append(gitSha);
|
|
||||||
result.append(")");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace deskflow
|
|
||||||
|
|
@ -16,10 +16,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
||||||
/* Define version here for Unix, but using /D for Windows. */
|
|
||||||
#cmakedefine DESKFLOW_VERSION "@DESKFLOW_VERSION@"
|
|
||||||
|
|
||||||
/* Define to the base type of arg 3 for `accept`. */
|
/* Define to the base type of arg 3 for `accept`. */
|
||||||
#cmakedefine ACCEPT_TYPE_ARG3 @ACCEPT_TYPE_ARG3@
|
#cmakedefine ACCEPT_TYPE_ARG3 @ACCEPT_TYPE_ARG3@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
#include "common/constants.h"
|
#include "common/constants.h"
|
||||||
#include "common/copyright.h"
|
#include "common/copyright.h"
|
||||||
#include "common/ipc.h"
|
#include "common/ipc.h"
|
||||||
#include "common/version.h"
|
|
||||||
#include "deskflow/ArgsBase.h"
|
#include "deskflow/ArgsBase.h"
|
||||||
#include "deskflow/Config.h"
|
#include "deskflow/Config.h"
|
||||||
#include "deskflow/XDeskflow.h"
|
#include "deskflow/XDeskflow.h"
|
||||||
|
|
@ -93,13 +92,11 @@ App::~App()
|
||||||
|
|
||||||
void App::version()
|
void App::version()
|
||||||
{
|
{
|
||||||
const auto version = deskflow::version();
|
|
||||||
|
|
||||||
const auto kBufferLength = 1024;
|
const auto kBufferLength = 1024;
|
||||||
std::vector<char> buffer(kBufferLength);
|
std::vector<char> buffer(kBufferLength);
|
||||||
std::snprintf( // NOSONAR
|
std::snprintf( // NOSONAR
|
||||||
buffer.data(), kBufferLength, "%s v%s, protocol v%d.%d\n%s", //
|
buffer.data(), kBufferLength, "%s v%s, protocol v%d.%d\n%s", //
|
||||||
argsBase().m_pname, version.c_str(), kProtocolMajorVersion, kProtocolMinorVersion, deskflow::kCopyright
|
argsBase().m_pname, kVersion, kProtocolMajorVersion, kProtocolMinorVersion, deskflow::kCopyright
|
||||||
);
|
);
|
||||||
|
|
||||||
std::cout << std::string(buffer.data()) << std::endl;
|
std::cout << std::string(buffer.data()) << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ void VersionChecker::replyFinished(QNetworkReply *reply)
|
||||||
const auto newestVersion = QString(reply->readAll());
|
const auto newestVersion = QString(reply->readAll());
|
||||||
qDebug("version check response: %s", qPrintable(newestVersion));
|
qDebug("version check response: %s", qPrintable(newestVersion));
|
||||||
|
|
||||||
if (!newestVersion.isEmpty() && compareVersions(DESKFLOW_VERSION, newestVersion) > 0) {
|
if (!newestVersion.isEmpty() && compareVersions(kVersion, newestVersion) > 0) {
|
||||||
qDebug("update found");
|
qDebug("update found");
|
||||||
Q_EMIT updateFound(newestVersion);
|
Q_EMIT updateFound(newestVersion);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "common/constants.h"
|
#include "common/constants.h"
|
||||||
#include "common/version.h"
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "env_vars.h"
|
#include "env_vars.h"
|
||||||
#include "styles.h"
|
#include "styles.h"
|
||||||
|
|
@ -66,8 +65,7 @@ void showErrorDialog(const QString &message, const QString &fileLine, QtMsgType
|
||||||
" and copy/paste the following error:</p>")
|
" and copy/paste the following error:</p>")
|
||||||
.arg(kUrlHelp, kColorSecondary);
|
.arg(kUrlHelp, kColorSecondary);
|
||||||
|
|
||||||
const QString version = QString::fromStdString(deskflow::version());
|
text += QString("<pre>v%1\n%2\n%3</pre>").arg(kVersion, message, fileLine);
|
||||||
text += QString("<pre>v%1\n%2\n%3</pre>").arg(version, message, fileLine);
|
|
||||||
|
|
||||||
if (type == QtFatalMsg) {
|
if (type == QtFatalMsg) {
|
||||||
// create a blocking message box for fatal errors, as we want to wait
|
// create a blocking message box for fatal errors, as we want to wait
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue