cmake_minimum_required(VERSION 3.4 FATAL_ERROR) option(TD_ENABLE_JNI "Enable JNI-compatible TDLib API" ON) if (CMAKE_CROSSCOMPILING) string(APPEND CMAKE_CXX_FLAGS " -std=c++14 -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -Wconversion -Wno-sign-conversion -fno-omit-frame-pointer -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti") string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--gc-sections -Wl,--exclude-libs,ALL") # use prebuilt OpenSSL list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/crypto/${ANDROID_ARCH_NAME}") if (NOT OPENSSL_FOUND) find_package(OpenSSL REQUIRED) endif() add_subdirectory(td) add_library(tdjniclient JniClient.cpp JniClient.h ) target_link_libraries(tdjniclient PUBLIC tdutils tdclient) add_library(tdjni SHARED jni_helper.cpp jni_init.cpp telegram_NativeClient.cpp telegram_crypto.cpp jni_helper.h telegram_NativeClient.h telegram_crypto.h ) target_link_libraries(tdjni PRIVATE tdjniclient z atomic ${OPENSSL_CRYPTO_LIBRARY}) target_include_directories(tdjni PRIVATE ${OPENSSL_INCLUDE_DIR}) add_custom_command(TARGET tdjni POST_BUILD COMMAND ${CMAKE_COMMAND} -E rename $ $.debug COMMAND ${CMAKE_STRIP} --strip-debug --strip-unneeded $.debug -o $) else() add_subdirectory(td) set(TD_API_JAVA_PACKAGE "org/drinkless/td/libcore/telegram") set(TD_API_JAVA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../java/) set(TD_API_TLO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/td/generate/scheme/td_api.tlo) set(TD_API_TL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/td/generate/scheme/td_api.tl) set(JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/td/td/generate/JavadocTlDocumentationGenerator.php) set(GENERATE_JAVA_CMD td_generate_java_api TdApi ${TD_API_TLO_PATH} ${TD_API_JAVA_PATH} ${TD_API_JAVA_PACKAGE}) if (PHP_EXECUTABLE) set(GENERATE_JAVA_CMD ${GENERATE_JAVA_CMD} && ${PHP_EXECUTABLE} ${JAVADOC_TL_DOCUMENTATION_GENERATOR_PATH} ${TD_API_TL_PATH} ${TD_API_JAVA_PATH}/${TD_API_JAVA_PACKAGE}/TdApi.java androidx.annotation.Nullable @Nullable) endif() add_custom_target(tl_generate_java COMMAND ${GENERATE_JAVA_CMD} COMMENT "Generate java tl source files" DEPENDS td_generate_java_api ${TD_API_TLO_PATH} ) endif()