cmake 3.23.2 - Error: Could not find MPI_C on Macbook Pro os 10.13.6; elmerfem, FindMPI

First of all: it’s the first time I’m filing an issue here. I also don’t know if I’m in the right place here for asking help for this issue. I also am NOT an advanced user of cmake, compilers, macports, etc. I just wanted to install a seemingly simple open-source program for doing Finite Element Analysis, but it turned out not as straight-forward as it seemed. Apologies beforehand for any stupid questions.


While trying to cmake and build a program called ‘elmerfem’, I get the following error:

CMake Error at cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Call Stack (most recent call first):
    cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
    cmake/Modules/FindMPI.cmake:615 (find_package_handle_standard_args)
    CMakeLists.txt:254 (FIND_PACKAGE)

I tried many times including locations for this package via -DCMAKE_PREFIX_PATH=\<relevant_location>, but this didn’t work. The commands below are (some of) the ones I tried:



  1. How do I point cmake to the relevant compilers, libraries, and packages it needs? Have I done something wrong, or overlooked something?
  2. How do I figure out where the problem is situated? Meaning, is it a fault on cmake’s side, or something in the CMakeLists.txt, or on Macports’ side, OSX, Xcode, … ?

My system

  • Macbook Pro late 2011
  • OSX 10.13.6
  • Packages installed via Macports v2.7.2 (compilers, libs, …)
  • Xcode 10.1

Other possibly relevant things:

  • Previously I also had trouble with cmake finding the C-, CXX-, and Fortran-compilers. After a lot of searching, trying things out, failing and cursing everything to the moon, I ended up changing the CMakeLists.txt manually. I am aware that this is actually ‘not done’, but at least it worked. The relevant compilers where indeed found by cmake.
  • all packages and libraries needed are installed via ‘Macports’. The installation-guide of ‘elmerfem’ is written for Homebrew instead of Macports. I’m guessing all the included installation-files are all aimed at locations typically used by Homebrew, and I probably need to adapt them for usage with Macports. Or is that stupid idea?
  • Previously I tried building/compiling ‘elmerfem’ (also with cmake) on a Fedora 36 system. I got the same error for MPI_C.
  • I got this kind of errors a lot, for MPI, MUMPS, and other libraries. This was the case on OSX as well as on Fedora36.

Many thanks in advance, and best regards,

1 Like

Have you tried -DCMAKE_PREFIX_PATH=/opt/local? A prefix here is what you might pass to --prefix in an autoconf build (basically “where to put all built things for use”). Homebrew likes /opt/local for this. Usually, bin is a subdirectory with executables, so you want its parent directory.

You can pass --debug-find to CMake to get an idea of where it is looking for stuff.