mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
update:重写获取构建时间方法
This commit is contained in:
@@ -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})
|
||||
|
||||
12
src/main.cpp
12
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");
|
||||
|
||||
Reference in New Issue
Block a user