[CMake] Please support FindLAPACK/FindBLAS for C/C++-only projects

Theodore Papadopoulo Theodore.Papadopoulo at sophia.inria.fr
Fri Feb 5 11:45:15 EST 2010


I have been following this discussion silently, as the problem of 
interfacing C/C++ with blas and lapack
(and without obliging users to install a fortran compiler) is recurrent 
in a few of the projects I'm involved in.

I'm attaching (for comments) a modified FortranCInterface.cmake that 
basically has two modes. If a fortran and
a C compiler are available, it works as it does currently except for teo 
things:
- Error messages when C or Fortran compiler is missing should be much 
more understandable....
- If the source list is "", then create_fortran_c_interface creates 
generic macros if possible...
  Eg: create_fortran_c_interface("" "" 
${CMAKE_CURRENT_BINARY_DIR}/src/fortran.h)

But I have also added a new function: discover_fortran_c_interface
Without parameters, this function attempts to find the C/Fortran 
mangling from compilers (create_fortran_c_interface
actually now uses that function). But more interestingly, this function 
can be called with parameters:

discover_fortran_c_interface(LIBRARY FUNCTIONS) will attempts to 
discover the mangling from an installed
library LIBRARY which should contain the functions FUNCTIONS (right now 
I'm testing only up to two of those
functions (one containing an _ an another without _). Then, 
create_fortran_c_interface can be used as usual to
create mangled manes (or generic interface).

Example of use:
SET(FUNCTIONS dgesvd daxpy dgess dcopy) # Blas and lapack functions
discover_fortran_c_interface(blas dcopy)
create_fortran_c_interface("" FUNCTIONS 
${CMAKE_CURRENT_BINARY_DIR}/src/fortran.h)

This work is not totally finished: lack of support for modules, lack of 
proper error messages when
mangling functions with _ when mangling has been detected only for 
functions without _ (and vice versa),
maybe a new way of calling create_fortran_c_interface:
create_fortran_c_interface(PREFIX FUNCTIONS FILE LIBRARY lib functions) 
or even
create_fortran_c_interface(PREFIX FUNCTIONS FILE lib functions)
where LIBRARY is meant to be an option keyword...

Still it is in a usable state, so I'd like to gather comments:
1) whether the idea is considered useful.
2) could it be integrated with the standard FortranCInterface module.
3) any suggestions for improvements in both the interface and the 
implementation.
4) ...

    Thank's a lot

       Theo.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: FortranCInterface.cmake
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100205/35054146/attachment.txt>


More information about the CMake mailing list