[CMake] begginer Q on generated headers with generated tool

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Apr 30 11:09:56 EDT 2007


On 2007-04-30 09:09-0400 Alexander Neundorf wrote:

> On Monday 30 April 2007 08:48, Jesús López wrote:
>> Hi,
>> Congrats for CMake, finally something I can understand speedy,
>> instead of the autohell.. :-)
>>
>> Just a begginer's question if some find the time to it.
>>
>> I have a project that generates custom IDL to H compiler needed for
>> building, I have a big include directoy full with common headers used
>> by several targets each in a directory, and some missing headers need
>> to be created invocating that IDL2H.
>>
>> I've read in the FAQ how to create headers depending on custom
>> generators, but in the  example all happens in only one
>> directory/cmakelists, instead of a proyect spanning in several.
>
> Do you have any special problems with this ?
>
>> Is there some clean strategy to do this. And also is there a way to
>> avoid the need of include the generated headers as explicit
>> dependencies of the main targets,
>
> No, adding them to the source files for a target is the way to express the
> dependency.

Alexander, in my experience that strategy does not work for a library built
in one directory with header generated in another.  (If there is a way to do
it please let me know.) Instead, you have to make the library depend on the
custom target that generates (through dependencies) the header.

Jesús, for the practical example that you requested, see
http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/src/CMakeLists.txt?view=markup
(look for add_dependencies on line 130), and line 32 through 58 of
http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/include/CMakeLists.txt?view=markup.

This example works for all our platforms (Linux, Mac OS X, several different
windows platforms), and also for "make -j2" on Linux.  Note, a custom
command is used to generate the header, and an empty custom target that is
always executed when the library is built depends on that custom command.
The result of this seemingly complicated arrangement is efficiency; the
header is generated only when absolutely needed so there are no unnecessary
rebuilds of the library.

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