Skip to content

Commit 2efe655

Browse files
authored
fix: add target_compile_reactnative_options (#1085)
## 📜 Description Added `target_compile_reactnative_options` for Android in `CMakeList.txt`. ## 💡 Motivation and Context As per [blogpost](https://reactnative.dev/blog/2025/08/12/react-native-0.81#rn_serializable_state-and-c-flags) we should add `target_compile_reactnative_options` to the lib in order to support RN 0.81. We use custom C++ code (custom shadow nodes) and we don't rely on codegen, so we need to do it. > We use custom shadow nodes since `1.17.0` to properly stretch `OverKeyboardView`. The same fix was added to `react-native-safe-area-context` and `react-native-screens`. ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### Android - added `target_compile_reactnative_options(${LIB_TARGET_NAME} PRIVATE)` for RN 0.80+ ## 🤔 How Has This Been Tested? Tested via this PR - it doesn't break old builds 🙂 Didn't test on RN 0.81 project yet because upgrade is blocked by Detox. ## 📸 Screenshots (if appropriate): <img width="691" height="257" alt="image" src="https://github.com/user-attachments/assets/e16587fc-30e9-4d90-80f5-7ce466042382" /> ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 1d7721b commit 2efe655

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

android/src/main/jni/CMakeLists.txt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,22 @@ else()
6868
)
6969
endif()
7070

71-
target_compile_options(
72-
${LIB_TARGET_NAME}
73-
PRIVATE
74-
-DLOG_TAG=\"ReactNative\"
75-
-fexceptions
76-
-frtti
77-
-std=c++20
78-
-Wall
79-
)
71+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
72+
target_compile_reactnative_options(${LIB_TARGET_NAME} PRIVATE)
73+
else()
74+
target_compile_options(
75+
${LIB_TARGET_NAME}
76+
PRIVATE
77+
-DLOG_TAG=\"ReactNative\"
78+
-fexceptions
79+
-frtti
80+
-std=c++20
81+
-Wall
82+
)
83+
endif()
8084
8185
target_include_directories(
8286
${CMAKE_PROJECT_NAME}
8387
PUBLIC
8488
${CMAKE_CURRENT_SOURCE_DIR}
85-
)
89+
)

0 commit comments

Comments
 (0)