diff --git a/CMakeLists.txt b/CMakeLists.txt index a6a93e4a5b..ee4662eec0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,17 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + cmake_minimum_required(VERSION 3.16) cmake_policy(SET CMP0076 NEW) cmake_policy(SET CMP0091 NEW) set_property(GLOBAL PROPERTY USE_FOLDERS ON) +include(cmake/variables.cmake) + project(Telegram LANGUAGES C CXX VERSION 1.9.0 @@ -11,7 +19,6 @@ project(Telegram HOMEPAGE_URL "https://desktop.telegram.org" ) -include(cmake/paths.cmake) include(cmake/options.cmake) include(cmake/init_target.cmake) include(cmake/generate_target.cmake) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index bfd5f4e130..2dc4bf7225 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + add_executable(Telegram WIN32 MACOSX_BUNDLE) init_target(Telegram) @@ -24,10 +30,10 @@ get_filename_component(res_loc Resources REALPATH) include(cmake/lib_export.cmake) include(cmake/lib_ffmpeg.cmake) -include(cmake/lib_lz4.cmake) include(cmake/lib_mtproto.cmake) include(cmake/lib_scheme.cmake) include(cmake/lib_tgvoip.cmake) +include(cmake/telegram_options.cmake) set(style_files boxes/boxes.style @@ -60,7 +66,6 @@ generate_numbers(Telegram ${res_loc}/numbers.txt) set_target_properties(Telegram PROPERTIES AUTOMOC ON) set_target_properties(Telegram PROPERTIES AUTORCC ON) -set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") target_link_libraries(Telegram PRIVATE @@ -68,7 +73,6 @@ PRIVATE lib_crl lib_ui lib_tl - lib_spellcheck lib_storage lib_lottie lib_rlottie @@ -77,7 +81,7 @@ PRIVATE lib_export lib_ffmpeg lib_tgvoip - lib_lz4 + external_lz4 external_qt external_openssl external_crash_reports @@ -978,8 +982,8 @@ PRIVATE target_compile_definitions(Telegram PRIVATE - TDESKTOP_API_ID=17349 - TDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb + TDESKTOP_API_ID=${TDESKTOP_API_ID} + TDESKTOP_API_HASH=${TDESKTOP_API_HASH} AL_LIBTYPE_STATIC AL_ALEXT_PROTOTYPES ) @@ -994,3 +998,6 @@ PRIVATE _other/updater_osx.m ) nice_target_sources(Updater ${src_loc} "${updater_sources}") + +set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +set_target_properties(Updater PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") diff --git a/Telegram/cmake/generate_lang.cmake b/Telegram/cmake/generate_lang.cmake index d93516b38d..0f9008765a 100644 --- a/Telegram/cmake/generate_lang.cmake +++ b/Telegram/cmake/generate_lang.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + function(generate_lang target_name lang_file) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) set(generated_files diff --git a/Telegram/cmake/generate_numbers.cmake b/Telegram/cmake/generate_numbers.cmake index 0e5a0eb10f..fbe305cee1 100644 --- a/Telegram/cmake/generate_numbers.cmake +++ b/Telegram/cmake/generate_numbers.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + function(generate_numbers target_name numbers_file) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) set(generated_files diff --git a/Telegram/cmake/generate_scheme.cmake b/Telegram/cmake/generate_scheme.cmake index 6cb2513f19..b42ae22ab1 100644 --- a/Telegram/cmake/generate_scheme.cmake +++ b/Telegram/cmake/generate_scheme.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + function(generate_scheme target_name script scheme_files) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) set(generated_files diff --git a/Telegram/cmake/lib_export.cmake b/Telegram/cmake/lib_export.cmake index 6f9c3ebb1d..11570a20a9 100644 --- a/Telegram/cmake/lib_export.cmake +++ b/Telegram/cmake/lib_export.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + add_library(lib_export OBJECT) init_target(lib_export) diff --git a/Telegram/cmake/lib_ffmpeg.cmake b/Telegram/cmake/lib_ffmpeg.cmake index 870a89f44e..9191d00613 100644 --- a/Telegram/cmake/lib_ffmpeg.cmake +++ b/Telegram/cmake/lib_ffmpeg.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + add_library(lib_ffmpeg OBJECT) init_target(lib_ffmpeg) diff --git a/Telegram/cmake/lib_lz4.cmake b/Telegram/cmake/lib_lz4.cmake deleted file mode 100644 index 373c8366ac..0000000000 --- a/Telegram/cmake/lib_lz4.cmake +++ /dev/null @@ -1,22 +0,0 @@ -add_library(lib_lz4 OBJECT) -init_target(lib_lz4) - -set(lz4_loc ${third_party_loc}/lz4/lib) - -target_sources(lib_lz4 -PRIVATE - ${lz4_loc}/lz4.c - ${lz4_loc}/lz4.h - ${lz4_loc}/lz4frame.c - ${lz4_loc}/lz4frame.h - ${lz4_loc}/lz4frame_static.h - ${lz4_loc}/lz4hc.c - ${lz4_loc}/lz4hc.h - ${lz4_loc}/xxhash.c - ${lz4_loc}/xxhash.h -) - -target_include_directories(lib_lz4 -PUBLIC - ${lz4_loc} -) diff --git a/Telegram/cmake/lib_mtproto.cmake b/Telegram/cmake/lib_mtproto.cmake index 6ce8926ba7..9d1352765e 100644 --- a/Telegram/cmake/lib_mtproto.cmake +++ b/Telegram/cmake/lib_mtproto.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + add_library(lib_mtproto OBJECT) init_target(lib_mtproto) diff --git a/Telegram/cmake/lib_scheme.cmake b/Telegram/cmake/lib_scheme.cmake index eaf1fa4e06..8d3ac537e8 100644 --- a/Telegram/cmake/lib_scheme.cmake +++ b/Telegram/cmake/lib_scheme.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + add_library(lib_scheme OBJECT) init_target(lib_scheme) diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake index 16ff4853ab..22deae7bcb 100644 --- a/Telegram/cmake/lib_tgvoip.cmake +++ b/Telegram/cmake/lib_tgvoip.cmake @@ -1,3 +1,9 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + add_library(lib_tgvoip OBJECT) init_target(lib_tgvoip) @@ -708,7 +714,6 @@ PRIVATE WEBRTC_APM_DEBUG_DUMP=0 TGVOIP_USE_DESKTOP_DSP WEBRTC_NS_FLOAT - WEBRTC_WIN ) if (WIN32) @@ -716,6 +721,29 @@ if (WIN32) PRIVATE /wd4005 ) + target_compile_definitions(lib_tgvoip + PRIVATE + WEBRTC_WIN + ) +elseif (APPLE) + target_compile_definitions(lib_tgvoip + PRIVATE + WEBRTC_POSIX + WEBRTC_MAC + TARGET_OS_OSX + ) + if (build_macstore) + target_compile_definitions(lib_tgvoip + PRIVATE + TGVOIP_NO_OSX_PRIVATE_API + ) + endif() +else() + target_compile_definitions(lib_tgvoip + PRIVATE + WEBRTC_POSIX + WEBRTC_LINUX + ) endif() target_include_directories(lib_tgvoip diff --git a/Telegram/cmake/telegram_options.cmake b/Telegram/cmake/telegram_options.cmake new file mode 100644 index 0000000000..0a6c4eead9 --- /dev/null +++ b/Telegram/cmake/telegram_options.cmake @@ -0,0 +1,72 @@ +# This file is part of Telegram Desktop, +# the official desktop application for the Telegram messaging service. +# +# For license and copyright information please follow this link: +# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL + +option(TDESKTOP_FORCE_GTK_FILE_DIALOG "Force using GTK file dialog (Linux only)." OFF) +option(TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME "Disable automatic 'tg://' URL scheme handler registration." OFF) +option(TDESKTOP_DISABLE_NETWORK_PROXY "Disable all code for working through Socks5 or MTProxy." OFF) +option(TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION "Disable automatic '.desktop' file generation (Linux only)." OFF) +option(TDESKTOP_DISABLE_GTK_INTEGRATION "Disable all code for GTK integration (Linux only)." OFF) +option(TDESKTOP_API_TEST "Use test API credentials." OFF) +set(TDESKTOP_API_ID "0" CACHE STRING "Provide 'api_id' for the Telegram API access.") +set(TDESKTOP_API_HASH "" CACHE STRING "Provide 'api_hash' for the Telegram API access.") + +if (TDESKTOP_API_TEST) + set(TDESKTOP_API_ID 17349) + set(TDESKTOP_API_HASH 344583e45741c457fe1862106095a5eb) +endif() + +if (TDESKTOP_API_ID STREQUAL "0" OR TDESKTOP_API_HASH STREQUAL "") + message(FATAL_ERROR + " \n" + " PROVIDE: -D TDESKTOP_API_ID=[API_ID] -D TDESKTOP_API_HASH=[API_HASH]\n" + " \n" + " > To build your version of Telegram Desktop you're required to provide\n" + " > your own 'api_id' and 'api_hash' for the Telegram API access.\n" + " >\n" + " > How to obtain your 'api_id' and 'api_hash' is described here:\n" + " > https://core.telegram.org/api/obtaining_api_id\n" + " >\n" + " > If you're building the application not for deployment,\n" + " > but only for test purposes you can use TEST ONLY credentials,\n" + " > which are very limited by the Telegram API server:\n" + " >\n" + " > api_id: 17349\n" + " > api_hash: 344583e45741c457fe1862106095a5eb\n" + " >\n" + " > Your users will start getting internal server errors on login\n" + " > if you deploy an app using those 'api_id' and 'api_hash'.\n" + " ") +endif() + +if (TDESKTOP_FORCE_GTK_FILE_DIALOG AND TDESKTOP_DISABLE_GTK_INTEGRATION) + message(FATAL_ERROR "Option TDESKTOP_FORCE_GTK_FILE_DIALOG conflicts with option TDESKTOP_DISABLE_GTK_INTEGRATION.") +endif() + +if (DESKTOP_APP_DISABLE_SPELLCHECK) + target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_SPELLCHECK) +else() + target_link_libraries(Telegram PRIVATE lib_spellcheck) +endif() + +if (TDESKTOP_FORCE_GTK_FILE_DIALOG) + target_compile_definitions(Telegram PRIVATE TDESKTOP_FORCE_GTK_FILE_DIALOG) +endif() + +if (TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME) + target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME) +endif() + +if (TDESKTOP_DISABLE_NETWORK_PROXY) + target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_NETWORK_PROXY) +endif() + +if (TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION) + target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION) +endif() + +if (TDESKTOP_DISABLE_GTK_INTEGRATION) + target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_GTK_INTEGRATION) +endif() diff --git a/Telegram/lib_lottie b/Telegram/lib_lottie index 3ef08c5aec..03693ebccb 160000 --- a/Telegram/lib_lottie +++ b/Telegram/lib_lottie @@ -1 +1 @@ -Subproject commit 3ef08c5aec24e544b8fbc6372c9baf56993aa0b0 +Subproject commit 03693ebccbc41af6279e3fcdb1e91ea23f9942b4 diff --git a/Telegram/lib_storage b/Telegram/lib_storage index ffdc9cc7b6..1ed6307b81 160000 --- a/Telegram/lib_storage +++ b/Telegram/lib_storage @@ -1 +1 @@ -Subproject commit ffdc9cc7b64e3d9502ae416cc362f3f2d327b8a8 +Subproject commit 1ed6307b816d368c20848e653e47498292c607c4 diff --git a/cmake b/cmake index 2a87436d39..118ce81dd4 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 2a87436d39b8c0248a2e717b2ef1834329489ccc +Subproject commit 118ce81dd412306900f862be412b419cf243cfa2