| 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 | set(CAN_COMPILE_SME FALSE CACHE INTERNAL "Disable libyuv SME" FORCE) |
| 26 | add_subdirectory( |
| 27 | third_party/libyuv |
| 28 | ${CMAKE_CURRENT_BINARY_DIR}/libyuv |
| 29 | EXCLUDE_FROM_ALL) |
| 30 |
| 31 | add_library(avutil STATIC IMPORTED) |
| 32 | set_target_properties(avutil PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libavutil.a) |
| 33 |
| 34 | add_library(avformat STATIC IMPORTED) |
| 35 | set_target_properties(avformat PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libavformat.a) |
| 36 |
| 37 | add_library(avcodec STATIC IMPORTED) |
| 38 | set_target_properties(avcodec PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libavcodec.a) |
| 39 |
| 40 | add_library(swresample STATIC IMPORTED) |
| 41 | set_target_properties(swresample PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libswresample.a) |
| 42 |
| 43 | add_library(swscale STATIC IMPORTED) |
| 44 | set_target_properties(swscale PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libswscale.a) |
| 45 |
| 46 | add_library(crypto STATIC IMPORTED) |
| 47 | set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libcrypto.a) |
| 48 |
| 49 | add_library(ssl STATIC IMPORTED) |
| 50 | set_target_properties(ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libssl.a) |
| 51 |
| 52 |
| 53 | #aesige |
| 54 | #add_library(aesige STATIC openssl/aes_ige.c) |
| 55 | #target_compile_options(aesige PUBLIC -Wall -frtti -finline-functions -ffast-math -Oz) |
| 56 | #target_include_directories(aesige PUBLIC third_party/boringssl/include openssl/include) |
| 57 | #target_link_libraries(aesige crypto) |
| 58 |
| 59 |
| 60 | add_library(libvpx STATIC IMPORTED) |
| 61 | set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libvpx.a) |
| 62 |
| 63 | add_library(libdav1d STATIC IMPORTED) |
| 64 | set_target_properties(libdav1d PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libdav1d.a) |
| 65 |
| 66 | add_library(libopus STATIC IMPORTED) |
| 67 | set_target_properties(libopus PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libopus.a) |
| 68 |
| 69 | add_library(tde2e STATIC IMPORTED) |
| 70 | set_target_properties(tde2e PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libtde2e.a) |
| 71 |
| 72 | add_library(tdutils STATIC IMPORTED) |
| 73 | set_target_properties(tdutils PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libtdutils.a) |
| 74 |
| 75 | #tgnet |
| 76 | add_library(tgnet STATIC |
| 77 | openssl/aes_ige.c |
| 78 | tgnet/ApiScheme.cpp |
| 79 | tgnet/BuffersStorage.cpp |
| 80 | tgnet/ByteArray.cpp |
| 81 | tgnet/ByteStream.cpp |
| 82 | tgnet/Connection.cpp |
| 83 | tgnet/ConnectionSession.cpp |
| 84 | tgnet/ConnectionsManager.cpp |
| 85 | tgnet/TLSHello.cpp |
| 86 | tgnet/ConnectionSocket.cpp |
| 87 | tgnet/Datacenter.cpp |
| 88 | tgnet/EventObject.cpp |
| 89 | tgnet/FileLog.cpp |
| 90 | tgnet/MTProtoScheme.cpp |
| 91 | tgnet/NativeByteBuffer.cpp |
| 92 | tgnet/Request.cpp |
| 93 | tgnet/Timer.cpp |
| 94 | tgnet/TLObject.cpp |
| 95 | tgnet/ProxyCheckInfo.cpp |
| 96 | tgnet/Handshake.cpp |
| 97 | tgnet/Config.cpp) |
| 98 | target_compile_options(tgnet PUBLIC |
| 99 | -Wall -frtti -finline-functions -ffast-math -Oz) |
| 100 | set_target_properties(tgnet PROPERTIES |
| 101 | ANDROID_ARM_MODE arm) |
| 102 | target_compile_definitions(tgnet PUBLIC |
| 103 | HAVE_PTHREAD) |
| 104 | target_include_directories(tgnet PUBLIC |
| 105 | third_party/boringssl/include |
| 106 | openssl/include) |
| 107 | target_link_libraries(tgnet |
| 108 | crypto) |
| 109 |
| 110 | # tlottie (prebuilt Rust static library) |
| 111 | add_library(tlottie STATIC IMPORTED) |
| 112 | set_target_properties(tlottie PROPERTIES |
| 113 | IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libtlottie.a) |
| 114 |
| 115 | #sqlite |
| 116 | add_library(sqlite STATIC |
| 117 | sqlite/sqlite3.c) |
| 118 | target_compile_options(sqlite PUBLIC |
| 119 | -fno-strict-aliasing -Oz) |
| 120 | set_target_properties(sqlite PROPERTIES |
| 121 | ANDROID_ARM_MODE arm) |
| 122 | target_compile_definitions(sqlite PUBLIC |
| 123 | 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) |
| 124 |
| 125 | #breakpad |
| 126 | add_library(breakpad STATIC |
| 127 | third_party/breakpad/src/client/linux/crash_generation/crash_generation_client.cc |
| 128 | third_party/breakpad/src/client/linux/handler/exception_handler.cc |
| 129 | third_party/breakpad/src/client/linux/handler/minidump_descriptor.cc |
| 130 | third_party/breakpad/src/client/linux/log/log.cc |
| 131 | third_party/breakpad/src/client/linux/dump_writer_common/thread_info.cc |
| 132 | third_party/breakpad/src/client/linux/dump_writer_common/seccomp_unwinder.cc |
| 133 | third_party/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc |
| 134 | third_party/breakpad/src/client/linux/microdump_writer/microdump_writer.cc |
| 135 | third_party/breakpad/src/client/linux/minidump_writer/linux_dumper.cc |
| 136 | third_party/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc |
| 137 | third_party/breakpad/src/client/linux/minidump_writer/minidump_writer.cc |
| 138 | third_party/breakpad/src/client/minidump_file_writer.cc |
| 139 | third_party/breakpad/src/common/android/breakpad_getcontext.S |
| 140 | third_party/breakpad/src/common/convert_UTF.c |
| 141 | third_party/breakpad/src/common/md5.cc |
| 142 | third_party/breakpad/src/common/string_conversion.cc |
| 143 | third_party/breakpad/src/common/linux/elfutils.cc |
| 144 | third_party/breakpad/src/common/linux/file_id.cc |
| 145 | third_party/breakpad/src/common/linux/guid_creator.cc |
| 146 | third_party/breakpad/src/common/linux/linux_libc_support.cc |
| 147 | third_party/breakpad/src/common/linux/memory_mapped_file.cc |
| 148 | third_party/breakpad/src/common/linux/safe_readlink.cc) |
| 149 | set_target_properties(breakpad PROPERTIES ANDROID_ARM_MODE arm) |
| 150 | set_property(SOURCE third_party/breakpad/src/common/android/breakpad_getcontext.S PROPERTY LANGUAGE C) |
| 151 | target_include_directories(breakpad PUBLIC |
| 152 | third_party/breakpad/src/common/android/include |
| 153 | third_party/breakpad/src) |
| 154 |
| 155 |
| 156 | #voip |
| 157 | include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt) |
| 158 |
| 159 | # verify |
| 160 | include(${CMAKE_HOME_DIRECTORY}/integrity/CMakeLists.txt) |
| 161 |
| 162 | set(NATIVE_LIB "tmessages.49") |
| 163 |
| 164 | #tmessages |
| 165 | add_library(${NATIVE_LIB} SHARED |
| 166 | jni.c |
| 167 | audio.c |
| 168 | webm_encoder.c |
| 169 | webm_to_gif.cpp |
| 170 | image.cpp |
| 171 | intro/IntroRenderer.c |
| 172 | SqliteWrapper.cpp |
| 173 | utilities.cpp |
| 174 | gifvideo.cpp |
| 175 | lottie.cpp |
| 176 | TgNetWrapper.cpp |
| 177 | ffmpeg_jni.cc |
| 178 | fast-edge.cpp |
| 179 | genann.c |
| 180 | secureid_ocr.cpp |
| 181 | tde2e/bridge.cpp |
| 182 | tests.cpp |
| 183 | ) |
| 184 |
| 185 | target_compile_options(${NATIVE_LIB} PUBLIC |
| 186 | -ffast-math -Oz -funroll-loops -ffast-math -fno-strict-aliasing -fno-math-errno) |
| 187 |
| 188 | target_compile_definitions(${NATIVE_LIB} PUBLIC |
| 189 | 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) |
| 190 |
| 191 | target_sources(${NATIVE_LIB} PRIVATE |
| 192 |
| 193 | third_party/xiph/opusfile/src/info.c |
| 194 | third_party/xiph/opusfile/src/internal.c |
| 195 | third_party/xiph/opusfile/src/opusfile.c |
| 196 | third_party/xiph/opusfile/src/stream.c |
| 197 | third_party/xiph/ogg/src/bitwise.c |
| 198 | third_party/xiph/ogg/src/framing.c) |
| 199 |
| 200 | target_include_directories(${NATIVE_LIB} PUBLIC |
| 201 | third_party/xiph/opus/include |
| 202 | third_party/xiph/opus/silk |
| 203 | third_party/xiph/opus/silk/fixed |
| 204 | third_party/xiph/opus/celt |
| 205 | third_party/xiph/opus |
| 206 | third_party/xiph/opusfile/include |
| 207 | third_party/xiph/ogg/include |
| 208 | third_party/libyuv/include |
| 209 | third_party/boringssl/include |
| 210 | openssl/include |
| 211 | prebuild/include/${ANDROID_ABI} |
| 212 | third_party/ffmpeg |
| 213 | third_party/libvpx |
| 214 | third_party/dav1d/include |
| 215 | emoji |
| 216 | exoplayer/include |
| 217 | intro |
| 218 | tlottie/include |
| 219 | tgcalls/ |
| 220 | webrtc/ |
| 221 | td/tde2e |
| 222 | td/tde2e/td/e2e |
| 223 | ) |
| 224 |
| 225 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,-z,max-page-size=16384") |
| 226 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,-z,common-page-size=16384") |
| 227 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports.map") |
| 228 | target_link_libraries(${NATIVE_LIB} |
| 229 | -Wl,--whole-archive rnnoise openh264 voipandroid -Wl,--no-whole-archive |
| 230 | tgcalls |
| 231 | tgcalls_tp |
| 232 | tgnet |
| 233 | tlottie |
| 234 | sqlite |
| 235 | swscale |
| 236 | avformat |
| 237 | avcodec |
| 238 | swresample |
| 239 | libvpx |
| 240 | libdav1d |
| 241 | libopus |
| 242 | tde2e |
| 243 | tdutils |
| 244 | yuv |
| 245 | avutil |
| 246 | ssl |
| 247 | crypto |
| 248 | jnigraphics |
| 249 | log |
| 250 | z |
| 251 | GLESv2 |
| 252 | EGL |
| 253 | android |
| 254 | OpenSLES |
| 255 | cpufeatures |
| 256 | integrity |
| 257 | breakpad) |
| 258 |
| 259 |
| 260 | include(AndroidNdkModules) |
| 261 | android_ndk_import_module_cpufeatures() |
| 262 |