@@ -15,6 +15,12 @@ set(WINRT_GENERATED_FILES_DIR "${CMAKE_CURRENT_LIST_DIR}/BabylonReactNative/Gene
1515# Add WINRT generated files directory globally
1616include_directories ("${WINRT_GENERATED_FILES_DIR} " "${WINRT_GENERATED_FILES_DIR} /winrt" )
1717
18+ # Ensure consistent CppWinRT compilation settings across all targets to match vcxproj
19+ # This prevents linker errors due to CppWinRT version/setting mismatches
20+ add_compile_definitions (
21+ WINRT_SOURCE_LOCATION=false
22+ )
23+
1824# Configure Babylon Native to use JSI
1925# Note: We should avoid installing node_modules in the Module\@babylonjs\react-native folder.
2026# Installing react-native dependencies for both the Playground app and the @babylonjs/react-native package will generate a bad bundle/runtime errors.
@@ -43,6 +49,20 @@ target_compile_definitions(BabylonNative PRIVATE BABYLON_NATIVE_PLUGIN_NATIVEXR=
4349target_compile_definitions (BabylonNative PRIVATE BABYLON_NATIVE_PLUGIN_NATIVECAMERA=${BABYLON_NATIVE_PLUGIN_NATIVECAMERA} )
4450target_include_directories (BabylonNative PRIVATE ${SHARED_INCLUDES} )
4551
52+ # Ensure all dependency targets use consistent CppWinRT settings to match BabylonModule.obj
53+ # Apply WINRT_SOURCE_LOCATION=false to all BabylonNative and its dependencies
54+ set (BABYLON_TARGETS arcana GraphicsDevice jsi JsRuntime NativeCapture NativeEngine NativeInput NativeOptimizations NativeTracing Window Scheduling XMLHttpRequest ShaderCache Canvas)
55+ foreach (TARGET_NAME ${BABYLON_TARGETS} )
56+ if (TARGET ${TARGET_NAME} )
57+ get_target_property (TARGET_TYPE ${TARGET_NAME} TYPE)
58+ if (TARGET_TYPE STREQUAL "INTERFACE_LIBRARY" )
59+ target_compile_definitions (${TARGET_NAME} INTERFACE WINRT_SOURCE_LOCATION=false )
60+ else ()
61+ target_compile_definitions (${TARGET_NAME} PRIVATE WINRT_SOURCE_LOCATION=false )
62+ endif ()
63+ endif ()
64+ endforeach ()
65+
4666# because of warning C5030: attribute 'msvc::intrinsic' is not recognized
4767# solution is to update VS version but this might bring more issues
4868disable_warnings (Graphics )
0 commit comments