From 2c18ff10272b76b8f741a6d0599aa1842e7488be Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Tue, 27 Jan 2026 14:18:43 +0100 Subject: [PATCH 1/3] fix(hermes-inspector-modern): Apply HERMES_V1_ENABLED define to all build types The HERMES_V1_ENABLED compile option was incorrectly scoped inside the else() block, meaning it only applied to Release builds. This caused Debug builds to fail with missing header errors: fatal error: 'hermes/inspector/RuntimeAdapter.h' file not found Move the HERMES_V1_ENABLED conditional outside the Debug/Release if-else block so the define is applied regardless of build type. Note: target_compile_options() is additive in CMake, so this correctly appends to existing options rather than overriding them. --- .../ReactCommon/hermes/inspector-modern/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt b/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt index d392615a80e909..a57ec160ca725e 100644 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt +++ b/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt @@ -23,10 +23,10 @@ if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) PRIVATE -DHERMES_ENABLE_DEBUGGER=1 ) +endif() - if (HERMES_V1_ENABLED) - target_compile_options(hermes_inspector_modern PRIVATE -DHERMES_V1_ENABLED=1) - endif() +if (HERMES_V1_ENABLED) + target_compile_options(hermes_inspector_modern PRIVATE -DHERMES_V1_ENABLED=1) endif() target_include_directories(hermes_inspector_modern PUBLIC ${REACT_COMMON_DIR}) From 9f7f6b7f882959c9f8f80e40a993aa5407edcd01 Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Tue, 27 Jan 2026 16:12:40 +0100 Subject: [PATCH 2/3] refactor(cmake): Centralize HERMES_V1_ENABLED define Moved the HERMES_V1_ENABLED compile definition into the centralized target_compile_reactnative_options function in react-native-flags.cmake, eliminating duplicate conditional blocks across 7 CMakeLists.txt files. This ensures the define is consistently applied to all targets that use target_compile_reactnative_options when HERMES_V1_ENABLED is set, and makes the codebase easier to maintain. Files cleaned up: - ReactCommon/cmake-utils/react-native-flags.cmake (added centralized logic) - ReactCommon/hermes/inspector-modern/CMakeLists.txt - ReactCommon/hermes/executor/CMakeLists.txt - ReactCommon/react/runtime/CMakeLists.txt - ReactCommon/react/runtime/hermes/CMakeLists.txt - ReactAndroid/.../hermes/reactexecutor/CMakeLists.txt - ReactAndroid/.../runtime/hermes/jni/CMakeLists.txt - ReactAndroid/.../runtime/jni/CMakeLists.txt --- .../src/main/jni/react/hermes/reactexecutor/CMakeLists.txt | 4 ---- .../src/main/jni/react/runtime/hermes/jni/CMakeLists.txt | 4 ---- .../src/main/jni/react/runtime/jni/CMakeLists.txt | 4 ---- .../ReactCommon/cmake-utils/react-native-flags.cmake | 3 +++ .../react-native/ReactCommon/hermes/executor/CMakeLists.txt | 4 ---- .../ReactCommon/hermes/inspector-modern/CMakeLists.txt | 4 ---- .../react-native/ReactCommon/react/runtime/CMakeLists.txt | 4 ---- .../ReactCommon/react/runtime/hermes/CMakeLists.txt | 4 ---- 8 files changed, 3 insertions(+), 28 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt index b28df6a8a2fc59..920732a0db8ed4 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt @@ -27,8 +27,4 @@ target_link_libraries( target_compile_reactnative_options(hermes_executor PRIVATE) if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) target_compile_options(hermes_executor PRIVATE -DHERMES_ENABLE_DEBUGGER=1) - - if (HERMES_V1_ENABLED) - target_compile_options(hermes_executor PRIVATE -DHERMES_V1_ENABLED=1) - endif() endif() diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/CMakeLists.txt index 3ec451152cf220..13f7c86023d1a7 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/CMakeLists.txt @@ -29,8 +29,4 @@ target_link_libraries(hermesinstancejni target_compile_reactnative_options(hermesinstancejni PRIVATE) if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) target_compile_options(hermesinstancejni PRIVATE -DHERMES_ENABLE_DEBUGGER=1) - - if (HERMES_V1_ENABLED) - target_compile_options(hermesinstancejni PRIVATE -DHERMES_V1_ENABLED=1) - endif() endif () diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/CMakeLists.txt index 5394cb4af015ec..8987aed037633a 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/CMakeLists.txt @@ -19,10 +19,6 @@ add_library(rninstance target_compile_reactnative_options(rninstance PRIVATE) if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) target_compile_options(rninstance PRIVATE -DHERMES_ENABLE_DEBUGGER=1) - - if (HERMES_V1_ENABLED) - target_compile_options(rninstance PRIVATE -DHERMES_V1_ENABLED=1) - endif() endif () target_merge_so(rninstance) diff --git a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake index d005a4e0b0d89e..8a213c17d54439 100644 --- a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake +++ b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake @@ -31,5 +31,8 @@ function(target_compile_reactnative_options target_name scope) # TODO T228344694 improve this so that it works for all platforms if(ANDROID) target_compile_definitions(${target_name} ${scope} RN_SERIALIZABLE_STATE) + if(HERMES_V1_ENABLED) + target_compile_definitions(${target_name} ${scope} HERMES_V1_ENABLED=1) + endif() endif() endfunction() diff --git a/packages/react-native/ReactCommon/hermes/executor/CMakeLists.txt b/packages/react-native/ReactCommon/hermes/executor/CMakeLists.txt index cf991e1729b0a6..3731086f6d7dcc 100644 --- a/packages/react-native/ReactCommon/hermes/executor/CMakeLists.txt +++ b/packages/react-native/ReactCommon/hermes/executor/CMakeLists.txt @@ -32,10 +32,6 @@ if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) PRIVATE -DHERMES_ENABLE_DEBUGGER=1 ) - - if (HERMES_V1_ENABLED) - target_compile_options(hermes_executor_common PRIVATE -DHERMES_V1_ENABLED=1) - endif() else() target_compile_options( hermes_executor_common diff --git a/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt b/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt index a57ec160ca725e..ed2fbd87135565 100644 --- a/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt +++ b/packages/react-native/ReactCommon/hermes/inspector-modern/CMakeLists.txt @@ -25,10 +25,6 @@ if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) ) endif() -if (HERMES_V1_ENABLED) - target_compile_options(hermes_inspector_modern PRIVATE -DHERMES_V1_ENABLED=1) -endif() - target_include_directories(hermes_inspector_modern PUBLIC ${REACT_COMMON_DIR}) react_native_android_selector(reactnative reactnative "") target_link_libraries(hermes_inspector_modern diff --git a/packages/react-native/ReactCommon/react/runtime/CMakeLists.txt b/packages/react-native/ReactCommon/react/runtime/CMakeLists.txt index 25927837d9b620..0cf910be5bfda1 100644 --- a/packages/react-native/ReactCommon/react/runtime/CMakeLists.txt +++ b/packages/react-native/ReactCommon/react/runtime/CMakeLists.txt @@ -18,10 +18,6 @@ add_library(bridgeless target_compile_reactnative_options(bridgeless PRIVATE) if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) target_compile_options(bridgeless PRIVATE -DHERMES_ENABLE_DEBUGGER=1) - - if (HERMES_V1_ENABLED) - target_compile_options(bridgeless PRIVATE -DHERMES_V1_ENABLED=1) - endif() endif () target_include_directories(bridgeless PUBLIC .) diff --git a/packages/react-native/ReactCommon/react/runtime/hermes/CMakeLists.txt b/packages/react-native/ReactCommon/react/runtime/hermes/CMakeLists.txt index a237dfed110d0a..07b2a26b44222f 100644 --- a/packages/react-native/ReactCommon/react/runtime/hermes/CMakeLists.txt +++ b/packages/react-native/ReactCommon/react/runtime/hermes/CMakeLists.txt @@ -35,8 +35,4 @@ if(${CMAKE_BUILD_TYPE} MATCHES Debug OR REACT_NATIVE_DEBUG_OPTIMIZED) PRIVATE -DHERMES_ENABLE_DEBUGGER=1 ) - - if (HERMES_V1_ENABLED) - target_compile_options(bridgelesshermes PRIVATE -DHERMES_V1_ENABLED=1) - endif() endif() From 1942a5394a79bf8c3629faae45a34b73326ee59f Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Tue, 27 Jan 2026 16:19:57 +0100 Subject: [PATCH 3/3] codereview - moved out of android block --- .../ReactCommon/cmake-utils/react-native-flags.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake index 8a213c17d54439..b8a420af216d8a 100644 --- a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake +++ b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake @@ -31,8 +31,8 @@ function(target_compile_reactnative_options target_name scope) # TODO T228344694 improve this so that it works for all platforms if(ANDROID) target_compile_definitions(${target_name} ${scope} RN_SERIALIZABLE_STATE) - if(HERMES_V1_ENABLED) - target_compile_definitions(${target_name} ${scope} HERMES_V1_ENABLED=1) - endif() + endif() + if(HERMES_V1_ENABLED) + target_compile_definitions(${target_name} ${scope} HERMES_V1_ENABLED=1) endif() endfunction()