Using Fortran with CMake
Ein Beitrag dazu ist hier in der CMake Mailingsliste zu finden.
Vorgehen:
CMakeLists.txt
The project must specify all languages that are being used in the
project.
PROJECT(add_fortran CXX Fortran)
ADD_EXECUTABLE(add_fortran main.cpp testf1.F testf2.f testf3.f90)
You must which linker to use for a multiple language project.
SET_TARGET_PROPERTIES(add_fortran PROPERTIES LINKER_LANGUAGE CXX)
You need to find and link with libg2c (I _think_ this applies only if
you are using g77)
FIND_PATH(G2C_DIR libg2c.a /opt/local/lib)
LINK_DIRECTORIES(${G2C_DIR})
TARGET_LINK_LIBRARIES(add_fortran g2c)
Letztlich habe ich für das Einbinden der Bibliotheken von gfortran die beiden folgenden Aufrufe verwendet:
LINK_LIBRARIES ( gfortranbegin gfortran SystemStubs System)
LINK_DIRECTORIES(/usr/local/lib/gcc/powerpc-apple-darwin8.4.0/4.1.0 /usr/local/lib/gcc/powerpc-apple-darwin8.4.0/4.1.0/../../..)