From f9a126c8f45ef0d7f61b8fa7c6db922208d9e800 Mon Sep 17 00:00:00 2001 From: Manuel Huber Date: Mon, 7 Nov 2022 12:03:47 +0100 Subject: [PATCH 1/3] Add CMake support --- CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a600fa3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.10 FATAL_ERROR) + +project(BluePassServer LANGUAGES CXX) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt5 + COMPONENTS Core Gui Widgets Bluetooth + REQUIRED +) + +add_compile_options(-Wall -Wextra -Wpedantic) + +add_executable(BluePassServer + app_constants.h + bluetooth_device_list_model.cpp + bluetooth_device_list_model.h + bluetooth_service.cpp + bluetooth_service.h + choose_adapter_dialog.cpp + choose_adapter_dialog.h + dashboard.cpp + dashboard.h + main.cpp + main_app.cpp + main_app.h + settings.cpp + settings.h + settings_type.cpp + settings_type.h + bpserver.qrc + choose_adapter_dialog.ui + dashboard.ui +) + +target_include_directories(BluePassServer PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + +target_compile_definitions(BluePassServer PRIVATE + -DQT_DEPRECATED_WARNINGS=1 + -DQT_DISABLE_DEPRECATED_BEFORE=0xFFFFFF +) + +target_link_libraries(BluePassServer + Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Bluetooth +) + +set_property(TARGET BluePassServer PROPERTY CXX_STANDARD 11) From e61a7931d628b844c79b6caf65addc2913a77595 Mon Sep 17 00:00:00 2001 From: Manuel Huber Date: Mon, 7 Nov 2022 12:11:47 +0100 Subject: [PATCH 2/3] ci: Switch to CMake build Switch to CMake using Ninja. The Makefile based approach didn't work out of the box for Windows. Adjust the packaging procedure for Windows (it seems that I relied on the release folder being created by make on Windows). --- .appveyor.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 6a7475e..4cf7c4b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,17 +7,16 @@ install: - sh: export DEBIAN_FRONTEND=noninteractive - sh: ./ci/install-qt-dependencies.sh - sh: ./ci/install-linuxdeployqt.sh $HOME/bin - - sh: export PATH="$HOME/Qt/5.15.2/gcc_64/bin:$HOME/bin:$PATH" + - sh: export QTDIR="$HOME/Qt/5.15.2/gcc_64" + - sh: export PATH="$QTDIR/bin:$HOME/bin:$PATH" build_script: - - qmake BluePassServer.pro - - cmd: mingw32-make - - sh: make -j 4 + - cmd: cmake -G "Ninja" -DQt5_DIR=%QTDIR%\lib\Qt5 . + - sh: cmake -G "Ninja" -DQt5_DIR=$QTDIR/lib/cmake/Qt5 . + - ninja after_build: - - cmd: windeployqt release/BluePassServer.exe - - cmd: rm release/*.o - - cmd: rm release/*.cpp - - cmd: rm release/*.h - - cmd: mv release bluepass-server-win32 + - cmd: mkdir bluepass-server-win32 + - cmd: cp BluePassServer.exe bluepass-server-win32/ + - cmd: windeployqt bluepass-server-win32/BluePassServer.exe - sh: mkdir bluepass-server-linux - sh: cp BluePassServer bluepass-server-linux/ - sh: VERSION=${APPVEYOR_REPO_TAG_NAME} ./ci/package-appimage-linux.sh From 8ed24b4d4aa2b1e2e1b25130dac9bb2a432f24ac Mon Sep 17 00:00:00 2001 From: Manuel Huber Date: Mon, 7 Nov 2022 14:14:18 +0100 Subject: [PATCH 3/3] Add version information Show version information of this project. Use https://github.com/boon-code/c-git-version.git to track version information during the build. --- .appveyor.yml | 1 + .gitmodules | 3 +++ CMakeLists.txt | 10 ++++++++++ dashboard.cpp | 13 +++++++++++++ dashboard.h | 1 + main_app.cpp | 12 ++++++++++++ modules/c_git_version | 1 + 7 files changed, 41 insertions(+) create mode 100644 .gitmodules create mode 160000 modules/c_git_version diff --git a/.appveyor.yml b/.appveyor.yml index 4cf7c4b..91a4735 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,6 +2,7 @@ image: - Ubuntu1604 - Visual Studio 2019 install: + - git submodule update --init --recursive - cmd: set QTDIR=C:\Qt\5.15\mingw81_32 - cmd: set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw810_32\bin;%PATH%; - sh: export DEBIAN_FRONTEND=noninteractive diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e7403e7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/c_git_version"] + path = modules/c_git_version + url = https://github.com/boon-code/c-git-version.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a600fa3..e9db069 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project(BluePassServer LANGUAGES CXX) +option(HAS_VERSION "The project includes versioning information" ON) +if(HAS_VERSION) + add_subdirectory(modules/c_git_version) +endif() + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) @@ -42,6 +47,11 @@ target_compile_definitions(BluePassServer PRIVATE -DQT_DISABLE_DEPRECATED_BEFORE=0xFFFFFF ) +if(HAS_VERSION) + target_compile_definitions(BluePassServer PRIVATE -DHAS_VERSION=1) + target_link_libraries(BluePassServer c_git_version) +endif() + target_link_libraries(BluePassServer Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Bluetooth ) diff --git a/dashboard.cpp b/dashboard.cpp index 9086217..3956e2b 100644 --- a/dashboard.cpp +++ b/dashboard.cpp @@ -7,6 +7,9 @@ #include #include #include +#ifdef HAS_VERSION +#include "c_git_version.h" +#endif #define MAX_DISCOVERABLE_TIME_MS 60000 @@ -29,6 +32,7 @@ Dashboard::Dashboard(Settings *settings, QWidget *parent) : bt_service_started_(false) { ui->setupUi(this); + setTitle(); updateSettingsView(); setupTray(); on_configurationChanged(current_settings_); @@ -226,6 +230,15 @@ void Dashboard::updateTrayIcon() } } +void Dashboard::setTitle() +{ +#ifdef HAS_VERSION + this->setWindowTitle(QString("BluePassServer %1").arg(c_git_version())); +#else + this->setWindowTitle("BluePassServer"); +#endif +} + void Dashboard::on_dbbOkCancel_accepted() { settings_->updateSettings(current_settings_); diff --git a/dashboard.h b/dashboard.h index fd834db..5a3675a 100644 --- a/dashboard.h +++ b/dashboard.h @@ -54,6 +54,7 @@ private slots: void copyToClipboard(const QString& code); void updateDiscoverableText(); void updateTrayIcon(); + void setTitle(); private: Ui::Dashboard *ui; diff --git a/main_app.cpp b/main_app.cpp index c3e7d46..526bcc4 100644 --- a/main_app.cpp +++ b/main_app.cpp @@ -3,6 +3,9 @@ #include #include +#ifdef HAS_VERSION +#include "c_git_version.h" +#endif MainApp::MainApp(QObject *parent) : QObject(parent), @@ -55,4 +58,13 @@ void MainApp::setOrganizationFields() QCoreApplication::setOrganizationName(ORG_NAME); QCoreApplication::setOrganizationDomain(ORG_NAME); QCoreApplication::setApplicationName(APP_NAME); + +#ifdef HAS_VERSION + QCoreApplication::setApplicationVersion(c_git_version()); + + qDebug() << "Version: " << c_git_version(); + qDebug() << "Branch: " << c_git_branch(); + qDebug() << "Hash: " << c_git_hash(); + qDebug() << "Submodules: " << c_git_submodules(); +#endif } diff --git a/modules/c_git_version b/modules/c_git_version new file mode 160000 index 0000000..8130756 --- /dev/null +++ b/modules/c_git_version @@ -0,0 +1 @@ +Subproject commit 8130756047d51fa0b84cdb66126b04e2b72c2ae5