All,
I don’t know if this is a CMake issue or not, but it seems to be? To wit, I have a boring MPI C Hello World code and it builds just fine using either gcc or clang on the command line. First gcc:
❯ mpicc --version
gcc-14 (Homebrew GCC 14.2.0) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
❯ mpicc ./hello-world.c
❯ mpirun -np 2 ./a.out
Hello world from processor gs6101-alderaan-198120226026.ndc.nasa.gov, rank 1 out of 2 processors
Hello world from processor gs6101-alderaan-198120226026.ndc.nasa.gov, rank 0 out of 2 processors
and clang:
❯ mpicc --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
❯ mpicc ./hello-world.c
❯ mpirun -np 2 ./a.out
Hello world from processor gs6101-alderaan-198120226026.ndc.nasa.gov, rank 0 out of 2 processors
Hello world from processor gs6101-alderaan-198120226026.ndc.nasa.gov, rank 1 out of 2 processors
Now I whip up a simple CMakeLists.txt
and:
cmake_minimum_required(VERSION 3.20)
project(HelloWorldC)
find_package(MPI REQUIRED COMPONENTS C)
add_executable(hello_world hello-world.c)
target_link_libraries(hello_world PRIVATE MPI::MPI_C)
and then first we build with clang:
❯ cmake -B build-clang -S .
-- The C compiler identification is AppleClang 16.0.0.16000026
-- The CXX compiler identification is AppleClang 16.0.0.16000026
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found MPI_C: /Users/mathomp4/installed/Compiler/clang-gfortran-14/openmpi/5.0.5/lib/libmpi.dylib (found version "3.1")
-- Found MPI: TRUE (found version "3.1") found components: C
-- Configuring done (1.0s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/mathomp4/CMakeTutorial/hello-world-c/build-clang
Yay! Now with gcc:
❯ cmake -B build-gcc -S .
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/mathomp4/.homebrew/brew/bin/gcc-14 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/mathomp4/.homebrew/brew/bin/g++-14 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find MPI_C (missing: MPI_C_WORKS)
CMake Error at /Users/mathomp4/.homebrew/brew/Cellar/cmake/3.30.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
Could NOT find MPI (missing: MPI_C_FOUND C)
Call Stack (most recent call first):
/Users/mathomp4/.homebrew/brew/Cellar/cmake/3.30.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
/Users/mathomp4/.homebrew/brew/Cellar/cmake/3.30.3/share/cmake/Modules/FindMPI.cmake:1841 (find_package_handle_standard_args)
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
Well huh.
I mean, my MPI stack does work, but for some reason not when CMake tries to detect it.
I note that this all started when I updated to XCode 16 and I see that @brad.king already has one XCode 16 issue, but this seems more…basic and boring.
I’m using CMake 3.30.3:
❯ cmake --version
cmake version 3.30.3