[CMake] Auxiliary fortran link libraries?

Brad King brad.king at kitware.com
Mon Jul 19 14:43:51 EDT 2010


On 07/19/2010 11:46 AM, John R. Cary wrote:
> So the lapack libraries are actually needed as a dependency of
> Trilinos, another C++ library, which does the calling of the
> symbols, and it must get those right, because if I add them to
> the link line, then all links and runs.
> 
> Now I happen to know what those libraries were compiled with,
      ^^^^^^^^^^^^^^^^
...but CMake and Trilinos don't.  Ideally the libraries should
come in packages that have some kind of standard configuration
file to document in a machine-readable way how they were built.
Since they don't, manual interference will be needed in general.

I think Trilinos autodetects the mangling used in blas and lapack
and assumes a matching Fortran.

> and I passed the correct fortran, so I also know that what is
> here:
> 
>   numbersix.cary$ grep IMPLICIT CMakeFiles/CMakeFortranCompiler.cmake
>   SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "gfortran")
>   SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES
>   "/usr/local/lib/gcc/x86_64-apple-darwin10/4.5.0;/usr/local/lib")
> 
> So can I just INCLUDE CMakeFiles/CMakeFortranCompiler.cmake and
> then add these libraries to my target in cases where I know they
> are correct?
> 
> Or perhaps the include is done automatically?

The presence of that file is undocumented but it is always included
as part of enabling a language anyway.  The variables mentioned above
*are* documented so you can reference them.  However, this is a
workaround too.  If you have a C/C++ project that depends on Trilinos
your code should not have to be aware of the Trilinos->blas->Fortran
dependency.

Note that if you use the *shared* libblas.so and liblapack.so then
you do not need to list the implementation dependencies explicitly.
Another way to view this is that when you pointed Trilinos at the
blas and lapack libraries to use, you chose the static ones but
did not mention their dependencies.  This is where the manual
interference comes in.

You could set TPL_LAPACK_LIBRARIES and TPL_BLAS_LIBRARIES to list
the dependencies (by full path!).  Indeed, these variables are
documented as

"List of semi-colon separated full paths to the libraries for
 the TPL BLAS.  This is the final variable that is used in the
 link commands."

-Brad


More information about the CMake mailing list