Skip to content

Commit bb50f0f

Browse files
authoredMar 6, 2025··
Update detect_dependencies.cmake
Made OpenMP work for more modern brew installations
1 parent 04eb86e commit bb50f0f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎cmake/detect_dependencies.cmake

+16
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ if(APPLE AND CMAKE_HOST_APPLE)
8383
endif()
8484
endif()
8585

86+
# If OpenMP wasn't found, try if we can find it in the default Homebrew location (for newer homebrew setups)
87+
if((NOT OPENMP_FOUND) AND(NOT OPENMP_CXX_FOUND) AND EXISTS "/opt/homebrew/opt/libomp/lib")
88+
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
89+
set(OpenMP_CXX_LIB_NAMES omp)
90+
set(OpenMP_omp_LIBRARY /opt/homebrew/opt/libomp/lib)
91+
92+
find_package(OpenMP)
93+
94+
if(OPENMP_FOUND OR OPENMP_CXX_FOUND)
95+
message(VERBOSE "Found libomp in homebrew default location.")
96+
else()
97+
message(FATAL_ERROR "Didn't find libomp. Tried homebrew default location but also didn't find it.")
98+
endif()
99+
endif()
100+
101+
86102
set(Additional_OpenMP_Libraries_Workaround "")
87103

88104
# Workaround because older cmake on apple doesn't support FindOpenMP

0 commit comments

Comments
 (0)
Please sign in to comment.