From db9389d24ce3bc42cec6aabde56b7066f0567cf6 Mon Sep 17 00:00:00 2001 From: shinra-electric <50119606+shinra-electric@users.noreply.github.com> Date: Mon, 26 Sep 2022 19:07:05 +0200 Subject: [PATCH] [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. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 073d74573a..baac35ee1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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