diff --git a/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt b/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt index 7319e832fcff96..c3e3ecebbbd75b 100644 --- a/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt +++ b/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt @@ -21,6 +21,9 @@ add_compile_options( -Wno-error=unused-but-set-variable -DHAVE_POSIX_CLOCKS ) +if(${CMAKE_BUILD_TYPE} MATCHES Release) + add_compile_options(-DNDEBUG) +endif() # Yogacore needs to link towards android and log from the NDK libs target_link_libraries(fb dl android log) diff --git a/ReactCommon/hermes/executor/CMakeLists.txt b/ReactCommon/hermes/executor/CMakeLists.txt index de74c65daea888..f63bd1e7d04f62 100644 --- a/ReactCommon/hermes/executor/CMakeLists.txt +++ b/ReactCommon/hermes/executor/CMakeLists.txt @@ -28,4 +28,10 @@ if(${CMAKE_BUILD_TYPE} MATCHES Debug) PRIVATE -DHERMES_ENABLE_DEBUGGER=1 ) +else() + target_compile_options( + hermes_executor_common + PRIVATE + -DNDEBUG + ) endif() diff --git a/ReactCommon/jsc/CMakeLists.txt b/ReactCommon/jsc/CMakeLists.txt index 2f387fa996f644..5db3ff62a01bbc 100644 --- a/ReactCommon/jsc/CMakeLists.txt +++ b/ReactCommon/jsc/CMakeLists.txt @@ -33,3 +33,7 @@ target_link_libraries(jscruntime # TODO: Remove this flag when ready. # Android has this enabled by default, but the flag is still needed for iOS. target_compile_options(jscruntime PRIVATE -DRN_FABRIC_ENABLED) + +if(${CMAKE_BUILD_TYPE} MATCHES Release) + target_compile_options(jscruntime PRIVATE -DNDEBUG) +endif() diff --git a/ReactCommon/react/debug/CMakeLists.txt b/ReactCommon/react/debug/CMakeLists.txt index 620a1c54392c8c..ccfc69872e7340 100644 --- a/ReactCommon/react/debug/CMakeLists.txt +++ b/ReactCommon/react/debug/CMakeLists.txt @@ -22,3 +22,7 @@ add_library(react_debug SHARED ${react_debug_SRC}) target_include_directories(react_debug PUBLIC ${REACT_COMMON_DIR}) target_link_libraries(react_debug log folly_runtime) + +if(${CMAKE_BUILD_TYPE} MATCHES Release) + target_compile_options(react_debug PUBLIC -DNDEBUG) +endif() diff --git a/ReactCommon/react/debug/flags.h b/ReactCommon/react/debug/flags.h index 62d1cc445746a1..dae3ecc4e51f81 100644 --- a/ReactCommon/react/debug/flags.h +++ b/ReactCommon/react/debug/flags.h @@ -10,7 +10,9 @@ // // Enable REACT_NATIVE_DEBUG if NDEBUG is not defined. // Due to BUCK defaults in open-source, NDEBUG is always defined for all android -// builds (if you build without BUCK, this isn't an issue). Thus we introduce +// builds. +// If you build in OSS with CMake, you will have -DNDEBUG set only for release +// builds, therefore REACT_NATIVE_DEBUG will not be set. Here we introduce // REACT_NATIVE_DEBUG that we use internally instead of NDEBUG that we can // control and use as a more reliable xplat flag. For any build that doesn't // have NDEBUG defined, we enable REACT_NATIVE_DEBUG for convenience.