I have installed Open-MPI using homebrew, using brew install open-mpi.
If I run mpic++ main.cpp
in the command line, the code is compiled correctly. I can then run it using mpirun a.out
.
Now the issue is, when I create my CMakelists.txt file in Clion, it seems to not be able to find the Open-MPI package:
cmake_minimum_required(VERSION 3.15)
project(project)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_PREFIX_PATH "/usr/local/Cellar/open-mpi/4.0.2/lib")
find_package(OpenMP REQUIRED) #FAILS AT THIS LINE
set(LDFLAGS "-L/usr/local/Cellar/open-mpi/4.0.2/lib")
set(CPPFLAGS "-I/usr/local/Cellar/open-mpi/4.0.2/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${LDFLAGS} ${CPPFLAGS} -fopenmp")
add_executable(project main.cpp)
Could someone please provide guidance? I am confused as to how I can get it to work and have been trying for some amount of hours. I am new to Open-MPI.
The error it generates when I try to build:
CMake Error at
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) Call Stack (most recent call first):
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindOpenMP.cmake:477 (find_package_handle_standard_args) CMakeLists.txt:9 (find_package)
Thanks!