Fix building on Apple Silicon Macs (see https://github.com/cryfs/homebrew-tap/issues/10 )

This commit is contained in:
Sebastian Messmer 2022-10-11 18:42:21 -07:00
parent 27515e0116
commit daea2fb788

View File

@ -1146,7 +1146,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.1" AND USE_OPENMP)
endif()
endif()
# If OpenMP wasn't found, try if we can find it in the default Homebrew location
# If OpenMP wasn't found, try if we can find it in the default Homebrew location (Intel Macs)
if((NOT OPENMP_FOUND) AND (NOT OPENMP_CXX_FOUND) AND EXISTS "/usr/local/opt/libomp/lib/libomp.dylib")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
set(OpenMP_CXX_LIB_NAMES omp)
@ -1154,9 +1154,23 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.1" AND USE_OPENMP)
find_package(OpenMP)
if (OPENMP_FOUND OR OPENMP_CXX_FOUND)
message(STATUS "OpenMP: Found libomp in homebrew default location.")
message(STATUS "OpenMP: Found libomp in homebrew default location for Intel Macs.")
else()
message(FATAL_ERROR "OpenMP: Didn't find libomp. Tried homebrew default location but also didn't find it.")
message(FATAL_ERROR "OpenMP: Didn't find libomp. Tried homebrew default location for Intel Macs but also didn't find it.")
endif()
endif()
# If OpenMP wasn't found, try if we can find it in the default Homebrew location (Apple Silicon Macs)
if((NOT OPENMP_FOUND) AND (NOT OPENMP_CXX_FOUND) AND EXISTS "/opt/homebrew/opt/libomp/lib/libomp.dylib")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include")
set(OpenMP_CXX_LIB_NAMES omp)
set(OpenMP_omp_LIBRARY /opt/homebrew/opt/libomp/lib/libomp.dylib)
find_package(OpenMP)
if (OPENMP_FOUND OR OPENMP_CXX_FOUND)
message(STATUS "OpenMP: Found libomp in homebrew default location for Apple Silicon Macs.")
else()
message(FATAL_ERROR "OpenMP: Didn't find libomp. Tried homebrew default location for Apple Silicon Macs but also didn't find it.")
endif()
endif()