[CMake] Ada and CMake

Filipe Sousa natros at gmail.com
Sun Feb 25 17:36:25 EST 2007


Alan W. Irwin wrote:
> On 2007-02-24 12:03-0800 Alan W. Irwin wrote:
> 
> 
> 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.

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

--
Filipe Sousa



More information about the CMake mailing list