[CMake] linking main Fortran and C++

Jed Brown jed at 59A2.org
Thu Oct 21 11:16:14 EDT 2010


On Thu, Oct 21, 2010 at 16:52, M. Scot Breitenfeld <brtnfld at uiuc.edu> wrote:
>  It was part of a section detecting if mpi is present, if it is then it uses
> the mpi** compiler wrappers instead:
>
> IF ( MPI_FOUND )
>  SET (CMAKE_Fortran_COMPILER  mpif90)
>  SET (CMAKE_CC_COMPILER  mpicc)

This is a typo, should be CMAKE_C_COMPILER.

>  SET (CMAKE_CXX_COMPILER  mpicxx)
> ENDIF()

This approach is horribly non-portable, many systems do not have
wrapper compilers or they have different names.  An easy solution is
for the user to set CMAKE_C_COMPILER themselves, as in cmake
-DCMAKE_C_COMPILER=/path/to/mpicc.  You can also use FindMPI.cmake
(which needs love, it's broken in many batch environments) to
determine the flags needed to compile and link using the unwrapped
compiler.

Jed


More information about the CMake mailing list