era*_*lan 4 qt qmake build qt4
此类qmake项目 (*.pro) 代码在 Ubuntu Linux 下成功运行,但在 Windows 8 下则不能:
win32 {
BUILD_TIME = $$system ("time /T")
}
else
{
BUILD_TIME = $$system ("time")
}
message($$BUILD_TIME) # output the current time
Run Code Online (Sandbox Code Playgroud)
输出是“time /T”,即命令本身而不是命令执行值。这种行为是错误,还是只是我做错了?:)
UPD:我找到了另一种获取当前日期的方法:$$_DATE_。但是,我不喜欢使用未记录的功能 - 这是个坏主意。
PS 我的目标只是生成唯一的构建 ID 字符串。我正在使用 Qt 4.8.5。
以下命令对我来说很好用:
win32 {
BUILD_TIME = $$system("time /T") # no spaces between 'system' command and args.
} else {
BUILD_TIME = $$system("time")
}
message($$BUILD_TIME) # output the current time
Run Code Online (Sandbox Code Playgroud)
请注意,我删除了$$system和("time /T")