[CMake] How to compile a file only when linking anyhow?
Mark Jonas
toertel at gmail.com
Thu Apr 17 03:18:51 EDT 2008
Hi Alex,
thanks for your input.
> > How do I tell the custom command to run when the linker will be
> > called? It should not run always because that would cause the linker
> > to be called whenever I call make.
> You could use something like:
> ADD_CUSTOM_COMMAND(TARGET target POST_BUILD
> COMMAND touch build_timestamp.c)
I tried that before and it has a bad side effect: The linker is now
called every time I run make although the source did not change. What
I am shooting for is that build_timestamp.c is compiled only when the
application would be linked anyhow.
Additionally, the solution uses a command that wouldn't work if the
output of CMake would be e.g. a Visual Studio project.
> then the file will be newer than the executable everytime the executable is
> built (and have build_timestamp.c part of your regular set of source files).
Exactly. You might be asking now why I am insisting not calling the
linker when it is not really necessary. The reason is that the
application I would like to use CMake with has about 1,000,000 source
lines. Linking the little monster takes about 5 minutes on a modern
PC.
Do you have another idea?
TIA,
Mark
More information about the CMake
mailing list