From 9517320176ee410fe6c78e8fae6c257060f4a819 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Wed, 23 Nov 2022 18:48:47 -0800 Subject: [PATCH] Enable C++17 for cxxreact and jsiexecutor/inspector and ... (#35435) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35435 This raises the C++ language standard to C++17 which is needed to remove some folly:: dependencies changelog: [Internal] Reviewed By: cortinico Differential Revision: D41482821 fbshipit-source-id: 62af6e95e6e78378112a4ce4e9c3ab7df0587218 --- ReactAndroid/src/main/jni/CMakeLists.txt | 2 +- .../src/main/jni/react/hermes/reactexecutor/CMakeLists.txt | 1 + ReactCommon/cxxreact/CMakeLists.txt | 1 + ReactCommon/cxxreact/React-cxxreact.podspec | 3 ++- ReactCommon/hermes/React-hermes.podspec | 3 ++- ReactCommon/hermes/executor/CMakeLists.txt | 2 ++ ReactCommon/hermes/inspector/CMakeLists.txt | 1 + ReactCommon/jsiexecutor/CMakeLists.txt | 6 +++++- ReactCommon/jsiexecutor/React-jsiexecutor.podspec | 3 ++- ReactCommon/jsinspector/CMakeLists.txt | 4 +++- ReactCommon/jsinspector/React-jsinspector.podspec | 1 + 11 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/jni/CMakeLists.txt b/ReactAndroid/src/main/jni/CMakeLists.txt index 420794146092e8..bd13fa34b5e7e0 100644 --- a/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/ReactAndroid/src/main/jni/CMakeLists.txt @@ -17,7 +17,7 @@ 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 -std=c++1y) +add_compile_options(-Wall -Werror -std=c++17) function(add_react_android_subdir relative_path) add_subdirectory(${REACT_ANDROID_DIR}/${relative_path} ReactAndroid/${relative_path}) diff --git a/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt b/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt index d446141c7ed92d..3145a733fe5c4d 100644 --- a/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt +++ b/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt @@ -25,6 +25,7 @@ target_compile_options( ${HERMES_TARGET_NAME} PRIVATE $<$:-DHERMES_ENABLE_DEBUGGER=1> + -std=c++17 -fexceptions ) target_include_directories(${HERMES_TARGET_NAME} PRIVATE .) diff --git a/ReactCommon/cxxreact/CMakeLists.txt b/ReactCommon/cxxreact/CMakeLists.txt index 5518b0909efc27..2aa8c299dc1c38 100644 --- a/ReactCommon/cxxreact/CMakeLists.txt +++ b/ReactCommon/cxxreact/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_VERBOSE_MAKEFILE on) add_compile_options( -fexceptions -frtti + -std=c++17 -Wno-unused-lambda-capture -DLOG_TAG=\"ReactNative\") diff --git a/ReactCommon/cxxreact/React-cxxreact.podspec b/ReactCommon/cxxreact/React-cxxreact.podspec index b672f5489764b2..a2c66cf7eb5c4b 100644 --- a/ReactCommon/cxxreact/React-cxxreact.podspec +++ b/ReactCommon/cxxreact/React-cxxreact.podspec @@ -33,7 +33,8 @@ Pod::Spec.new do |s| s.source_files = "*.{cpp,h}" s.exclude_files = "SampleCxxModule.*" s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags - s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"" } + s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } s.header_dir = "cxxreact" s.dependency "boost", "1.76.0" diff --git a/ReactCommon/hermes/React-hermes.podspec b/ReactCommon/hermes/React-hermes.podspec index 02a072c313df67..dc1036c0bb3f61 100644 --- a/ReactCommon/hermes/React-hermes.podspec +++ b/ReactCommon/hermes/React-hermes.podspec @@ -40,7 +40,8 @@ Pod::Spec.new do |s| s.public_header_files = "executor/HermesExecutorFactory.h" s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/hermes-engine/destroot/include\" \"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include\"" + "HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/hermes-engine/destroot/include\" \"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include\"", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" }.merge!(build_type == :debug ? { "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } : {}) s.header_dir = "reacthermes" s.dependency "React-cxxreact", version diff --git a/ReactCommon/hermes/executor/CMakeLists.txt b/ReactCommon/hermes/executor/CMakeLists.txt index a6d8bbac1ddf01..b6575a08e19937 100644 --- a/ReactCommon/hermes/executor/CMakeLists.txt +++ b/ReactCommon/hermes/executor/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE on) +add_compile_options(-std=c++17) + file(GLOB_RECURSE hermes_executor_SRC CONFIGURE_DEPENDS *.cpp) add_library( hermes-executor-common diff --git a/ReactCommon/hermes/inspector/CMakeLists.txt b/ReactCommon/hermes/inspector/CMakeLists.txt index 14f6f1ce263900..e08a1eaadd2817 100644 --- a/ReactCommon/hermes/inspector/CMakeLists.txt +++ b/ReactCommon/hermes/inspector/CMakeLists.txt @@ -17,6 +17,7 @@ target_compile_options( PRIVATE -DHERMES_ENABLE_DEBUGGER=1 -DHERMES_INSPECTOR_FOLLY_KLUDGE=1 + -std=c++17 -fexceptions ) diff --git a/ReactCommon/jsiexecutor/CMakeLists.txt b/ReactCommon/jsiexecutor/CMakeLists.txt index 68597560a0c69c..ae63005ed6d022 100644 --- a/ReactCommon/jsiexecutor/CMakeLists.txt +++ b/ReactCommon/jsiexecutor/CMakeLists.txt @@ -6,7 +6,11 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE on) -add_compile_options(-fexceptions -frtti -O3) +add_compile_options( + -fexceptions + -frtti + -std=c++17 + -O3) add_library(jsireact STATIC diff --git a/ReactCommon/jsiexecutor/React-jsiexecutor.podspec b/ReactCommon/jsiexecutor/React-jsiexecutor.podspec index cbfaf3879a3270..cedebb9e6479ce 100644 --- a/ReactCommon/jsiexecutor/React-jsiexecutor.podspec +++ b/ReactCommon/jsiexecutor/React-jsiexecutor.podspec @@ -31,7 +31,8 @@ Pod::Spec.new do |s| s.source = source s.source_files = "jsireact/*.{cpp,h}" s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags - s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"" } + s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } s.header_dir = "jsireact" s.dependency "React-cxxreact", version diff --git a/ReactCommon/jsinspector/CMakeLists.txt b/ReactCommon/jsinspector/CMakeLists.txt index 511afcb9a43d52..dd361e90b9a132 100644 --- a/ReactCommon/jsinspector/CMakeLists.txt +++ b/ReactCommon/jsinspector/CMakeLists.txt @@ -6,7 +6,9 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE on) -add_compile_options(-fexceptions) +add_compile_options( + -fexceptions + -std=c++17) file(GLOB jsinspector_SRC CONFIGURE_DEPENDS *.cpp) add_library(jsinspector SHARED ${jsinspector_SRC}) diff --git a/ReactCommon/jsinspector/React-jsinspector.podspec b/ReactCommon/jsinspector/React-jsinspector.podspec index cf77de1da3044b..4b6d9a9287f0bd 100644 --- a/ReactCommon/jsinspector/React-jsinspector.podspec +++ b/ReactCommon/jsinspector/React-jsinspector.podspec @@ -27,4 +27,5 @@ Pod::Spec.new do |s| s.source = source s.source_files = "*.{cpp,h}" s.header_dir = 'jsinspector' + s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } end