Question

Such qmake project (*.pro) code successfully work under Ubuntu Linux, but under Windows 8 it don't:

win32 {
    BUILD_TIME = $$system ("time /T")
}
else
{
    BUILD_TIME = $$system ("time")
}
message($$BUILD_TIME) # output the current time

The output is "time /T", i.e. command itself instead of command execution value. Is this behaviour a bug, or just i'm doing smth wrong? :)

UPD: i've found the another way to obtain current date: $$_DATE_. However, i don't like to use undocumented feature - it is bad idea.

P.S. My target is just to generate unique build ID string. I'm using Qt 4.8.5.

Was it helpful?

Solution

The following commands work fine for me:

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

Note, that I removed space between $$system and ("time /T")

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top