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");