From 8e0e943ce56d497ec27998d5b377e345ce1abb31 Mon Sep 17 00:00:00 2001 From: Nicholas Lonsinger Date: Wed, 4 Feb 2026 10:48:20 -0800 Subject: [PATCH] BUILD(cmake): Set macOS deployment target based on architecture Apple Silicon requires macOS 11.0 minimum (Big Sur) since ARM Macs were introduced with that version. Setting 10.15 as the deployment target on ARM builds causes compiler warnings as it silently overrides to 11.0. This change detects the target architecture and sets the appropriate deployment target: - ARM64 (Apple Silicon): macOS 11.0 - x86_64 (Intel): macOS 10.15 Co-Authored-By: Claude Opus 4.5 --- CMakeLists.txt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc674d87121..5654175747f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,26 @@ if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 20) set(CMAKE_CXX_STANDARD 20) endif() set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) +if(APPLE) + # Determine target architecture for deployment target selection + # Priority: explicit CMAKE_OSX_ARCHITECTURES > CMAKE_SYSTEM_PROCESSOR > host processor + if(CMAKE_OSX_ARCHITECTURES) + set(_target_arch "${CMAKE_OSX_ARCHITECTURES}") + elseif(CMAKE_SYSTEM_PROCESSOR) + set(_target_arch "${CMAKE_SYSTEM_PROCESSOR}") + else() + set(_target_arch "${CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() + + # macOS 11.0 is the minimum for ARM64 (Apple Silicon was introduced with Big Sur) + # macOS 10.15 remains the target for Intel builds + if(_target_arch STREQUAL "arm64") + set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0) + else() + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) + endif() + unset(_target_arch) +endif() include(pkg-utils)