CMake cannot find MPI, configuration issue

#1

I have libopenmpi-dev installed and my mpirun is (Open MPI) 2.1.1

Error message with cmake is as follow:

CMake Error: File /usr/local/share/cmake-3.9/Modules/FindMPI/test_mpi.c does not exist.
CMake Error at cmake/FindMPI.cmake:1166 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  cmake/FindMPI.cmake:1223 (_MPI_try_staged_settings)
  cmake/FindMPI.cmake:1385 (_MPI_check_lang_works)
  CMakeLists.txt:49 (find_package)


CMake Error at /home/ezrayst/cb-geo/mpm/build/CMakeFiles/CMakeTmp/CMakeLists.txt:16 (add_executable):
  Cannot find source file:

    /home/ezrayst/cb-geo/mpm/build/CMakeFiles/FindMPI/test_mpi.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error: CMake can not determine linker language for target: cmTC_45955
CMake Error: Cannot determine link language for target "cmTC_45955".
CMake Error at cmake/FindMPI.cmake:1182 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  cmake/FindMPI.cmake:1223 (_MPI_try_staged_settings)
  cmake/FindMPI.cmake:1385 (_MPI_check_lang_works)
  CMakeLists.txt:49 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/ezrayst/cb-geo/mpm/build/CMakeFiles/CMakeOutput.log".

Also, there is no such /usr/local/share/cmake-3.9/Modules/FindMPI/ folder in my machine. Any thoughts?

#2

What’s your CMake command? It should be something like this:

export CXX_COMPILER=mpicxx
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_EXPORT_COMPILE_COMMANDS=On ..
#3

Followed this and it still does not work.

ezrayst@EYST:~/cb-geo/mpm/build$ rm -rf ./*
ezrayst@EYST:~/cb-geo/mpm/build$ export CXX_COMPILER=mpicxx
ezrayst@EYST:~/cb-geo/mpm/build$ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_EXPORT_COMPILE_COMMANDS=On ..
-- The CXX compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /usr/bin/mpicxx
-- Check for working CXX compiler: /usr/bin/mpicxx -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   filesystem
--   system
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0") 
CMake Error: File /usr/local/share/cmake-3.9/Modules/FindMPI/test_mpi.c does not exist.
CMake Error at cmake/FindMPI.cmake:1166 (configure_file):
  configure_file Problem configuring file
Call Stack (most recent call first):
  cmake/FindMPI.cmake:1223 (_MPI_try_staged_settings)
  cmake/FindMPI.cmake:1385 (_MPI_check_lang_works)
  CMakeLists.txt:49 (find_package)


CMake Error at /home/ezrayst/cb-geo/mpm/build/CMakeFiles/CMakeTmp/CMakeLists.txt:16 (add_executable):
  Cannot find source file:

    /home/ezrayst/cb-geo/mpm/build/CMakeFiles/FindMPI/test_mpi.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error: CMake can not determine linker language for target: cmTC_8b84a
CMake Error: Cannot determine link language for target "cmTC_8b84a".
CMake Error at cmake/FindMPI.cmake:1182 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  cmake/FindMPI.cmake:1223 (_MPI_try_staged_settings)
  cmake/FindMPI.cmake:1385 (_MPI_check_lang_works)
  CMakeLists.txt:49 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/ezrayst/cb-geo/mpm/build/CMakeFiles/CMakeOutput.log".

#4

You are on a old version of CMake, try CMake 3.12

#5

Yes, resolved with new cmake.