[CMake] FindMPI

Raymond Wan rwan.work at gmail.com
Fri Sep 11 05:10:37 EDT 2015


Hi Nico,


On Fri, Sep 11, 2015 at 4:53 PM, Nico Schlömer <nico.schloemer at gmail.com> wrote:
> I see from the CMake docs [1] that the recommended way for using MPI is to
> call `find_package(MPI)` and set the linker and include flags appropriately.
> On the other hand, I see from the OpenMPI specs [2] that
>
>>
>
> The Open MPI team strongly recommends that you simply use Open MPI's
>
>> "wrapper" compilers to compile your MPI applications.
>
>
> Is there a way to reconcile these two approaches?


I'm not sure what is the "right" way to do things, but FindMPI and the
Open MPI's doc doesn't really contradict with each other.

If you look at the source for FindMPI.cmake, the variable for
MPI_<lang>_COMPILER gets set to the path of the wrapper.  So, the
wrapper is found.  Honestly, I've never tried replacing the compiler
in my CMake with this wrapper, without setting any libraries...it
might work?

CMake is suppose to be for cross-platform development.  Some other
system might have MPI but no wrapper compiler.  So, perhaps for this
reason, it's a good idea not to rely on the wrapper?

Maybe you could use the wrapper and if MPI_<lang>_COMPILER is not set,
then set the library, etc. the CMake way?

As for the Open MPI's suggestion, I don't think that paragraph means
that they suggest it over CMake's method.  I think what it is
suggesting is to use the wrapper over trying to worry about the
libraries and options "manually" -- which is a pain.

Ray


More information about the CMake mailing list