From 85ca5dfb86253d0f7db5869d7c922b54b4b310c2 Mon Sep 17 00:00:00 2001 From: momen Date: Fri, 8 Aug 2025 12:46:00 +0800 Subject: [PATCH] =?UTF-8?q?update:=E9=87=8D=E5=86=99=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=97=B6=E9=97=B4=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CMakeLists.txt | 6 ++++++ src/main.cpp | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fcdce80..203b654 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,12 @@ find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network Svg WebEngineWidgets Concurrent) find_package(Dtk6 REQUIRED COMPONENTS Core Gui Widget) +# 添加构建时间宏 +string(TIMESTAMP BUILD_DATE "%Y.%m.%d" UTC) +string(TIMESTAMP BUILD_TIME "%H:%M:%S" UTC) +add_definitions(-DBUILD_DATE="${BUILD_DATE}") +add_definitions(-DBUILD_TIME="${BUILD_TIME}") + include(src.cmake) add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES} ${QRC_FILE}) diff --git a/src/main.cpp b/src/main.cpp index 84bce65..2e155e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -110,11 +110,13 @@ int main(int argc, char *argv[]) signal(SIGSEGV, crashHandler); // 注册SIGSEGV处理函数 - // Get build time - static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy"); - static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss"); - buildDateTime = buildDate.toString("yyyy.MM.dd") + "-" + buildTime.toString("hh:mm:ss"); - + // // Get build time + // static const QDate buildDate = QLocale(QLocale::English).toDate(QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy"); + // static const QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss"); + // buildDateTime = buildDate.toString("yyyy.MM.dd") + "-" + buildTime.toString("hh:mm:ss"); + + //在cmakelist.txt中设置 buildDateTime + QString buildDateTime = QString("%1-%2").arg(QString(BUILD_DATE)).arg(QString(BUILD_TIME)); // NOTE: 提前设置组织名称和应用名称,避免配置文件位置错误 DApplication::setOrganizationName("spark-union");