[CMake] Ada and CMake

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Feb 25 15:35:09 EST 2007


On 2007-02-24 12:03-0800 Alan W. Irwin wrote:

> I am a rank Ada beginner, but nevertheless somebody just donated an Ada
> interface to PLplot so I am trying to get on top of what changes to our
> CMake build system will be required to build and install an Ada project
> library interfacing Ada with the PLplot core library.  We also need to build
> and install Ada examples using the new project library.  I presume we will
> be using the GNAT compiler (i.e., gnatmake) for all builds including the
> relinking required for installs.
>
> Anyhow, if anyone here has played with GNAT/Ada and CMake, I would appreciate
> your advice and experience.

I have now learned that the GNAT compiler is simply and add-on to gcc, and
in fact all the low-level compilations of Ada source in the GNAT case are
done by gcc.  Also, Ada keeps track of dependency issues for itself so the
high-level gnatmake command can be used as a front-end to gcc with all
compilations done only when needed.
For example, in a simple case with no dependencies

gnatmake -c -fPIC plplot.adb

results in running

gcc -c -fPIC plplot.adb

which compiles that ada source into plplot.o. (A plplot.ali file is
created as well to help keep track of Ada dependencies, but that can be
ignored as far as CMake is concerned.)  To build a library of the results
you use the gcc command as normal, e.g.,

gcc -shared -FPIC plplot.o -o libplplotada.so.0.0.0

I currently handle all of this with custom commands that are suitable just
for Linux shared libraries.  I could add other platforms and deal with
the question of static libraries on all platforms as well.  However, this
seems like "reinventing the wheel".

Thus, I would like to do

add_library(plplotada plplot.adb)

instead without worrying about custom commands, the question of static or
shared libraries, or cross-platform issues (the gnat variation of the gcc
compiler is also available on Mac OS X and windows):

In order for the add_library command to work, I need to modify CMake (or
CMake modules or variables) so that

* gnatmake is temporarily considered as the gcc compiler (note it takes
the usual -c and -fPIC options of gcc since it is just a front-end for
an ada-enabled version of gcc.)

* *.adb files are considered to be "C" source.  (When I tried the add_library
approach, cmake complained that the language could not be recognized.  Is this
a matter of simply telling CMake that the ".adb" suffix is acceptable to gcc
for compilation?

Can somebody tell me how to arrange the above modifications? Note, gcc
should be kept as the linker command.

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