Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
fix compile on Mac when HOMEBREW_PREFIX is /opt/homebrew (#197)
Browse files Browse the repository at this point in the history
Signed-off-by: Enwei Jiao <[email protected]>
  • Loading branch information
jiaoew1991 authored May 28, 2022
1 parent 477cff5 commit 4c6ff55
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ add_definitions( -DAUTO_INITIALIZE_EASYLOGGINGPP )
if ( APPLE )
set ( CMAKE_CROSSCOMPILING TRUE )
set ( RUN_HAVE_GNU_POSIX_REGEX 0 )
set ( CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang" )
set ( CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++" )
if ( DEFINED ENV{HOMEBREW_PREFIX} )
set( APPLE_LLVM_PREFIX $ENV{HOMEBREW_PREFIX} )
else()
set( APPLE_LLVM_PREFIX "/usr/local" )
endif()
set ( CMAKE_C_COMPILER "${APPLE_LLVM_PREFIX}/opt/llvm/bin/clang" )
set ( CMAKE_CXX_COMPILER "${APPLE_LLVM_PREFIX}/opt/llvm/bin/clang++" )
endif ()

set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
Expand Down Expand Up @@ -74,7 +79,7 @@ include( CheckCXXCompilerFlag )
if ( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
message(STATUS "MacOS")
set ( MACOS TRUE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L/usr/local/opt/libomp/lib" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${APPLE_LLVM_PREFIX}/opt/libomp/lib" )
elseif ( "${CMAKE_SYSTEM}" MATCHES "Linux" )
message( STATUS "Linux")
set ( LINUX TRUE )
Expand Down

0 comments on commit 4c6ff55

Please sign in to comment.