[CMake] Ada and CMake

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Feb 27 22:54:18 EST 2007


On 2007-02-27 21:38-0500 Bill Hoffman wrote:

> Alan W. Irwin wrote:
>> A question for the CMake developers: how difficult would it be to add
>> support for <SOURCE> when interpreting CMAKE_(LANG)_LINK_EXECUTABLE?
>> 
>> As explained above without this core change to CMake it is impossible to
>> implement a useful ADD_EXECUTABLE for Ada, and I am forced to use a rather
>> complicated custom rule instead (see
>> http://plplot.cvs.sourceforge.net/plplot/plplot/examples/ada/CMakeLists.txt 
>> for an example of such a rule.)
>> greatly improve the level of testing of this Ada interface to PLplot.

> What would <SOURCE> be expanded out to be?

The first source file that is supplied to add_executable.  Normally,
gnatmake uses just a single "main" source code file to figure everything out
for all other Ada source code files that the main routine depends on.  Those
dependencies are indicated by the chain of Ada "with" commands that appear
in those source files starting with the main routine.  So normally, only one
"main" source code file would be specified for add_executable in the Ada
context.

Note, gnatmake can handle more than one main source code file, but it makes
an executable for each one it encounters, and that makes no sense from the
add_executable perspective.  So that is why I have specified that <SOURCE>
should refer just to the first source file that is supplied to
add_executable.  Ada developers that know what they are doing would only
specify one "main" source code file to add_executable, but if they specify
more, then with the above definition of <SOURCE> the additional files would
be silently ignored.

Note, perhaps an even better alternative would be to error out for the 
ADD_EXECUTABLE/Ada case if more than one source file is specified. In
contrast, multiple file names are normally required for the ADD_LIBRARY/Ada
case since each file has to be separately compiled (by gnatgcc which doesn't
follow dependencies like gnatmake does) and put into the library.

In sum, gnatgcc handles compiling and linking into a library in a manner
identical to gcc (it is actually a symlink to an Ada-enabled gcc on Linux
systems) so ADD_LIBRARY for the Ada case is easy to implement.  However,
gnatmake is required to actually link a viable executable, and the rules are
very different in that case. Thus, an implementation of <SOURCE> (as defined
above) for the CMAKE_(LANG)_LINK_EXECUTABLE case is required to make
ADD_EXECUTABLE work properly in the Ada case.

If you do find the time to implement <SOURCE> for the
CMAKE_(LANG)_LINK_EXECUTABLE case in CVS, I would be happy to test it.

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 Yorick front-end to PLplot (yplot.sf.net); 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