[CMake] Ada and CMake

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Feb 27 21:29:47 EST 2007


On 2007-02-25 22:36-0000 Filipe Sousa wrote:

> In Modules directory there is a file with instructions on how to add a new 
> language to cmake.
>
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/CMakeAddNewLanguage.txt?rev=1.1.2.1&root=CMake&view=markup

Thanks to that tip from Filipe, I now have add_library working for Ada on
the two platforms accessible to me (Debian stable and Ubuntu Dapper), and I
think it should also work on most other platforms where the GNAT extension
to the gcc compiler has been installed.  The 4 Ada language support files
for CMake are named as follows: CMakeAdaCompiler.cmake.in,
CMakeAdaInformation.cmake, CMakeDetermineAdaCompiler.cmake, and
CMakeTestAdaCompiler.cmake.  Those files are based on the equivalent Fortran
files distributed with CMake, and most changes can be described by the
following sed command:

sed -e 's?FC?ADA?g' -e 's?_Fortran?_Ada?g' -e 's? Fortran ? Ada ?g'
<inputFortranfile >outputAdafile

although some additional changes had to be made as well.

The Ada language support files can be found at
http://plplot.cvs.sourceforge.net/plplot/plplot/cmake/modules/, and I
encourage everyone interested in Ada support in CMake to try those out.

One current limitation of the Ada language support for CMake is that in
CMakeAdaInformation.cmake, I must use

SET(CMAKE_Ada_LINK_EXECUTABLE  "")

because when CMake uses the pattern in CMAKE_Ada_LINK_EXECUTABLE to link the
executable it does not have access to <SOURCE>, and I therefore cannot use
the proper gnatmake command (which requires access to the source code to
prepare an executable).

The result is add_executable merely compiles Ada code and does not actually
link it into a viable executable.

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.)

The current status is that Ada now has an interface to PLplot (and also one
test example written in Ada that uses PLplot) that can be built with the
CMake build system for PLplot.  Aside from the problem mentioned above with
ADD_EXECUTABLE which forces using custom commands to build executables, it
is looking pretty good. The next step is to write our ~25 standard examples
(currently implemented for all our mature language interfaces) in Ada to
greatly improve the level of testing of this Ada interface to PLplot.

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