ADD_CUSTOM_TARGET question (was RE: [CMake] Version embedding - how
to cause a command when make is run?)
Atwood, Robert C
r.atwood at imperial.ac.uk
Fri Oct 5 14:03:39 EDT 2007
Hi:
I think I've got it (the CMAKE bit, for whichever svn command is
eventually used) nearly ...
> -----Original Message-----
> From: Alan W. Irwin [mailto:irwin at beluga.phys.uvic.ca]
> Sent: 04 October 2007 18:07
> If that is more information than you want in your executables, then to
> answer your original query, I suggest looking in the cmake
> documentation for
> the ADD_CUSTOM_COMMAND(TARGET signature. I believe the
> POST_BUILD option
> for that command will do exactly what you want, but it has
> been a while
> since I tried that option.
It would be PRE_BUILD, but that appears not to work at present with
Unix makefiles.
"Note that the PRE_BUILD option is only supported on Visual Studio 7 or
later. For all other generators PRE_BUILD will be treated as PRE_LINK."
(verified by trying it as well)
But, I think thanks in part to you pointer, I found the following and it
seems to do what I want, using ADD_CUSTOM_TARGET ( in test form here,
the actual command would be whatever eventually seems the best
Revision-control software command) along with ADD_DEPENDENCIES. Then it
always puts the build date into the include file (and crashes in this
case because it's not embedded in a character string. That's how I could
easily tell if it happened before or after the compilation!)
But, this requres 'echo' , or at least '>>' , does any one know if the
'file(append' or a builtin cmake-command can be invoked here to do the
same on any platform? Or does it need a platform specific tool for each
platform?
Thanks for the lead!
Robert
258
259 ADD_CUSTOM_TARGET(includer
260 COMMAND echo '/*custom command*/' >> ${INCFILE}
261 COMMAND date >> ${INCFILE} #<--this crashes the build if
it's added before...
262 WORKING_DIRECTORY ${uMatIC_SOURCE_DIR})
263 ADD_DEPENDENCIES(ca_run includer)
More information about the CMake
mailing list