Skip to content

cmake FindMPI not working on macOS Sonoma (MPI_C_WORKS missing)

SuperLUDist refuses to install because FindMPI is not working. The cmake shell command is listed under what I was expecting. The result is:

Call Stack (most recent call first):
/opt/homebrew/Cellar/cmake/3.29.2/share/cmake/Modules/FindMPI.cmake:1548 (_MPI_interrogate_compiler)
CMakeLists.txt:168 (find_package)


-- Could NOT find MPI_C (missing: MPI_C_WORKS)
-- Found MPI_CXX: /opt/extlib/openmpi/5.0.2/gcc/13.2.0/bin/mpicxx (found version "3.1")
-- Found MPI_Fortran: /opt/extlib/openmpi/5.0.2/gcc/13.2.0/bin/mpif90 (found version "3.1")
CMake Error at /opt/homebrew/Cellar/cmake/3.29.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find MPI (missing: MPI_C_FOUND) (found version "3.1")

The odd thing is that MPI_C, MPICXX and MPI_Fortran all report version 3.1 but, only MPI_C_WORKS is missing.

The command:

cmake --fresh --debug-find \
    -DTPL_ENABLE_PARMETISLIB=ON \
    -DTPL_PARMETIS_INCLUDE_DIRS="/opt/extlib/parmetis/4.0.3/openmpi/5.0.2/gcc/13.2.0/include;/opt/extlib/metis/5.1.0/gcc/13.2.0/include" \
    -DTPL_PARMETIS_LIBRARIES="/opt/extlib/parmetis/4.0.3/openmpi/5.0.2/gcc/13.2.0/lib/libparmetis.a;/opt/extlib/metis/5.1.0/gcc/13.2.0/lib/libmetis.a" \
    -DTPL_BLAS_LIBRARIES="-framework Accelerate" \
        \
    -DTPL_LAPACK_LIBRARIES="-framework Accelerate" \
        \
    -DCMAKE_C_FLAGS="-std=c99 -g -DPRNTlevel=0 -DDEBUGlevel=0" \
    -DCMAKE_C_COMPILER=/opt/extlib/openmpi/5.0.2/gcc/13.2.0/bin/mpicc \
    -DCMAKE_CXX_COMPILER=mpicxx \
    -DCMAKE_Fortran_COMPILER=mpif90 \
    -DCMAKE_CXX_FLAGS="-std=c++11" \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_INSTALL_PREFIX="/opt/extlib/superludist/git/openmpi/5.0.2/gcc/13.2.0" \
    ../

This has worked in the past.

Link to CMakeLists.txt for the SuperLUDist package: CMakesList.txt. I didn't see any obvious reason why this should work.

In a simple hello_world.c cmake, it did find it.

cmake -B ./build --fresh -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpif90

The contents of the CMakeLists.txt for this project:

cmake_minimum_required(VERSION 3.18)
project(test_FindMPI VERSION 0.1)

## enforce build directory
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES  ON)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
  message(SEND_ERROR "In-source builds are not allowed.")
endif ()


find_package(MPI REQUIRED)

if(NOT MPI_C_FOUND)
    message(WARNING "Could not find all MPI components! MPI_C_FOUND=${MPI_C_FOUND}")
endif(NOT MPI_C_FOUND)

if(MPI_C_FOUND)
    message(WARNING "Found all MPI components! MPI_C_FOUND=${MPI_C_FOUND}")
endif(MPI_C_FOUND)

message(STATUS "MPI VARIABLES:    MPI_HOME=${MPI_HOME}, MPI C Ver=${MPI_C_VERSION_MAJOR}")
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information