When building with Cray MPICH it seems to default is to us a static MPI library. I have in the project set BUILD_SHARED_LIBS
so my resulting library is shared but since the Cray MPICH compiler is building statically it seems inconsistent in FindMPI looking for static library. Should FindMPI check the BUILD_SHARED_LIBS
and add the required option to MPI_COMPILER_FLAGS
to make this consistent. If I do this manually on the cmake command line with -DMPI_COMPILER_FLAGS=-shared
it finds the shared MPI library and everything works and picks up the required dependencies via environment variables pointing to other shared library locations.
At the moment with the default finding of static MPI library it requires extra libraries to be passed to it at link stage since the output from mpicc -show
doesn’t provide all the libraries it requires (in this case libfabric and librt). This will be reported to HPE.
I’m not particularly familiar with the FindMPI module, but in general, BUILD_SHARED_LIBS
is only relevant for things built by your project. Find modules are generally finding already-built things, so they should pretty much ignore BUILD_SHARED_LIBS
.
Instead, some Find modules might have their own controls for preferring static over shared, or projects might use multiple calls to find_package()
with different PATHS
, HINTS
, or NAMES
and various NO_...
options to convince a find module to prefer finding static over shared. You’d have to go through the documentation of the FindMPI module to see if there’s a formally supported way to achieve the outcome you are looking for.
I know that’s not a very satisfying answer, but I hope at least I’ve answered the BUILD_SHARED_LIBS
part for you.
Thanks. My thoughts were that if my project is wanting to build a shared library should it not also check that its dependencies are shared? I see other modules such as FindwxWidgets and FindCUDA using BUILD_SHARED_LIBS as a proxy for whether to link to shared or static version of the libraries. At least there is a way to specify the flag for MPI but consistent behaviour for modules would be nice.