[CMake] Auto-convert all IDL files in a tree?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat Jun 23 17:44:32 EDT 2007


On 2007-06-23 15:37-0400 Dave Wolfe wrote:

> I have a project with some (home-brewed) IDL files that I need to run a
> python script on to convert to CPP.  Some of these IDL files include
> other IDL files, which may, in turn, include *other* IDL files.  I
> really only need to convert the 'top-level' files, i.e., the ones that
> are NOT included by any other file.
>
> The existing IDL-to-CPP script will tell me which files are top-level
> files if I feed it the right commandline arg, and it will also enumerate
> the dependencies (included files) of a given IDL file.  So I think I've
> got all the pieces I need but... can anyone recommend a way of hooking
> this all up to CMake?

It appears from what you have said, that you have a generated cpp file that
depends on a top-level idl file and the idl files that top-level idl file
includes.  Since at any time you could edit the top-level idl file or the
included idl files to include yet additional files or drop some included
files, it sounds like you need to deal with the dependencies dynamically at
build time rather than cmake time.  I don't know how you can set that up
with cmake, but it is an interesting question, and I hope others here
have a good answer for you.

There is an obvious analogy here with project C/C++ header files changing
with more/less files being included as the #include commands get changed.
It's possible CMake does deal with that case properly, but I am not sure.
For the C/C++ case you may have to explicitly list all the headers as part
of the C/C++ source list, and of course that is (a) subject to human error
and (b) not dynamic.

If you were willing to accept static idl dependencies then you could use
EXECUTE_PROCESS to run your python script to generate the cpp file and
determine a static list of idl dependencies at cmake time, and use
ADD_CUSTOM_COMMAND to regenerate the cpp file (if necessary) at build time
(i.e., make time) if any of the static list of dependencies has been
changed/edited (aside from changes to include commands).  Of course, you
could remove the cache file and rerun cmake to update the list of static
dependencies that are paid attention to in the Makefile, but that takes
human understanding of when the include statements have changed so the
procedure is subject to human error but may be a compromise that reasonably
satisfies your needs.

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