hpcgarage/spatter

CMake Can't find Open MP on M2 mac

Closed this issue · 2 comments

We added this to CMakeLists.txt

SET (TRGT spatter)
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xclang -fopenmp")
SET (OpenMP_C_FLAGS "-Xclang -fopenmp -I/opt/homebrew/Cellar/libomp/15.0.6/include -L/opt/homebrew/Cellar/libomp/15.0.6/lib")
SET (OpenMP_C_LIB_NAMES "libomp")
SET (OpenMP_libomp_LIBRARY "omp")
SET (OpenMP_CXX_FLAGS "-Xclang -fopenmp -I/opt/homebrew/Cellar/libomp/15.0.6/include -L/opt/homebrew/Cellar/libomp/15.0.6/lib")
SET (OpenMP_CXX_LIB_NAMES "libomp")
SET (LDFLAGS "${LDFLAGS} -L/opt/homebrew/Cellar/libomp/15.0.6/lib") 

I think this may be fixed check that we are properly using FindOpenMP https://cmake.org/cmake/help/v3.20/module /FindOpenMP.html in our CMakeLists.txt.

I'm going to tag this under our CMake improvements branch of things but it may be a bug related to M2's OpenMP implementation.

There have been reports of CMake not being able to find OpenMP on Mac. This issue has been noted on the README, and users are encouraged to use a Linux container, as implementing a solution for it can be overly hacky (installing OpenMP from source, which needs a full installation of XCode).