[CMake] how to link intel fortran libraries static
Michael Wild
themiwi at gmail.com
Thu Jan 22 02:39:43 EST 2009
On 21. Jan, 2009, at 19:05, Roland Krause wrote:
> Greetings,
> I'm working on CMake support for a very large Fortran code. We are
> linking nearly everything static, especially the Intel Fortran
> libraries but I can't seem to find the flag to do this in the CMake
> documentation (looked at CMake-2.6.x online). I've found
> SET(CMAKE_DL_LIBS "dl") in the Modules/Platform/Linux-ifort.cmake.
> Is that it?
>
No, CMAKE_DL_LIBS is for libdl, the dynamic linker (i.e. "plugin"
loading). You need to pass the -static-intel flag to the compiler
during linking. You can to that either using the LINK_FLAGS target
property (but then make very sure that you're really using an intel
compiler in you CMakeLists.txt) or set the CMAKE_XXX_LINKER_FLAGS in
the cache (where XXX is one of EXE, SHARED or MODULE).
This worked for me:
project(test Fortran)
add_executable( test test.f90 )
# test whether this is an intel compiler, then use -static-intel when
linking
if( CMAKE_Fortran_COMPILER_ID STREQUAL Intel )
set_target_properties( test PROPERTIES LINK_FLAGS -static-intel )
endif( CMAKE_Fortran_COMPILER_ID STREQUAL Intel )
> Thanks for any pointers.
>
> Roland
HTH
Michael
More information about the CMake
mailing list