diff --git a/native/android/app/CMakeLists.txt b/native/android/app/CMakeLists.txt --- a/native/android/app/CMakeLists.txt +++ b/native/android/app/CMakeLists.txt @@ -4,8 +4,13 @@ set (CMAKE_CXX_STANDARD 14) -# Sets the minimum version of CMake required to build the native library. +# C0103 is a naming convention, but the variable names which need to be set +# are determined by the upstream project +# cmake-lint: disable=C0103 +# Disable line length as some paths are hard to reduce without becoming cryptic +# cmake-lint: disable=C0301 +# Sets the minimum version of CMake required to build the native library. cmake_minimum_required(VERSION 3.4.1) # Creates and names a library, sets it as either STATIC @@ -22,6 +27,10 @@ set(WITH_GTEST OFF CACHE BOOL "Use googletest" FORCE) set(WITH_GFLAGS OFF CACHE BOOL "Use gflags" FORCE) +# General +set(_third_party_dir ${CMAKE_CURRENT_SOURCE_DIR}/build/third-party-ndk) +set(_android_build_dir build/${CMAKE_ANDROID_ARCH_ABI}) + # Protobuf set(protobuf_BUILD_TESTS OFF) @@ -34,26 +43,34 @@ set(gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF) set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF) # We're updating parameters below for Cmake's find_OpenSSL() function -set(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/third-party-ndk/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}") +set(OPENSSL_ROOT_DIR + "${_third_party_dir}/openssl/openssl-${OPENSSL_VERSION}/${_android_build_dir}" +) list(APPEND CMAKE_FIND_ROOT_PATH "${OPENSSL_ROOT_DIR}") -add_subdirectory(./build/third-party-ndk/grpc/grpc-${GRPC_VERSION}/ ${CMAKE_CURRENT_BINARY_DIR}/grpc/ EXCLUDE_FROM_ALL) -add_subdirectory(./build/third-party-ndk/glog/glog-${GLOG_VERSION}/) +add_subdirectory(${_third_party_dir}/grpc/grpc-${GRPC_VERSION}/ + ${CMAKE_CURRENT_BINARY_DIR}/grpc/ + EXCLUDE_FROM_ALL +) +add_subdirectory(${_third_party_dir}/glog/glog-${GLOG_VERSION}/) add_subdirectory(../../node_modules/olm ./build) +set(_node_modules_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../node_modules) +set(_react_native_dir ${_node_modules_dir}/react-native) + include_directories( - ../../node_modules/react-native/React - ../../node_modules/react-native/React/Base - ../../node_modules/react-native/ReactCommon - ../../node_modules/react-native/ReactCommon/jsi - ../../node_modules/react-native/ReactCommon/callinvoker - ../../node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon + ${_react_native_dir}/React + ${_react_native_dir}/React/Base + ${_react_native_dir}/ReactCommon + ${_react_native_dir}/ReactCommon/jsi + ${_react_native_dir}/ReactCommon/callinvoker + ${_react_native_dir}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon # OpenSSL - ./build/third-party-ndk/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}/include + ${_third_party_dir}/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}/include # SQLCipher amalgamation - ../../node_modules/@commapp/sqlcipher-amalgamation/src + ${_node_modules_dir}/@commapp/sqlcipher-amalgamation/src # SQLite ORM ../../cpp/lib/sqlite_orm @@ -62,9 +79,9 @@ ../headers # external libs - ./build/third-party-ndk/folly - ./build/third-party-ndk/boost/boost - ./build/third-party-ndk/double-conversion + ${_third_party_dir}/folly + ${_third_party_dir}/boost/boost + ${_third_party_dir}/double-conversion # comm android specific code ./src/cpp @@ -83,10 +100,14 @@ ) # search for all cpp files in this directory -file(GLOB SQLCIPHER "../../node_modules/@commapp/sqlcipher-amalgamation/src/*.c") +file(GLOB SQLCIPHER + "${_node_modules_dir}/@commapp/sqlcipher-amalgamation/src/*.c" +) file(GLOB_RECURSE COMMON_NATIVE_CODE "../../cpp/CommonCpp/**/*.cpp") file(GLOB ANDROID_NATIVE_CODE "./src/cpp/*.cpp") -file(GLOB DOUBLE_CONVERSION_SOURCES "./build/third-party-ndk/double-conversion/double-conversion/*.cc") +file(GLOB DOUBLE_CONVERSION_SOURCES + "${_third_party_dir}/double-conversion/double-conversion/*.cc" +) file(GLOB GRPC_CODE "../../cpp/CommonCpp/grpc/_generated/*.cc") add_library( @@ -97,37 +118,37 @@ SHARED # Provides a relative path to your source file(s). - ../../node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp - ../../node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/CallInvokerHolder.cpp - ../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp - ../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.cpp - ../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp - + ${_react_native_dir}/ReactCommon/jsi/jsi/jsi.cpp + ${_react_native_dir}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/CallInvokerHolder.cpp + ${_react_native_dir}/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.cpp + ${_react_native_dir}/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.cpp + ${_react_native_dir}/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp + # SQLCipher ${SQLCIPHER} # folly - ./build/third-party-ndk/folly/folly/detail/Futex.cpp - ./build/third-party-ndk/folly/folly/synchronization/ParkingLot.cpp - ./build/third-party-ndk/folly/folly/lang/SafeAssert.cpp - ./build/third-party-ndk/folly/folly/FileUtil.cpp - ./build/third-party-ndk/folly/folly/Subprocess.cpp - ./build/third-party-ndk/folly/folly/File.cpp - ./build/third-party-ndk/folly/folly/Format.cpp - ./build/third-party-ndk/folly/folly/Conv.cpp - ./build/third-party-ndk/folly/folly/io/IOBuf.cpp - ./build/third-party-ndk/folly/folly/memory/detail/MallocImpl.cpp - ./build/third-party-ndk/folly/folly/ScopeGuard.cpp - ./build/third-party-ndk/folly/folly/hash/SpookyHashV2.cpp - ./build/third-party-ndk/folly/folly/io/IOBufQueue.cpp - ./build/third-party-ndk/folly/folly/lang/Assume.cpp - ./build/third-party-ndk/folly/folly/String.cpp - ./build/third-party-ndk/folly/folly/portability/SysUio.cpp - ./build/third-party-ndk/folly/folly/net/NetOps.cpp - ./build/third-party-ndk/folly/folly/dynamic.cpp - ./build/third-party-ndk/folly/folly/json.cpp - ./build/third-party-ndk/folly/folly/json_pointer.cpp - ./build/third-party-ndk/folly/folly/Unicode.cpp + ${_third_party_dir}/folly/folly/detail/Futex.cpp + ${_third_party_dir}/folly/folly/synchronization/ParkingLot.cpp + ${_third_party_dir}/folly/folly/lang/SafeAssert.cpp + ${_third_party_dir}/folly/folly/FileUtil.cpp + ${_third_party_dir}/folly/folly/Subprocess.cpp + ${_third_party_dir}/folly/folly/File.cpp + ${_third_party_dir}/folly/folly/Format.cpp + ${_third_party_dir}/folly/folly/Conv.cpp + ${_third_party_dir}/folly/folly/io/IOBuf.cpp + ${_third_party_dir}/folly/folly/memory/detail/MallocImpl.cpp + ${_third_party_dir}/folly/folly/ScopeGuard.cpp + ${_third_party_dir}/folly/folly/hash/SpookyHashV2.cpp + ${_third_party_dir}/folly/folly/io/IOBufQueue.cpp + ${_third_party_dir}/folly/folly/lang/Assume.cpp + ${_third_party_dir}/folly/folly/String.cpp + ${_third_party_dir}/folly/folly/portability/SysUio.cpp + ${_third_party_dir}/folly/folly/net/NetOps.cpp + ${_third_party_dir}/folly/folly/dynamic.cpp + ${_third_party_dir}/folly/folly/json.cpp + ${_third_party_dir}/folly/folly/json_pointer.cpp + ${_third_party_dir}/folly/folly/Unicode.cpp # double-conversion ${DOUBLE_CONVERSION_SOURCES} @@ -157,26 +178,31 @@ find_library(log-lib log) add_library( - # OpenSSL Crypto lib - openssl-crypto - STATIC - IMPORTED + # OpenSSL Crypto lib + openssl-crypto + STATIC + IMPORTED ) + set_target_properties( - # OpenSSL Crypto lib - openssl-crypto - PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/build/third-party-ndk/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}/lib/libcrypto.a" + # OpenSSL Crypto lib + openssl-crypto + PROPERTIES IMPORTED_LOCATION + "${_third_party_dir}/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}/lib/libcrypto.a" ) + add_library( - # OpenSSL SSL lib - openssl-ssl - STATIC - IMPORTED + # OpenSSL SSL lib + openssl-ssl + STATIC + IMPORTED ) + set_target_properties( - # OpenSSL SSL lib - openssl-ssl - PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/build/third-party-ndk/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}/lib/libssl.a" + # OpenSSL SSL lib + openssl-ssl + PROPERTIES IMPORTED_LOCATION + "${_third_party_dir}/openssl/openssl-${OPENSSL_VERSION}/build/${CMAKE_ANDROID_ARCH_ABI}/lib/libssl.a" ) target_link_libraries(