[CMake] Dependencies for EXEC_PROGRAM

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Oct 1 18:42:44 EDT 2007


On 2007-10-01 14:15-0700 Neal Meyer wrote:

> I've got a static library that contains generated code, today this is
> done in a make file so I can check the dependencies before the PERL
> script is called again during the build process.  I'm adding a
> CustomBuildCommand to the project, so the dependecies are properly
> checked in my vcproj files.
>
> I'm wondering if anybody has any clues on how this might be done in a
> CMake file.  Right now I just have EXEC_PROGRAM being called
> everytime, which just addes some time to the processing that seems to
> be a waste.

First, EXEC_PROGRAM is deprecated in favour of EXECUTE_PROCESS, but both
are normally executed at cmake time rather than run time so I don't think
they are suitable for what you need.

Second, look for GENERATED in the documentation to see one method of dealing
with generated code.  However, I could not get that to work for the case of
a library in one directory being dependent on code generated by a rule set
up by a CMakeLists.txt file in a different directory.  The solution in that
case was to have the library depend on a custom target in another directory.
The custom target (see 
http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/include/CMakeLists.txt?view=log)
has no internal command, but instead file depends on a custom command which
actually contains the command that generates the source code.  Furthermore,
the custom command has the file dependencies of that command.  The result is
the header in question is built only when needed which is what you want.

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