4

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?

Community
  • 1
  • 1
kenba
  • 4,303
  • 1
  • 23
  • 40
  • system(@COPY /B file.name "+,,") - worked fine for me – oklas Jun 06 '16 at 22:26
  • It worked for me too @oklas, but it's still not the elusive `qmake touch`. Roll on [bash on Windows 10](https://msdn.microsoft.com/en-us/commandline/wsl/about)... – kenba Jun 07 '16 at 06:47

1 Answers1

0

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.

gmabey
  • 15
  • 1
  • 6