Skip to content

FindMPI: New compiler wrapper parsing logic

This MR replaces the previous, generic parsing logic with a new one based entirely CMake platform variables. After all, CMake knows for a given compiler how -L, -l or -I look like and we can consume these.

Currently, it is possible to have erroneous matches of flags, especially due to the inclusion of /D and /I for Visual C++, which would match on other platforms parameters like -L /Data/my/path causing ata/my/path to be considered a definition and due to the space would not even be parsed as a path.

In the same way, the current system fails to remove linker paths given by -Wl,-L/my/path from the linker flags array, which has been improved.

Overall this currently addresses:

  • Support for Visual C++ style /link parameter separation and linker flags on this compiler.
  • Full dynamization of flags and library prefixes/suffixes due to elevating CMake's own mechanics. This adds support for direct paths to .so or .dylib shared libraries.
  • Significantly simplified regexes causing a reduction in false matches.
  • Support for more exotic syntaxes like -Wl,-L -Wl,/my/path or -Wl,--library-path=/my/path for maximal compatibility.
  • Elimination of linker path flags parameters from the link flags output variable.
  • Retain linker directories that weren't used for finding libraries.
  • Add MPICH and Intel MPI compiler environment variables to improve search quality by matching the compiler for the wrapper. This ensures compiler-specific configuration files are parsed correctly.
  • Intel MPI:
    • Set I_MPI_DEBUG_INFO_STRIP and I_MPI_FORT_BIND to disabled if they weren't set. Neither makes sense for CMake - the first one we need to explicitly ignore during the parse of the static link information, and the latter one is intended to ease linking mixed C/C++ and Fortran applications by also providing the Fortran dependencies when using the wrapper. For CMake this makes little sense to use, as it wouldn't be portable anyways and it causes C++ apps to depend on Fortran MPI runtimes by default.
    • Support I_MPI_CHECK_COMPILER compiler checking. This triggers some limited compiler compatibility checks with the MPI. Only Intel and GCC compilers are supported by it. Previously setting this variable or passing -compchk would have broken the parsing.
Edited by Christian Pfeiffer

Merge request reports