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