[CMake] Extension proposal: CheckFortranFuinctionExists.cmake

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Jun 25 10:05:15 EDT 2008


On 2008-06-25 15:15+0200 Hauke Heibel wrote:

> Hi there,
>
> I started diving into the world of CMake and spend the last two days in 
> trying to convert a project of mine to be working with CMake.
>
> We are using BLAS in the project, so obviously I gave FIND_PACKAGE(BLAS) a 
> shot. In the beginning it was not really working, but I found a workaround 
> which I would like to discuss - maybe it will be useful for others as well.
>
> So here is the scenario. I am given a machine having only access to static 
> pre-compiled libraries of BLAS (in my case atlas.lib, cblas.lib and 
> f77blas.lib). It would be great if the FIND_PACKAGE script would allow me to 
> use these libraries even when I do not have a Fortran compiler at hand. Why 
> should I need it anyways - the libs are pre-compiled.
>
> So in the first step I managed to get FindBLAS.cmake running that far, that 
> it finds the libs but as said before, it was failing due to the missing 
> Fortran compiler. To resolve this final issue I did the following.
>
> Since Fortran compiled libraries can be used from C/C++, why not simply 
> create a test based on a .cpp file. I gave it a try and it seems to work:

I think that assumption needs lots of qualifiers.  Did your run-time
actually give correct numerical results when linking from a C main programme
to f77blas.lib? Interfacing C/C++ and Fortran is a tricky business. There is
a project called cfortran that tries to do it for all the different Unix
variants, but it is pretty complicated because of various naming conventions
on each brand of Unix. Because of those complications, systems often have
both C and Fortran versions of BLAS installed.  For example, it appears your
system has cblas.lib which is the library I think you want to link to from
C/C++ code.

To check whether a function exists in that C library, you need to use
CheckFunctionExists instead of CheckFortranFunctionExists. Therefore, I
suggest you make a completely separate FindCBLAS.cmake that looks only for C
versions of BLAS and tests with CheckFunctionExists.  That gives the
build-system designer the option of using either FindCBLAS.cmake or
FindBLAS.cmake depending on which language variant of the library they want.
(That choice is not clear simply from the languages that are enabled since
you can have both Fortran and C enabled for a single project.)

Using the same analogy, I think we also should have a separate
FindCLAPACK.cmake to find and test the C variant of the LAPACK library.

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 libLASi project (unifont.org/lasi); 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