@@ -56,8 +56,11 @@ else()
5656 set (ADDITIONAL_LIBRARIES NativeXr NativeCamera)
5757endif ()
5858
59- set (TURBOMODULE_DIR "${REACTNATIVE_DIR_CMAKE} /ReactAndroid/src/main/jni/react/turbomodule/" )
60- if (EXISTS "${TURBOMODULE_DIR} /CMakeLists.txt" )
59+ # Prefab packages from React Native
60+ find_package (ReactAndroid REQUIRED CONFIG)
61+ find_package (fbjni REQUIRED CONFIG)
62+
63+ if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 71)
6164 # >= React Native 0.71 with prefabs
6265 include (${REACTNATIVE_DIR_CMAKE} /ReactAndroid/cmake-utils/folly-flags .cmake)
6366
@@ -84,77 +87,80 @@ if (EXISTS "${TURBOMODULE_DIR}/CMakeLists.txt")
8487 ${PROJECT_BUILD_DIR} /generated /rncli/src/main/jni)
8588
8689 target_compile_options (BabylonNative PRIVATE -Wall -Werror -fexceptions -frtti -std=c++17 -DWITH_INSPECTOR=1 -DLOG_TAG=\"ReactNative\")
87-
88- # Prefab packages from React Native
89- find_package (ReactAndroid REQUIRED CONFIG)
90- add_library (react_render_debug ALIAS ReactAndroid::react_render_debug)
91- add_library (turbomodulejsijni ALIAS ReactAndroid::turbomodulejsijni)
92- add_library (runtimeexecutor ALIAS ReactAndroid::runtimeexecutor)
93- add_library (react_codegen_rncore ALIAS ReactAndroid::react_codegen_rncore)
94- add_library (react_debug ALIAS ReactAndroid::react_debug)
95- add_library (react_render_componentregistry ALIAS ReactAndroid::react_render_componentregistry)
96- add_library (react_newarchdefaults ALIAS ReactAndroid::react_newarchdefaults)
97- add_library (react_render_core ALIAS ReactAndroid::react_render_core)
98- add_library (react_render_graphics ALIAS ReactAndroid::react_render_graphics)
99- add_library (rrc_view ALIAS ReactAndroid::rrc_view)
100- add_library (jsi ALIAS ReactAndroid::jsi)
101- add_library (glog ALIAS ReactAndroid::glog)
102- add_library (fabricjni ALIAS ReactAndroid::fabricjni)
103- add_library (react_render_mapbuffer ALIAS ReactAndroid::react_render_mapbuffer)
104- add_library (yoga ALIAS ReactAndroid::yoga)
105- add_library (folly_runtime ALIAS ReactAndroid::folly_runtime)
106- add_library (react_nativemodule_core ALIAS ReactAndroid::react_nativemodule_core)
107- add_library (react_render_imagemanager ALIAS ReactAndroid::react_render_imagemanager)
108- add_library (rrc_image ALIAS ReactAndroid::rrc_image)
109-
110- find_package (fbjni REQUIRED CONFIG)
11190 add_library (fbjni ALIAS fbjni::fbjni)
11291
113- target_link_libraries (BabylonNative
114- GLESv3
115- android
116- EGL
117- log
118- -lz
119- arcana
120- fabricjni # prefab ready
121- fbjni # via 3rd party prefab
122- folly_runtime # prefab ready
123- glog # prefab ready
124- jsi # prefab ready
125- react_codegen_rncore # prefab ready
126- react_debug # prefab ready
127- react_nativemodule_core # prefab ready
128- react_newarchdefaults # prefab ready
129- react_render_componentregistry # prefab ready
130- react_render_core # prefab ready
131- react_render_debug # prefab ready
132- react_render_graphics # prefab ready
133- react_render_imagemanager # prefab ready
134- react_render_mapbuffer # prefab ready
135- rrc_image # prefab ready
136- rrc_view # prefab ready
137- runtimeexecutor # prefab ready
138- turbomodulejsijni # prefab ready
139- yoga # prefab ready
140- AndroidExtensions
141- GraphicsDevice
142- JsRuntime
143- NativeCapture
144- NativeEngine
145- NativeInput
146- NativeOptimizations
147- NativeTracing
148- Window
149- XMLHttpRequest
150- Canvas
151- ${ADDITIONAL_LIBRARIES} )
152-
153- # We use an interface target to propagate flags to all the generated targets
154- # such as the folly flags or others.
155- add_library (common_flags INTERFACE )
156- target_compile_options (common_flags INTERFACE ${folly_FLAGS} )
157- target_link_libraries (ReactAndroid::react_codegen_rncore INTERFACE common_flags)
92+ # React Native introduced merged .so libraries in 0.76.0
93+ # https://github.com/react-native-community/discussions-and-proposals/discussions/816
94+ if (REACTNATIVE_MERGED_SO OR ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
95+ target_link_libraries (BabylonNative
96+ GLESv3
97+ android
98+ EGL
99+ log
100+ -lz
101+ arcana
102+ ReactAndroid::reactnative
103+ ReactAndroid::jsi
104+ fbjni
105+ AndroidExtensions
106+ GraphicsDevice
107+ JsRuntime
108+ NativeCapture
109+ NativeEngine
110+ NativeInput
111+ NativeOptimizations
112+ NativeTracing
113+ Window
114+ XMLHttpRequest
115+ Canvas
116+ ${ADDITIONAL_LIBRARIES} )
117+ else ()
118+ target_link_libraries (BabylonNative
119+ GLESv3
120+ android
121+ EGL
122+ log
123+ -lz
124+ arcana
125+ ReactAndroid::fabricjni # prefab ready
126+ fbjni::fbjni # via 3rd party prefab
127+ ReactAndroid::folly_runtime # prefab ready
128+ ReactAndroid::glog # prefab ready
129+ ReactAndroid::jsi # prefab ready
130+ ReactAndroid::react_codegen_rncore # prefab ready
131+ ReactAndroid::react_debug # prefab ready
132+ ReactAndroid::react_nativemodule_core # prefab ready
133+ ReactAndroid::react_newarchdefaults # prefab ready
134+ ReactAndroid::react_render_componentregistry # prefab ready
135+ ReactAndroid::react_render_core # prefab ready
136+ ReactAndroid::react_render_debug # prefab ready
137+ ReactAndroid::react_render_graphics # prefab ready
138+ ReactAndroid::react_render_imagemanager # prefab ready
139+ ReactAndroid::react_render_mapbuffer # prefab ready
140+ ReactAndroid::rrc_image # prefab ready
141+ ReactAndroid::rrc_view # prefab ready
142+ ReactAndroid::runtimeexecutor # prefab ready
143+ ReactAndroid::turbomodulejsijni # prefab ready
144+ ReactAndroid::yoga # prefab ready
145+ AndroidExtensions
146+ GraphicsDevice
147+ JsRuntime
148+ NativeCapture
149+ NativeEngine
150+ NativeInput
151+ NativeOptimizations
152+ NativeTracing
153+ Window
154+ XMLHttpRequest
155+ Canvas
156+ ${ADDITIONAL_LIBRARIES} )
157+
158+ # We use an interface target to propagate flags to all the generated targets
159+ # such as the folly flags or others.
160+ add_library (common_flags INTERFACE )
161+ target_compile_options (common_flags INTERFACE ${folly_FLAGS} )
162+ target_link_libraries (ReactAndroid::react_codegen_rncore INTERFACE common_flags)
163+ endif ()
158164
159165 # If project is on RN CLI v9, then we can use the following lines to link against the autolinked 3rd party libraries.
160166 if (EXISTS ${PROJECT_BUILD_DIR} /generated /rncli/src/main/jni/Android-rncli.cmake)
@@ -210,4 +216,4 @@ else()
210216 XMLHttpRequest
211217 Canvas
212218 ${ADDITIONAL_LIBRARIES} )
213- endif ()
219+ endif ()
0 commit comments