Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

include(${CMAKE_CURRENT_LIST_DIR}/folly-flags.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

# We configured the REACT_COMMON_DIR variable as it's commonly used to reference
# shared C++ code in other targets.
Expand Down Expand Up @@ -60,16 +61,7 @@ target_include_directories(${CMAKE_PROJECT_NAME}
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_BUILD_DIR}/generated/autolinking/src/main/jni)

target_compile_options(${CMAKE_PROJECT_NAME}
PRIVATE
-Wall
-Werror
-fexceptions
-frtti
-std=c++20
-DLOG_TAG=\"ReactNative\"
-DFOLLY_NO_CONFIG=1
)
target_compile_reactnative_options(${CMAKE_PROJECT_NAME} PRIVATE "ReactNative")

# Prefab packages from React Native
find_package(ReactAndroid REQUIRED CONFIG)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

# This CMake file exposes the React Native Flags that all the libraries should use when
# compiling a module that will end up inside libreactnative.so

SET(reactnative_FLAGS
-Wall
-Werror
-fexceptions
-frtti
-std=c++20
-DFOLLY_NO_CONFIG=1
)

function(target_compile_reactnative_options target_name scope)
target_compile_options(${target_name}
${scope}
-Wall
-fexceptions
-frtti
-std=c++20
-DFOLLY_NO_CONFIG=1
)
set (extra_args ${ARGN})
list(LENGTH extra_args extra_count)
set (tag "ReactNative")
if (${extra_count} GREATER 0)
list(GET extra_args 0 user_provided_tag)
target_compile_options(${target_name} ${scope} -DLOG_TAG=\"${user_provided_tag}\")
endif ()
endfunction()

16 changes: 7 additions & 9 deletions packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(CMAKE_VERBOSE_MAKEFILE on)

project(ReactAndroid)

include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

# Convert input paths to CMake format (with forward slashes)
file(TO_CMAKE_PATH "${REACT_ANDROID_DIR}" REACT_ANDROID_DIR)
file(TO_CMAKE_PATH "${REACT_BUILD_DIR}" REACT_BUILD_DIR)
Expand All @@ -22,7 +24,6 @@ endif(CCACHE_FOUND)

# Make sure every shared lib includes a .note.gnu.build-id header
add_link_options(-Wl,--build-id)
add_compile_options(-Wall -Werror)

function(add_react_android_subdir relative_path)
add_subdirectory(${REACT_ANDROID_DIR}/${relative_path} ReactAndroid/${relative_path})
Expand Down Expand Up @@ -242,6 +243,8 @@ target_link_libraries(reactnative
yogacore
)

target_compile_reactnative_options(reactnative PRIVATE)

target_include_directories(reactnative
PUBLIC
$<TARGET_PROPERTY:bridgeless,INTERFACE_INCLUDE_DIRECTORIES>
Expand Down Expand Up @@ -361,14 +364,9 @@ add_executable(reactnative_unittest
# ${REACT_COMMON_DIR}/react/renderer/core/tests/ConcreteShadowNodeTest.cpp
# ${REACT_COMMON_DIR}/react/renderer/core/tests/ComponentDescriptorTest.cpp
)
target_compile_options(reactnative_unittest
PRIVATE
-Wall
-Werror
-fexceptions
-frtti
-std=c++20
-DHERMES_ENABLE_DEBUGGER)

target_compile_reactnative_options(reactnative_unittest PRIVATE)
target_compile_options(reactnative_unittest PRIVATE -DHERMES_ENABLE_DEBUGGER)

target_link_libraries(reactnative_unittest
fabricjni
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)

add_compile_options(
-fvisibility=hidden
-fexceptions
-frtti
-std=c++20
-O3)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB yoga_SRC CONFIGURE_DEPENDS jni/*.cpp)
add_library(yoga OBJECT ${yoga_SRC})
Expand All @@ -27,3 +21,6 @@ target_link_libraries(yoga
log
android
)

target_compile_reactnative_options(yoga PRIVATE)
target_compile_options(yoga PRIVATE -fvisibility=hidden -O3)
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(-fexceptions -frtti -std=c++20 -Wall -DLOG_TAG=\"ReactNative\")

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB react_devsupportjni_SRC CONFIGURE_DEPENDS *.cpp)

Expand All @@ -21,3 +20,5 @@ target_include_directories(react_devsupportjni PUBLIC .)
target_link_libraries(react_devsupportjni
fbjni
jsinspector)

target_compile_reactnative_options(react_devsupportjni PRIVATE "ReactNative")
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
cmake_minimum_required(VERSION 3.13)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB fabricjni_SRCS CONFIGURE_DEPENDS *.cpp)

Expand Down Expand Up @@ -63,12 +64,4 @@ target_link_libraries(
yoga
)

target_compile_options(
fabricjni
PRIVATE
-DLOG_TAG=\"Fabric\"
-fexceptions
-frtti
-std=c++20
-Wall
)
target_compile_reactnative_options(fabricjni PRIVATE "Fabric")
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
cmake_minimum_required(VERSION 3.13)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB react_featureflagsjni_SRCS CONFIGURE_DEPENDS *.cpp)

Expand All @@ -25,13 +26,4 @@ target_link_libraries(
)

target_merge_so(react_featureflagsjni)

target_compile_options(
react_featureflagsjni
PRIVATE
-DLOG_TAG=\"ReactNative\"
-fexceptions
-frtti
-std=c++20
-Wall
)
target_compile_reactnative_options(react_featureflagsjni PRIVATE "ReactNative")
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB_RECURSE jsijniprofiler_SRC CONFIGURE_DEPENDS *.cpp)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

add_library(
jsijniprofiler
OBJECT
${jsijniprofiler_SRC}
)
target_compile_options(
jsijniprofiler
PRIVATE
-fexceptions
)
target_compile_reactnative_options(jsijniprofiler PRIVATE)
target_merge_so(jsijniprofiler)

target_include_directories(jsijniprofiler PRIVATE .)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB_RECURSE hermes_executor_SRC CONFIGURE_DEPENDS *.cpp)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

add_library(hermes_executor
OBJECT
${hermes_executor_SRC}
)
target_compile_options(
hermes_executor
PRIVATE
$<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>
-std=c++20
-fexceptions
)
target_merge_so(hermes_executor)
target_include_directories(hermes_executor PRIVATE .)
target_link_libraries(
Expand All @@ -30,3 +24,5 @@ target_link_libraries(
jsi
reactnative
)
target_compile_reactnative_options(hermes_executor PRIVATE)
target_compile_options(hermes_executor PRIVATE $<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>)
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

file(GLOB reactnativejni_SRC CONFIGURE_DEPENDS *.cpp)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

add_compile_options(
-fexceptions
-Wno-unused-lambda-capture
-std=c++20)
file(GLOB reactnativejni_SRC CONFIGURE_DEPENDS *.cpp)

######################
### reactnativejni ###
Expand Down Expand Up @@ -41,3 +38,5 @@ target_link_libraries(reactnativejni
runtimeexecutor
yoga
)
target_compile_reactnative_options(reactnativejni PRIVATE)
target_compile_options(reactnativejni PRIVATE -Wno-unused-lambda-capture)
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)

add_compile_options(-fexceptions -frtti -std=c++20 -Wall -DLOG_TAG=\"Fabric\")
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB mapbuffer_SRC CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/react/common/mapbuffer/*.cpp)
Expand All @@ -34,3 +33,5 @@ target_link_libraries(mapbufferjni
react_utils
yoga
)

target_compile_reactnative_options(mapbufferjni PRIVATE "Fabric")
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)

add_compile_options(-fexceptions
-frtti
-std=c++20
-Wall
-DLOG_TAG=\"ReactNative\")
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB react_newarchdefaults_SRC CONFIGURE_DEPENDS *.cpp)

Expand All @@ -35,3 +30,5 @@ target_link_libraries(react_newarchdefaults
react_nativemodule_microtasks
react_nativemodule_idlecallbacks
jsi)

target_compile_reactnative_options(react_newarchdefaults PRIVATE "ReactNative")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(-fexceptions -frtti -std=c++20 -Wall)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

add_library(reactperfloggerjni INTERFACE)

Expand All @@ -20,3 +20,5 @@ target_link_libraries(reactperfloggerjni
fbjni
android
reactperflogger)

target_compile_reactnative_options(reactperfloggerjni INTERFACE)
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(
-fexceptions
-frtti
-Wno-unused-lambda-capture
-std=c++20)


#########################
### cxxreactpackage ###
#########################
Expand All @@ -28,3 +21,7 @@ target_link_libraries(react_cxxreactpackage
INTERFACE
fb
fbjni)

include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)
target_compile_reactnative_options(react_cxxreactpackage INTERFACE)
target_compile_options(react_cxxreactpackage INTERFACE -Wno-unused-lambda-capture)
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB_RECURSE hermes_instance_jni_SRC CONFIGURE_DEPENDS *.cpp)

add_library(hermesinstancejni
OBJECT
${hermes_instance_jni_SRC}
)
target_compile_options(
hermesinstancejni
PRIVATE
$<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>
-std=c++20
-fexceptions
)

target_include_directories(hermesinstancejni PRIVATE .)
target_merge_so(hermesinstancejni)

Expand All @@ -32,3 +25,6 @@ target_link_libraries(hermesinstancejni
bridgelesshermes
reactnative
)

target_compile_reactnative_options(hermesinstancejni PRIVATE)
target_compile_options(hermesinstancejni PRIVATE $<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>)
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

include(${REACT_ANDROID_DIR}/src/main/jni/first-party/jni-lib-merge/SoMerging-utils.cmake)
include(${REACT_ANDROID_DIR}/cmake-utils/react-native-flags.cmake)

file(GLOB_RECURSE bridgeless_jni_SRC CONFIGURE_DEPENDS *.cpp)

add_library(rninstance
OBJECT
${bridgeless_jni_SRC}
)
target_compile_options(
rninstance
PRIVATE
$<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>
-std=c++20
-fexceptions
)

target_compile_reactnative_options(rninstance PRIVATE)
target_compile_options(rninstance PRIVATE $<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>)

target_merge_so(rninstance)
target_include_directories(rninstance PUBLIC .)
target_link_libraries(
Expand Down
Loading
Loading