qmake touch function on windows

Viewed 621

The qmake manual documents a touch function to update the time stamp of a file, see: touch(filename, reference_filename). It is recommended here to update the timestamp on a file, e.g.:

version.commands = touch $$version.target

Note: the qmake manual documents two parameters, e.g.:

version.commands = touch $$version.target $$version.depends

However, I can't get the touch function to work on Windows using either call. I suspect that qmake is simply calling the linux touch command, since it works fine on Fedora 23.

A workaround is to create a touch.cmd command file on Windows, e.g.:

@COPY /B %1+,, %1

and use the following in the .pro file:

version.commands = $$system(touch $$version.target)

But I would prefer to use the qmake touch function...

What is the correct way to invoke it in a .pro file so that it works on Windows?

1 Answers

In using qmake, it's critical to remember what things are happening on invocation of qmake and what's happening during the subsequent make/nmake call.

Anything that's specified after version.commands = is going to be executed when make gets invoked.

On the other hand, touch() is a qmake function that will get invoked when you run qmake.

Looking in the Qt source code dev branch as of today, there are just 4 uses of touch() within Qt itself, all in the qtbase/mkspecs/features directory, and none in the context of a .commands construct.

Related