[macOS] Ask CMake to look in the right place for include & link directories (#12516)

* Ask CMake to look in the right place for include_directories and link_directories on macOS (arm64 and x86_64)

Homebrew installs to a different location on Arm Macs compared to Intel Macs. 

This change prevents this error when compiling on Arm:   
`ld: warning: directory not found for option '-L/opt/local/lib'`

Use STREQUAL instead of MATCHES, since MATCHES is supposed to be used with regular expressions. 

Also update the homebrew directories for Intel, since they were wrong.

Remove the conditional check for x86 Apple, as usr/local is part of the default search path.
Tested on Intel and the warning does not appear.
This commit is contained in:
shinra-electric 2022-09-26 19:07:05 +02:00 committed by GitHub
parent c996be321c
commit db9389d24c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,9 +104,9 @@ if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0602)
endif()
if(APPLE)
include_directories(/opt/local/include)
link_directories(/opt/local/lib)
if(APPLE AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
include_directories(/opt/homebrew/include)
link_directories(/opt/homebrew/lib)
endif()
# Warnings are silenced for 3rdparty code