[CMake] [CMake ] Specify linker for a mixed language Fortran/C++ application (linux)
Brad King
brad.king at kitware.com
Tue Jun 28 09:48:19 EDT 2011
On 06/27/2011 02:39 PM, Raphael Münster wrote:
> # name of the project
> PROJECT(Q2P1)
>
> enable_language (Fortran)
Languages can also be specified in the project command:
project(Q2P1 C CXX Fortran)
> I invoke cmake like this "CC=mpicc CXX=mpic++ cmake -DCMAKE_Fortran_COMPILER=mpif90"
FYI, you can use
CC=mpicc CXX=mpic++ FC=mpif90 cmake ...
and you do not need to set CMAKE_Fortran_COMPILER at all in the cmake code.
> So the question is how can I tell cmake to use mpif90 to link the program?
Set the LINKER_LANGUAGE target property:
http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:LINKER_LANGUAGE
with code like
set_property(TARGET Q2P1 PROPERTY LINKER_LANGUAGE Fortran)
-Brad
More information about the CMake
mailing list