From bd97f3a3807ba14daa1c3506b114daa0abe80562 Mon Sep 17 00:00:00 2001 From: luocai Date: Fri, 21 Jun 2024 11:33:11 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=9E=E7=8E=B0=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=BA=94=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Analyser/Application.cpp | 2 ++ Analyser/CMakeLists.txt | 5 +++++ Analyser/Configuration.h.in | 2 ++ Analyser/main.cpp | 4 ++++ Analyser/qml/main.qml | 2 +- CMakeLists.txt | 6 ++++++ 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Analyser/Configuration.h.in diff --git a/Analyser/Application.cpp b/Analyser/Application.cpp index f635b01..6f6305d 100644 --- a/Analyser/Application.cpp +++ b/Analyser/Application.cpp @@ -2,6 +2,7 @@ #include "AsyncEvent.h" #include "BoostLog.h" #include "CategoryLogSinkBackend.h" +#include "Configuration.h" #include "Database.h" #include "DeviceDiscovery.h" #include "VideoFrameProvider.h" @@ -18,6 +19,7 @@ constexpr uint32_t ImageSliceSize = 2048; Application::Application(int &argc, char **argv) : m_app(std::make_shared(argc, argv)) { + m_app->setApplicationVersion(QString("v%1_%2 build: %3 %4").arg(APP_VERSION, GIT_COMMIT_ID, __DATE__, __TIME__)); QFont font; font.setPointSize(16); m_app->setFont(font); diff --git a/Analyser/CMakeLists.txt b/Analyser/CMakeLists.txt index 198bf38..66179dc 100644 --- a/Analyser/CMakeLists.txt +++ b/Analyser/CMakeLists.txt @@ -1,9 +1,13 @@ +project(Analyser VERSION 0.2 LANGUAGES C CXX) + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick QuickTemplates2 Widgets SerialPort) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Quick QuickTemplates2 Widgets SerialPort) +configure_file(Configuration.h.in Configuration.h) + add_executable(Analyser Analyser.rc main.cpp Application.h Application.cpp @@ -40,6 +44,7 @@ endif() target_include_directories(Analyser PRIVATE ${FFmpeg_INCLUDE_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) target_link_directories(Analyser diff --git a/Analyser/Configuration.h.in b/Analyser/Configuration.h.in new file mode 100644 index 0000000..88bb89d --- /dev/null +++ b/Analyser/Configuration.h.in @@ -0,0 +1,2 @@ +#define GIT_COMMIT_ID "@GIT_COMMIT_ID@" +#define APP_VERSION "@PROJECT_VERSION@" diff --git a/Analyser/main.cpp b/Analyser/main.cpp index ae5b6ee..269b7a5 100644 --- a/Analyser/main.cpp +++ b/Analyser/main.cpp @@ -1,11 +1,15 @@ #include "Application.h" #include "BoostLog.h" +#include "Configuration.h" #include "DeviceDiscovery.h" #include "Widget.h" int main(int argc, char *argv[]) { using namespace Amass; boost::log::initialize("logs/app"); + LOG(info) << "Compiled on: " << __DATE__ << " " << __TIME__ << std::endl; + LOG(info) << "Git commit ID: " << GIT_COMMIT_ID << std::endl; + LOG(info) << "Program version: " << APP_VERSION << std::endl; auto app = Singleton::instance(argc, argv); app->initializeLogger(); diff --git a/Analyser/qml/main.qml b/Analyser/qml/main.qml index 443cbc1..9316873 100644 --- a/Analyser/qml/main.qml +++ b/Analyser/qml/main.qml @@ -7,7 +7,7 @@ Window { width: 1120 height: 640 visible: true - title: qsTr("L015上位机工具") + title: qsTr("L015上位机工具 "+Qt.application.version) OperationItem { id: operationItem diff --git a/CMakeLists.txt b/CMakeLists.txt index 2222d4f..a0cac42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,12 @@ set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.1-full_build-shared) set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include) set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib) +execute_process( + COMMAND D:/msys64/usr/bin/git rev-parse --short HEAD + OUTPUT_VARIABLE GIT_COMMIT_ID + OUTPUT_STRIP_TRAILING_WHITESPACE +) + add_subdirectory(${Projects_ROOT}/Kylin/Universal Universal) add_subdirectory(${Projects_ROOT}/Kylin/Encrypt Encrypt) add_subdirectory(${Projects_ROOT}/Kylin/QtComponets QtComponets)