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 # --------------------------------------------------