Skip to content

Commit

Permalink
Add more options.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 21, 2019
1 parent 7b6fcb4 commit 9e52620
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 33 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# 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
DESCRIPTION "Official Telegram Desktop messenger"
HOMEPAGE_URL "https://desktop.telegram.org"
)

include(cmake/paths.cmake)
include(cmake/options.cmake)
include(cmake/init_target.cmake)
include(cmake/generate_target.cmake)
Expand Down
19 changes: 13 additions & 6 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -60,15 +66,13 @@ 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
lib_base
lib_crl
lib_ui
lib_tl
lib_spellcheck
lib_storage
lib_lottie
lib_rlottie
Expand All @@ -77,7 +81,7 @@ PRIVATE
lib_export
lib_ffmpeg
lib_tgvoip
lib_lz4
external_lz4
external_qt
external_openssl
external_crash_reports
Expand Down Expand Up @@ -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
)
Expand All @@ -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}")
6 changes: 6 additions & 0 deletions Telegram/cmake/generate_lang.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions Telegram/cmake/generate_numbers.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions Telegram/cmake/generate_scheme.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions Telegram/cmake/lib_export.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
6 changes: 6 additions & 0 deletions Telegram/cmake/lib_ffmpeg.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
22 changes: 0 additions & 22 deletions Telegram/cmake/lib_lz4.cmake

This file was deleted.

6 changes: 6 additions & 0 deletions Telegram/cmake/lib_mtproto.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
6 changes: 6 additions & 0 deletions Telegram/cmake/lib_scheme.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
30 changes: 29 additions & 1 deletion Telegram/cmake/lib_tgvoip.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -708,14 +714,36 @@ PRIVATE
WEBRTC_APM_DEBUG_DUMP=0
TGVOIP_USE_DESKTOP_DSP
WEBRTC_NS_FLOAT
WEBRTC_WIN
)

if (WIN32)
target_compile_options(lib_tgvoip
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
Expand Down
72 changes: 72 additions & 0 deletions Telegram/cmake/telegram_options.cmake
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion Telegram/lib_lottie
Submodule lib_lottie updated 1 files
+8 −6 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_storage
Submodule lib_storage updated 1 files
+2 −7 CMakeLists.txt

0 comments on commit 9e52620

Please sign in to comment.