| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections -fvisibility=hidden -flto=full") |
| 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -flto=full") |
| 8 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full -Wl,--gc-sections -Wl,--icf=safe -Wl,-Bsymbolic") |
| 9 |
| 10 | if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "arm64-v8a") |
| 11 | enable_language(ASM) |
| 12 | else() |
| 13 | enable_language(ASM_NASM) |
| 14 | endif() |
| 15 |
| 16 | add_library(avutil STATIC IMPORTED) |
| 17 | set_target_properties(avutil PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavutil.a) |
| 18 |
| 19 | add_library(avformat STATIC IMPORTED) |
| 20 | set_target_properties(avformat PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavformat.a) |
| 21 |
| 22 | add_library(avcodec STATIC IMPORTED) |
| 23 | set_target_properties(avcodec PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavcodec.a) |
| 24 |
| 25 | add_library(swresample STATIC IMPORTED) |
| 26 | set_target_properties(swresample PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libswresample.a) |
| 27 |
| 28 | add_library(swscale STATIC IMPORTED) |
| 29 | set_target_properties(swscale PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libswscale.a) |
| 30 |
| 31 | add_library(crypto STATIC IMPORTED) |
| 32 | set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/boringssl/lib/${ANDROID_ABI}/libcrypto.a) |
| 33 |
| 34 | add_library(ssl STATIC IMPORTED) |
| 35 | set_target_properties(ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/boringssl/lib/${ANDROID_ABI}/libssl.a) |
| 36 |
| 37 | add_library(libvpx STATIC IMPORTED) |
| 38 | set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libvpx.a) |
| 39 |
| 40 | add_library(libdav1d STATIC IMPORTED) |
| 41 | set_target_properties(libdav1d PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libdav1d.a) |
| 42 |
| 43 | add_library(libopus STATIC IMPORTED) |
| 44 | set_target_properties(libopus PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libopus.a) |
| 45 |
| 46 | add_library(tde2e STATIC IMPORTED) |
| 47 | set_target_properties(tde2e PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/tde2e/${ANDROID_ABI}/libtde2e.a) |
| 48 |
| 49 | add_library(tdutils STATIC IMPORTED) |
| 50 | set_target_properties(tdutils PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/tde2e/${ANDROID_ABI}/libtdutils.a) |
| 51 |
| 52 | #tgnet |
| 53 | add_library(tgnet STATIC |
| 54 | tgnet/ApiScheme.cpp |
| 55 | tgnet/BuffersStorage.cpp |
| 56 | tgnet/ByteArray.cpp |
| 57 | tgnet/ByteStream.cpp |
| 58 | tgnet/Connection.cpp |
| 59 | tgnet/ConnectionSession.cpp |
| 60 | tgnet/ConnectionsManager.cpp |
| 61 | tgnet/ConnectionSocket.cpp |
| 62 | tgnet/Datacenter.cpp |
| 63 | tgnet/EventObject.cpp |
| 64 | tgnet/FileLog.cpp |
| 65 | tgnet/MTProtoScheme.cpp |
| 66 | tgnet/NativeByteBuffer.cpp |
| 67 | tgnet/Request.cpp |
| 68 | tgnet/Timer.cpp |
| 69 | tgnet/TLObject.cpp |
| 70 | tgnet/ProxyCheckInfo.cpp |
| 71 | tgnet/Handshake.cpp |
| 72 | tgnet/Config.cpp) |
| 73 | target_compile_options(tgnet PUBLIC |
| 74 | -Wall -frtti -finline-functions -ffast-math -Oz) |
| 75 | set_target_properties(tgnet PROPERTIES |
| 76 | ANDROID_ARM_MODE arm) |
| 77 | target_compile_definitions(tgnet PUBLIC |
| 78 | HAVE_PTHREAD) |
| 79 | target_include_directories(tgnet PUBLIC |
| 80 | boringssl/include/) |
| 81 | target_link_libraries(tgnet |
| 82 | crypto) |
| 83 |
| 84 | # tlottie (prebuilt Rust static library) |
| 85 | add_library(tlottie STATIC IMPORTED) |
| 86 | set_target_properties(tlottie PROPERTIES |
| 87 | IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/tlottie_lib/${ANDROID_ABI}/libtlottie.a) |
| 88 |
| 89 | #sqlite |
| 90 | add_library(sqlite STATIC |
| 91 | sqlite/sqlite3.c) |
| 92 | target_compile_options(sqlite PUBLIC |
| 93 | -fno-strict-aliasing -Oz) |
| 94 | set_target_properties(sqlite PROPERTIES |
| 95 | ANDROID_ARM_MODE arm) |
| 96 | target_compile_definitions(sqlite PUBLIC |
| 97 | NULL=0 SOCKLEN_T=socklen_t LOCALE_NOT_USED ANDROID_NDK DISABLE_IMPORTGL AVOID_TABLES ANDROID_TILE_BASED_DECODE HAVE_STRCHRNUL=0 ANDROID_ARMV6_IDCT) |
| 98 |
| 99 | #breakpad |
| 100 | add_library(breakpad STATIC |
| 101 | third_party/breakpad/src/client/linux/crash_generation/crash_generation_client.cc |
| 102 | third_party/breakpad/src/client/linux/handler/exception_handler.cc |
| 103 | third_party/breakpad/src/client/linux/handler/minidump_descriptor.cc |
| 104 | third_party/breakpad/src/client/linux/log/log.cc |
| 105 | third_party/breakpad/src/client/linux/dump_writer_common/thread_info.cc |
| 106 | third_party/breakpad/src/client/linux/dump_writer_common/seccomp_unwinder.cc |
| 107 | third_party/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc |
| 108 | third_party/breakpad/src/client/linux/microdump_writer/microdump_writer.cc |
| 109 | third_party/breakpad/src/client/linux/minidump_writer/linux_dumper.cc |
| 110 | third_party/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc |
| 111 | third_party/breakpad/src/client/linux/minidump_writer/minidump_writer.cc |
| 112 | third_party/breakpad/src/client/minidump_file_writer.cc |
| 113 | third_party/breakpad/src/common/android/breakpad_getcontext.S |
| 114 | third_party/breakpad/src/common/convert_UTF.c |
| 115 | third_party/breakpad/src/common/md5.cc |
| 116 | third_party/breakpad/src/common/string_conversion.cc |
| 117 | third_party/breakpad/src/common/linux/elfutils.cc |
| 118 | third_party/breakpad/src/common/linux/file_id.cc |
| 119 | third_party/breakpad/src/common/linux/guid_creator.cc |
| 120 | third_party/breakpad/src/common/linux/linux_libc_support.cc |
| 121 | third_party/breakpad/src/common/linux/memory_mapped_file.cc |
| 122 | third_party/breakpad/src/common/linux/safe_readlink.cc) |
| 123 | set_target_properties(breakpad PROPERTIES ANDROID_ARM_MODE arm) |
| 124 | set_property(SOURCE third_party/breakpad/src/common/android/breakpad_getcontext.S PROPERTY LANGUAGE C) |
| 125 | target_include_directories(breakpad PUBLIC |
| 126 | third_party/breakpad/src/common/android/include |
| 127 | third_party/breakpad/src) |
| 128 |
| 129 |
| 130 | #voip |
| 131 | include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt) |
| 132 |
| 133 | set(NATIVE_LIB "tmessages.49") |
| 134 |
| 135 | #tmessages |
| 136 | add_library(${NATIVE_LIB} SHARED |
| 137 | jni.c |
| 138 | audio.c |
| 139 | webm_encoder.c |
| 140 | image.cpp |
| 141 | intro/IntroRenderer.c |
| 142 | SqliteWrapper.cpp |
| 143 | utilities.cpp |
| 144 | gifvideo.cpp |
| 145 | lottie.cpp |
| 146 | TgNetWrapper.cpp |
| 147 | exoplayer/ffmpeg_jni.cc |
| 148 | fast-edge.cpp |
| 149 | genann.c |
| 150 | secureid_ocr.cpp |
| 151 | tde2e/bridge.cpp |
| 152 | ) |
| 153 |
| 154 | target_compile_options(${NATIVE_LIB} PUBLIC |
| 155 | -ffast-math -Oz -funroll-loops -ffast-math -fno-strict-aliasing -fno-math-errno) |
| 156 |
| 157 | target_compile_definitions(${NATIVE_LIB} PUBLIC |
| 158 | BSD=1 NULL=0 SOCKLEN_T=socklen_t ANDROID_NDK DISABLE_IMPORTGL AVOID_TABLES ANDROID_TILE_BASED_DECODE __STDC_CONSTANT_MACROS ANDROID_ARMV6_IDCT OPUS_BUILD FIXED_POINT USE_ALLOCA restrict= __EMX__ LOCALE_NOT_USED HAVE_LRINT HAVE_LRINTF) |
| 159 |
| 160 | if (${ANDROID_ABI} STREQUAL "armeabi-v7a") |
| 161 | set_target_properties(${NATIVE_LIB} PROPERTIES |
| 162 | ANDROID_ARM_NEON FALSE |
| 163 | ANDROID_ARM_MODE arm) |
| 164 | target_compile_definitions(${NATIVE_LIB} PUBLIC |
| 165 | ANDROID_ARM_NEON=false) |
| 166 | target_sources(${NATIVE_LIB} PRIVATE |
| 167 | third_party/libyuv/source/compare_neon.cc |
| 168 | third_party/libyuv/source/rotate_neon.cc |
| 169 | third_party/libyuv/source/row_neon.cc |
| 170 | third_party/libyuv/source/scale_neon.cc) |
| 171 | else() |
| 172 | set_target_properties(${NATIVE_LIB} PROPERTIES |
| 173 | ANDROID_ARM_NEON FALSE |
| 174 | ANDROID_ARM_MODE arm) |
| 175 | endif() |
| 176 |
| 177 | if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "arm64-v8a") |
| 178 | target_compile_definitions(${NATIVE_LIB} PUBLIC |
| 179 | LIBYUV_NEON) |
| 180 |
| 181 | elseif(${ANDROID_ABI} STREQUAL "x86") |
| 182 | target_compile_definitions(${NATIVE_LIB} PUBLIC |
| 183 | x86fix) |
| 184 | endif() |
| 185 |
| 186 | target_sources(${NATIVE_LIB} PRIVATE |
| 187 |
| 188 | third_party/xiph/opusfile/src/info.c |
| 189 | third_party/xiph/opusfile/src/internal.c |
| 190 | third_party/xiph/opusfile/src/opusfile.c |
| 191 | third_party/xiph/opusfile/src/stream.c |
| 192 | third_party/xiph/ogg/src/bitwise.c |
| 193 | third_party/xiph/ogg/src/framing.c |
| 194 | third_party/libyuv/source/compare_common.cc |
| 195 | third_party/libyuv/source/compare_gcc.cc |
| 196 | third_party/libyuv/source/compare_neon64.cc |
| 197 | third_party/libyuv/source/compare_win.cc |
| 198 | third_party/libyuv/source/compare.cc |
| 199 | third_party/libyuv/source/convert_argb.cc |
| 200 | third_party/libyuv/source/convert_from_argb.cc |
| 201 | third_party/libyuv/source/convert_from.cc |
| 202 | third_party/libyuv/source/convert_jpeg.cc |
| 203 | third_party/libyuv/source/convert_to_argb.cc |
| 204 | third_party/libyuv/source/convert_to_i420.cc |
| 205 | third_party/libyuv/source/convert.cc |
| 206 | third_party/libyuv/source/cpu_id.cc |
| 207 | third_party/libyuv/source/mjpeg_decoder.cc |
| 208 | third_party/libyuv/source/mjpeg_validate.cc |
| 209 | third_party/libyuv/source/planar_functions.cc |
| 210 | third_party/libyuv/source/rotate_any.cc |
| 211 | third_party/libyuv/source/rotate_argb.cc |
| 212 | third_party/libyuv/source/rotate_common.cc |
| 213 | third_party/libyuv/source/rotate_gcc.cc |
| 214 | third_party/libyuv/source/rotate_neon64.cc |
| 215 | third_party/libyuv/source/rotate_win.cc |
| 216 | third_party/libyuv/source/rotate.cc |
| 217 | third_party/libyuv/source/row_any.cc |
| 218 | third_party/libyuv/source/row_common.cc |
| 219 | third_party/libyuv/source/row_gcc.cc |
| 220 | third_party/libyuv/source/row_neon64.cc |
| 221 | third_party/libyuv/source/row_win.cc |
| 222 | third_party/libyuv/source/scale_any.cc |
| 223 | third_party/libyuv/source/scale_argb.cc |
| 224 | third_party/libyuv/source/scale_common.cc |
| 225 | third_party/libyuv/source/scale_gcc.cc |
| 226 | third_party/libyuv/source/scale_neon64.cc |
| 227 | third_party/libyuv/source/scale_win.cc |
| 228 | third_party/libyuv/source/scale.cc |
| 229 | third_party/libyuv/source/video_common.cc |
| 230 | third_party/libyuv/source/scale_uv.cc |
| 231 | third_party/libyuv/source/rotate_lsx.cc |
| 232 | third_party/libyuv/source/row_lasx.cc |
| 233 | third_party/libyuv/source/row_lsx.cc |
| 234 | third_party/libyuv/source/scale_lsx.cc |
| 235 | third_party/libyuv/source/scale_rgb.cc) |
| 236 |
| 237 | target_include_directories(${NATIVE_LIB} PUBLIC |
| 238 | third_party/xiph/opus/include |
| 239 | third_party/xiph/opus/silk |
| 240 | third_party/xiph/opus/silk/fixed |
| 241 | third_party/xiph/opus/celt |
| 242 | third_party/xiph/opus |
| 243 | third_party/xiph/opusfile/include |
| 244 | third_party/xiph/ogg/include |
| 245 | third_party/libyuv/include |
| 246 | boringssl/include |
| 247 | ffmpeg/include |
| 248 | emoji |
| 249 | exoplayer/include |
| 250 | intro |
| 251 | tlottie/include |
| 252 | tgcalls/ |
| 253 | webrtc/ |
| 254 | tde2e/include |
| 255 | ) |
| 256 |
| 257 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,-z,max-page-size=16384") |
| 258 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,-z,common-page-size=16384") |
| 259 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports.map") |
| 260 | target_link_libraries(${NATIVE_LIB} |
| 261 | -Wl,--whole-archive rnnoise openh264 voipandroid -Wl,--no-whole-archive |
| 262 | tgvoip |
| 263 | tgcalls |
| 264 | tgcalls_tp |
| 265 | tgnet |
| 266 | tlottie |
| 267 | sqlite |
| 268 | swscale |
| 269 | avformat |
| 270 | avcodec |
| 271 | swresample |
| 272 | libvpx |
| 273 | libdav1d |
| 274 | libopus |
| 275 | tde2e |
| 276 | tdutils |
| 277 | avutil |
| 278 | ssl |
| 279 | crypto |
| 280 | jnigraphics |
| 281 | log |
| 282 | z |
| 283 | GLESv2 |
| 284 | EGL |
| 285 | android |
| 286 | OpenSLES |
| 287 | cpufeatures |
| 288 | breakpad) |
| 289 |
| 290 | #if (${ANDROID_ABI} STREQUAL "x86" OR ${ANDROID_ABI} STREQUAL "x86_64") |
| 291 | # target_link_libraries(${NATIVE_LIB} |
| 292 | # -Wl,--whole-archive vpxasm -Wl,--no-whole-archive |
| 293 | # c) |
| 294 | #endif() |
| 295 |
| 296 | include(AndroidNdkModules) |
| 297 | android_ndk_import_module_cpufeatures() |
| 298 |