On 06/29/2011 10:04 AM, Yngve Inntjore Levinsen wrote: > Tirsdag 28 juni 2011 18.52.48 skrev Raphael Muenster : >> Yep, great) setting the LINKER_LANGUAGE to Fortran did it. >> >> Thanks, >> Raphael >> >> Am 28.06.2011 15:48, schrieb Brad King: >>> 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 >>> _______________________________________________ >>> Powered by www.kitware.com >>> >>> Visit other Kitware open-source projects at >>> http://www.kitware.com/opensource/opensource.html >>> >>> Please keep messages on-topic and check the CMake FAQ at: >>> http://www.cmake.org/Wiki/CMake_FAQ >>> >>> Follow this link to subscribe/unsubscribe: >>> http://www.cmake.org/mailman/listinfo/cmake >> >> _______________________________________________ >> Powered by www.kitware.com >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Please keep messages on-topic and check the CMake FAQ at: >> http://www.cmake.org/Wiki/CMake_FAQ >> >> Follow this link to subscribe/unsubscribe: >> http://www.cmake.org/mailman/listinfo/cmake >> > > > Just as a side-note, mpif90 is a wrapper compiler for mpi right? Have a look > at this thread, which discusses the recommended way to > compile MPI code with cmake: > http://www.cmake.org/pipermail/cmake/2011-June/045032.html > > My preferred way is also to specify in the project() command which languages > are used. That way if you have a pure fortran project cmake doesn't test your > c/c++ compiler etc. > > Cheers, > Yngve
Presumedly, the OP's concern isn't related to MPI but to the selection of the linker in a mixed-language target; as Raphael says, the linker command succeeds when mpic++ is replaced by mpif90. My assumption is rather that the C++ library the Fortran program is linked against is a static one, so the default settings CMAKE_CXX_LINKER_PREFERENCE = 30 CMAKE_Fortran_LINKER_PREFERENCE = 20 CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES = 1 bring the C++ linker into play, and it will preempt the Fortran one. The solution is - as already suggested - to set the target's linker language manually, switch off the linker preference's propagation for static C++ libraries or provide Fortran with a higher linker preference than C++. Regards, Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake