FindMPI mis-parses mpicc -compile-info output
FindMPI parses the output of mpicc -compile-info
to find arguments roughly like -fXXX
. This seems to be targeted at switches like -fstrict-aliasing
.
With MPICH 3.4 (released 5 Jan 2021, installed via MacPorts) on MacOS 10.15 Catalina the command returns
mpicc -compile-info
/usr/bin/clang -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -framework OpenCL -Wl,-flat_namespace -Wl,-commons,use_dylibs -I/opt/local/include/mpich-mp -L/opt/local/lib/mpich-mp -lmpi -lpmpi
and the parsing extracts -framework
without the corresponding OpenCL
. This leads to bad compiler invocations, such as:
The MPI test test_mpi for C in mode normal failed to compile with the following output:
Change Dir: /Users/olupton/build/cmake_debug/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_b3f90/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_b3f90.dir/build.make CMakeFiles/cmTC_b3f90.dir/build
Building C object CMakeFiles/cmTC_b3f90.dir/test_mpi.c.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -isystem /opt/local/include/mpich-mp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.15 -framework -o CMakeFiles/cmTC_b3f90.dir/test_mpi.c.o -c /opt/local/share/cmake-3.19/Modules/FindMPI/test_mpi.c
clang: error: no such file or directory: 'CMakeFiles/cmTC_b3f90.dir/test_mpi.c.o'
clang: warning: -framework -o: 'linker' input unused [-Wunused-command-line-argument]
which cause CMake 3.19.3 to fail to find MPI on this system.
On the same system MPICH 3.3.2 did not return the -framework OpenCL
fragment and everything worked as expected.