diff --git a/CMakeLists.txt b/CMakeLists.txt index e177a666f..0ced63f98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,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 b3817d9fe..320bca3a2 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -285,6 +285,19 @@ if(NAPI_JAVASCRIPT_ENGINE STREQUAL "JSI" OR NAPI_JAVASCRIPT_ENGINE STREQUAL "Her babylon_native_force_rtti(jsi) endif() +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) + if(_JAVASCRIPTCORE_FRAMEWORKS_DIR MATCHES "\\.framework$") + get_filename_component(_JAVASCRIPTCORE_FRAMEWORKS_DIR "${_JAVASCRIPTCORE_FRAMEWORKS_DIR}" DIRECTORY) + endif() + target_compile_options(napi PUBLIC "-iframework" "${_JAVASCRIPTCORE_FRAMEWORKS_DIR}") + unset(_JAVASCRIPTCORE_FRAMEWORKS_DIR) +endif() + # -------------------------------------------------- # metal-cpp # --------------------------------------------------