From d4ee79f26de0e21b6b2e8c5571ce7ff2de2e63ab Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Fri, 17 Jul 2026 14:50:09 -0700 Subject: [PATCH] Use a coherent system SDK for Apple builds Default top-level macOS builds to the selected Xcode SDK instead of allowing Command Line Tools headers to mix with Xcode frameworks. Mark the JavaScriptCore framework search path as a system framework through napi so JsRuntimeHost's pedantic warnings-as-errors policy ignores SDK implementation diagnostics without suppressing project warnings.\n\nThis fixes Xcode 26.5 nullability, invalid UTF-8, and related framework-header failures while leaving explicit cross-compilation toolchains and Apple mobile platforms unchanged. --- CMakeLists.txt | 12 ++++++++++++ Dependencies/CMakeLists.txt | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d37aac35e9..9e3370fea5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,18 @@ elseif(IOS) set(DEPLOYMENT_TARGET "13" CACHE STRING "") endif() +if(CMAKE_HOST_APPLE + AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR + AND NOT CMAKE_TOOLCHAIN_FILE + AND NOT IOS + AND NOT VISIONOS + AND NOT CMAKE_OSX_SYSROOT) + # Use one coherent Xcode SDK for headers and frameworks. Leaving this empty + # can mix Command Line Tools headers with frameworks from the selected + # Xcode, which turns SDK-only diagnostics into warnings-as-errors. + set(CMAKE_OSX_SYSROOT macosx CACHE STRING "macOS SDK" FORCE) +endif() + project(BabylonNative) set_property(GLOBAL PROPERTY USE_FOLDERS ON) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index 49b360250a..8db2a2d698 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -191,6 +191,16 @@ endif() # -------------------------------------------------- FetchContent_MakeAvailable_With_Message(JsRuntimeHost) +if(APPLE AND NAPI_JAVASCRIPT_ENGINE STREQUAL "JavaScriptCore" AND TARGET napi) + # find_library adds the SDK framework directory with -F, which does not + # classify framework headers as system headers. JsRuntimeHost uses + # -pedantic -Werror, so make that classification explicit for napi and all + # consumers while preserving warnings-as-errors for project sources. + get_filename_component(_JAVASCRIPTCORE_FRAMEWORKS_DIR "${JAVASCRIPTCORE_LIBRARY}" DIRECTORY) + target_compile_options(napi PUBLIC "SHELL:-iframework ${_JAVASCRIPTCORE_FRAMEWORKS_DIR}") + unset(_JAVASCRIPTCORE_FRAMEWORKS_DIR) +endif() + # -------------------------------------------------- # metal-cpp # --------------------------------------------------