perpetually executed custom commands and timestamps

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

perpetually executed custom commands and timestamps

Pawel Veselov
Hello.

I'm trying something I don't think is unreasonable.

I need to have an automatically generated file, let's say version.h

I have to run a custom command to generate it.

The contents of the file depend on some external forces, the custom command m
ay or may not change it (but it will always generate it if it is there).

That header is then included in bunch of other files, creating multiple 
targets

So, I created a custom command that has declared output of version.h, and 
have version.h included as sources for other (multiple) targets. This worked,
but, of course, if the version.h is already there, the command wouldn't run.

I couldn't find any way to force the command to run, so after reading this
SO post: https://stackoverflow.com/questions/13920072, I added a PHONY output
to the command, and dependency to the targets. This forced the command to
run every time.

However, when the command runs, but doesn't change the output file, there is
some target that forces the file to be updated (the touch_nocreate). This
causes the targets to both recompile and relink for no reason.

Questions:
1) Can I make a custom command run every time, even if its target is present
(without creating a PHONY target)? I don't want the 
2) Can I turn the touching off?

I don't think using TARGET based custom command is right, as it's a pre-build
target activity, and such is not supported for !VS.

I don't think using an ALL custom target is right, because custom target has
no output files, and target-to-target dependency wouldn't correctly determine
that I need that .h file in time.

I would love to know what's the point of touch_no_create, really, I can't
imagine a good reason the file is refreshed when it wasn't touched, it seems
that the point would be to "cheat" the dependency resolution that way, which
may have valid use cases, but as a forced default?

Thank you,
  Pawel.


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake