[CMake] how to avoid deletion of add_custom_commands generated files?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri May 4 13:18:15 EDT 2007


On 2007-05-04 11:53-0300 Bráulio Oliveira wrote:

> Hello all,
>
> I'm creating a Qt4 based project using Cmake. I have some translations files
> which are gererated with the command:
> ADD_CUSTOM_COMMAND(OUTPUT ${tsfiles}
>                        COMMAND ${QT_LUPDATE_EXECUTABLE}
>                        ARGS ${CMAKE_CURRENT_SOURCE_DIR} -ts ${tsfiles}
>                        DEPENDS ${sources}
>                        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>                       )
>
> where 'tsfiles' are the translations files and 'sources' are the source
> files (.cpp and .h) from which these files are generated. But the
> translations files are update with the translation by Qt Linguist. As I
> realize, when I run 'make clean' 'tsfiles' are all deleted, but this is
> unwanted since it was the translations already made shouldn't be lost. Is
> there any way to remove 'tsfiles' from the clean list?

In general, it is not a good idea to create files with CMake which are
subsequently changed with another command that is not under CMake control.
So how about getting around this by simply copying (by hand) what you need
for Qt Linguist?

However, if you are absolutely wedded to the idea of post-CMake file
modification, then I would try using an additional COMMAND in your
ADD_CUSTOM_COMMAND to create an empty file (say called timestamp_tsfiles)
and use that as the OUTPUT rather than ${tsfiles}.  Of course, this means
the creation of ${tsfiles} becomes a side-effect of your ADD_CUSTOM_COMMAND,
and you will have to change any CMake file dependencies that depend on
${tsfiles} to timestamp_tsfiles.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list