From 5bfe33f09203448caaf22cea24427692ea295112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Baptiste=20No=C3=ABl?= Date: Mon, 29 Aug 2022 19:40:10 +0200 Subject: CMakeFindFrameworks: Fix Brew 'Frameworks' path on Apple Silicon This approach is compatible with both Intel and Apple Silicon architectures. `/usr/local/Frameworks` was added in commit 9970cdcb59 (CMakeFindFrameworks: Allow custom framework locations, 2016-07-30, v3.7.0-rc1~296^2) unconditionally, but does not work on Apple Silicon. ``` x86_64 (Intel macOS): $ brew --prefix /usr/local arm64 (Apple Silicon macOS): $ brew --prefix /opt/homebrew ``` --- Modules/CMakeFindFrameworks.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeFindFrameworks.cmake b/Modules/CMakeFindFrameworks.cmake index 8906f48..1aa3929 100644 --- a/Modules/CMakeFindFrameworks.cmake +++ b/Modules/CMakeFindFrameworks.cmake @@ -17,12 +17,19 @@ if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) macro(CMAKE_FIND_FRAMEWORKS fwk) set(${fwk}_FRAMEWORKS) if(APPLE) + # 'Frameworks' directory from Brew (Apple Silicon and Intel) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + set(_brew_framework_path /opt/homebrew/Frameworks) + else() + set(_brew_framework_path /usr/local/Frameworks) + endif() + file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _cmff_CMAKE_FRAMEWORK_PATH) set(_cmff_search_paths ${CMAKE_FRAMEWORK_PATH} ${_cmff_CMAKE_FRAMEWORK_PATH} ~/Library/Frameworks - /usr/local/Frameworks + ${_brew_framework_path} /Library/Frameworks /System/Library/Frameworks /Network/Library/Frameworks -- cgit v0.12