From dd60573e9d402d5569599875c4d1a9d924a2ec4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Fri, 15 Jul 2022 21:10:11 +0200 Subject: [PATCH] Fix macOS min version and bump CI (#24) We never actually used the MACOS_MIN_VERSION variable anywhere so it was defaulting to the version of the macOS build host. The macos-10.15 Azure DevOps image is getting deprecated so bump to macos-12 and fix the build so it still compiles with a min version of 10.15 The configure checks need -Werror=unguarded-availability otherwise they'll erreanously detect presence of symbols --- ci/common-variables.yml | 2 +- cmake/toolchain.apple.cmake | 1 + cmake/versions.apple.cmake | 2 +- src/native/CMakeLists.txt | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ci/common-variables.yml b/ci/common-variables.yml index fb34cb7..d7e8712 100644 --- a/ci/common-variables.yml +++ b/ci/common-variables.yml @@ -31,7 +31,7 @@ variables: - name: LinuxPool value: ubuntu-18.04 - name: MacPool - value: macos-10.15 + value: macos-12 - name: LinuxCompilerSuffix value: -10 - name: BuildScriptCommonOptions diff --git a/cmake/toolchain.apple.cmake b/cmake/toolchain.apple.cmake index 61dfd88..520dd09 100644 --- a/cmake/toolchain.apple.cmake +++ b/cmake/toolchain.apple.cmake @@ -48,6 +48,7 @@ if(TARGET_PLATFORM MATCHES "^host-darwin-|^ios-|^tvos-|^catalyst-") set(DEPLOYMENT_TARGET ${TVOS_MIN_VERSION}) elseif(PLATFORM MATCHES "^MACOS_") set(INCLUDE_IOS_TOOLCHAIN False) + set(CMAKE_OSX_DEPLOYMENT_TARGET ${MACOS_MIN_VERSION} CACHE STRING "Minimum OSX version") else() message(FATAL_ERROR "Platform '${PLATFORM}' not supported") endif() diff --git a/cmake/versions.apple.cmake b/cmake/versions.apple.cmake index 7483c7a..2d4a70f 100644 --- a/cmake/versions.apple.cmake +++ b/cmake/versions.apple.cmake @@ -1,4 +1,4 @@ set(IOS_MIN_VERSION "10.0") -set(MACOS_MIN_VERSION "10.9") +set(MACOS_MIN_VERSION "10.15") set(MACOS_CATALYST_MIN_VERSION "13.1") set(TVOS_MIN_VERSION "9.0") diff --git a/src/native/CMakeLists.txt b/src/native/CMakeLists.txt index b960965..834a0d6 100644 --- a/src/native/CMakeLists.txt +++ b/src/native/CMakeLists.txt @@ -186,6 +186,15 @@ if(APPLE) set(HOST_MACROS _DARWIN_C_SOURCE ) + + # Apple platforms like macOS/iOS allow targeting older operating system versions with a single SDK, + # the mere presence of a symbol in the SDK doesn't tell us whether the deployment target really supports it. + # The compiler raises a warning when using an unsupported API, turn that into an error so check_symbol_exists() + # can correctly identify whether the API is supported on the target. + check_cxx_compiler_flag("-Wunguarded-availability" "C_SUPPORTS_WUNGUARDED_AVAILABILITY") + if(C_SUPPORTS_WUNGUARDED_AVAILABILITY) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability") + endif() endif() macro(_compiler_has_flag _lang _flag)