From a18baaae2ca89bbd1b6a4471503d3ee7f2f93df4 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Fri, 8 Nov 2019 14:08:40 +0300
Subject: [PATCH] Add all code generation targets.

---
 CMakeLists.txt                                |   7 +-
 Telegram/CMakeLists.txt                       | 937 +++++++++++++++++-
 Telegram/cmake/generate_lang.cmake            |  20 +
 Telegram/cmake/generate_numbers.cmake         |  20 +
 Telegram/cmake/generate_scheme.cmake          |  22 +
 Telegram/codegen                              |   2 +-
 Telegram/lib_tl                               |   2 +-
 Telegram/lib_ui                               |   2 +-
 cmake/force_include.cmake                     |  13 +
 cmake/generate_target.cmake                   |   8 +
 cmake/init_target.cmake                       |   9 +
 ...ctions.cmake => nice_target_sources.cmake} |  25 +-
 cmake/{constants.cmake => paths.cmake}        |   6 -
 13 files changed, 1018 insertions(+), 55 deletions(-)
 create mode 100644 Telegram/cmake/generate_lang.cmake
 create mode 100644 Telegram/cmake/generate_numbers.cmake
 create mode 100644 Telegram/cmake/generate_scheme.cmake
 create mode 100644 cmake/force_include.cmake
 create mode 100644 cmake/generate_target.cmake
 create mode 100644 cmake/init_target.cmake
 rename cmake/{functions.cmake => nice_target_sources.cmake} (77%)
 rename cmake/{constants.cmake => paths.cmake} (65%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f25f1131..23802db1a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,8 +11,11 @@ project(Telegram
     HOMEPAGE_URL "https://desktop.telegram.org"
 )
 
-include(cmake/constants.cmake)
-include(cmake/functions.cmake)
+include(cmake/paths.cmake)
+include(cmake/force_include.cmake)
+include(cmake/init_target.cmake)
+include(cmake/generate_target.cmake)
+include(cmake/nice_target_sources.cmake)
 
 add_subdirectory(cmake)
 add_subdirectory(Telegram)
diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt
index 3d5dcc931..440c7fec9 100644
--- a/Telegram/CMakeLists.txt
+++ b/Telegram/CMakeLists.txt
@@ -1,33 +1,930 @@
+add_executable(Telegram WIN32 MACOSX_BUNDLE)
+init_target(Telegram)
+
 add_subdirectory(lib_rpl)
 add_subdirectory(lib_crl)
 add_subdirectory(lib_base)
 add_subdirectory(lib_ui)
+add_subdirectory(lib_tl)
 add_subdirectory(codegen)
 
-# include(lib_ui/cmake/generate_styles.cmake)
+include(lib_ui/cmake/generate_styles.cmake)
+include(cmake/generate_scheme.cmake)
+include(cmake/generate_lang.cmake)
+include(cmake/generate_numbers.cmake)
 
-# get_filename_component(src_loc "./SourceFiles" REALPATH)
+get_filename_component(src_loc "./SourceFiles" REALPATH)
+get_filename_component(res_loc "./Resources" REALPATH)
 
-# add_executable(Telegram WIN32 MACOSX_BUNDLE)
-# init_target(Telegram)
+set(style_files
+    boxes/boxes.style
+    calls/calls.style
+    dialogs/dialogs.style
+    export/view/export.style
+    history/history.style
+    info/info.style
+    intro/intro.style
+    media/view/mediaview.style
+    media/player/media_player.style
+    overview/overview.style
+    passport/passport.style
+    profile/profile.style
+    settings/settings.style
+    chat_helpers/chat_helpers.style
+    window/window.style
+)
 
-# force_include(Telegram stdafx.h)
+set(dependent_style_files
+    ${submodules_loc}/lib_ui/ui/colors.palette
+    ${submodules_loc}/lib_ui/ui/basic.style
+    ${submodules_loc}/lib_ui/ui/layers/layers.style
+    ${submodules_loc}/lib_ui/ui/widgets/widgets.style
+)
 
-# set(telegram_sources
-# PRIVATE
-#     main.cpp
-# )
+set(scheme_files
+    ${res_loc}/tl/mtproto.tl
+    ${res_loc}/tl/api.tl
+)
 
-# nice_target_sources(Telegram ${src_loc} "${telegram_sources}")
+generate_scheme(Telegram ${src_loc}/codegen/scheme/codegen_scheme.py "${scheme_files}")
+generate_styles(Telegram ${src_loc} "${style_files}" "${dependent_style_files}")
+generate_lang(Telegram ${res_loc}/langs/lang.strings)
+generate_numbers(Telegram ${res_loc}/numbers.txt)
 
-# target_compile_definitions(Telegram
-# PRIVATE
-#     TDESKTOP_API_ID=17349
-#     TDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb
-# )
+set(telegram_sources
+PRIVATE
+    api/api_common.h
+    api/api_hash.h
+    api/api_sending.cpp
+    api/api_sending.h
+    api/api_single_message_search.cpp
+    api/api_single_message_search.h
+    api/api_text_entities.cpp
+    api/api_text_entities.h
+    boxes/peers/add_participants_box.cpp
+    boxes/peers/add_participants_box.h
+    boxes/peers/edit_contact_box.cpp
+    boxes/peers/edit_contact_box.h
+    boxes/peers/edit_linked_chat_box.cpp
+    boxes/peers/edit_linked_chat_box.h
+    boxes/peers/edit_participant_box.cpp
+    boxes/peers/edit_participant_box.h
+    boxes/peers/edit_participants_box.cpp
+    boxes/peers/edit_participants_box.h
+    boxes/peers/edit_peer_info_box.cpp
+    boxes/peers/edit_peer_info_box.h
+    boxes/peers/edit_peer_type_box.cpp
+    boxes/peers/edit_peer_type_box.h
+    boxes/peers/edit_peer_history_visibility_box.cpp
+    boxes/peers/edit_peer_history_visibility_box.h
+    boxes/peers/edit_peer_permissions_box.cpp
+    boxes/peers/edit_peer_permissions_box.h
+    boxes/about_box.cpp
+    boxes/about_box.h
+    boxes/abstract_box.cpp
+    boxes/abstract_box.h
+    boxes/add_contact_box.cpp
+    boxes/add_contact_box.h
+    boxes/auto_lock_box.cpp
+    boxes/auto_lock_box.h
+    boxes/auto_download_box.cpp
+    boxes/auto_download_box.h
+    boxes/background_box.cpp
+    boxes/background_box.h
+    boxes/background_preview_box.cpp
+    boxes/background_preview_box.h
+    boxes/calendar_box.cpp
+    boxes/calendar_box.h
+    boxes/change_phone_box.cpp
+    boxes/change_phone_box.h
+    boxes/confirm_box.cpp
+    boxes/confirm_box.h
+    boxes/confirm_phone_box.cpp
+    boxes/confirm_phone_box.h
+    boxes/connection_box.cpp
+    boxes/connection_box.h
+    boxes/create_poll_box.cpp
+    boxes/create_poll_box.h
+    boxes/download_path_box.cpp
+    boxes/download_path_box.h
+    boxes/edit_caption_box.cpp
+    boxes/edit_caption_box.h
+    boxes/edit_color_box.cpp
+    boxes/edit_color_box.h
+    boxes/edit_privacy_box.cpp
+    boxes/edit_privacy_box.h
+    boxes/language_box.cpp
+    boxes/language_box.h
+    boxes/local_storage_box.cpp
+    boxes/local_storage_box.h
+    boxes/mute_settings_box.cpp
+    boxes/mute_settings_box.h
+    boxes/peer_list_box.cpp
+    boxes/peer_list_box.h
+    boxes/peer_list_controllers.cpp
+    boxes/peer_list_controllers.h
+    boxes/passcode_box.cpp
+    boxes/passcode_box.h
+    boxes/photo_crop_box.cpp
+    boxes/photo_crop_box.h
+    boxes/rate_call_box.cpp
+    boxes/rate_call_box.h
+    boxes/report_box.cpp
+    boxes/report_box.h
+    boxes/self_destruction_box.cpp
+    boxes/self_destruction_box.h
+    boxes/send_files_box.cpp
+    boxes/send_files_box.h
+    boxes/sessions_box.cpp
+    boxes/sessions_box.h
+    boxes/share_box.cpp
+    boxes/share_box.h
+    boxes/single_choice_box.cpp
+    boxes/single_choice_box.h
+    boxes/sticker_set_box.cpp
+    boxes/sticker_set_box.h
+    boxes/stickers_box.cpp
+    boxes/stickers_box.h
+    boxes/url_auth_box.cpp
+    boxes/url_auth_box.h
+    boxes/username_box.cpp
+    boxes/username_box.h
+    calls/calls_box_controller.cpp
+    calls/calls_box_controller.h
+    calls/calls_call.cpp
+    calls/calls_call.h
+    calls/calls_emoji_fingerprint.cpp
+    calls/calls_emoji_fingerprint.h
+    calls/calls_instance.cpp
+    calls/calls_instance.h
+    calls/calls_panel.cpp
+    calls/calls_panel.h
+    calls/calls_top_bar.cpp
+    calls/calls_top_bar.h
+    chat_helpers/bot_keyboard.cpp
+    chat_helpers/bot_keyboard.h
+    chat_helpers/emoji_keywords.cpp
+    chat_helpers/emoji_keywords.h
+    chat_helpers/emoji_list_widget.cpp
+    chat_helpers/emoji_list_widget.h
+    chat_helpers/emoji_sets_manager.cpp
+    chat_helpers/emoji_sets_manager.h
+    chat_helpers/emoji_suggestions_widget.cpp
+    chat_helpers/emoji_suggestions_widget.h
+    chat_helpers/field_autocomplete.cpp
+    chat_helpers/field_autocomplete.h
+    chat_helpers/gifs_list_widget.cpp
+    chat_helpers/gifs_list_widget.h
+    chat_helpers/message_field.cpp
+    chat_helpers/message_field.h
+    chat_helpers/stickers.cpp
+    chat_helpers/stickers.h
+    chat_helpers/stickers_emoji_pack.cpp
+    chat_helpers/stickers_emoji_pack.h
+    chat_helpers/stickers_list_widget.cpp
+    chat_helpers/stickers_list_widget.h
+    chat_helpers/tabbed_panel.cpp
+    chat_helpers/tabbed_panel.h
+    chat_helpers/tabbed_section.cpp
+    chat_helpers/tabbed_section.h
+    chat_helpers/tabbed_selector.cpp
+    chat_helpers/tabbed_selector.h
+    core/application.cpp
+    core/application.h
+    core/base_integration.cpp
+    core/base_integration.h
+    core/changelogs.cpp
+    core/changelogs.h
+    core/click_handler_types.cpp
+    core/click_handler_types.h
+    core/core_cloud_password.cpp
+    core/core_cloud_password.h
+    core/core_settings.cpp
+    core/core_settings.h
+    core/crash_report_window.cpp
+    core/crash_report_window.h
+    core/crash_reports.cpp
+    core/crash_reports.h
+    core/file_utilities.cpp
+    core/file_utilities.h
+    core/launcher.cpp
+    core/launcher.h
+    core/local_url_handlers.cpp
+    core/local_url_handlers.h
+    core/media_active_cache.h
+    core/mime_type.cpp
+    core/mime_type.h
+    core/sandbox.cpp
+    core/sandbox.h
+    core/shortcuts.cpp
+    core/shortcuts.h
+    core/ui_integration.cpp
+    core/ui_integration.h
+    core/update_checker.cpp
+    core/update_checker.h
+    core/utils.cpp
+    core/utils.h
+    core/version.h
+    data/data_abstract_structure.cpp
+    data/data_abstract_structure.h
+    data/data_auto_download.cpp
+    data/data_auto_download.h
+    data/data_chat.cpp
+    data/data_chat.h
+    data/data_channel.cpp
+    data/data_channel.h
+    data/data_channel_admins.cpp
+    data/data_channel_admins.h
+    data/data_cloud_themes.cpp
+    data/data_cloud_themes.h
+    data/data_countries.cpp
+    data/data_countries.h
+    data/data_document.cpp
+    data/data_document.h
+    data/data_document_good_thumbnail.cpp
+    data/data_document_good_thumbnail.h
+    data/data_drafts.cpp
+    data/data_drafts.h
+    data/data_folder.cpp
+    data/data_folder.h
+    # data/data_feed_messages.cpp
+    # data/data_feed_messages.h
+    data/data_file_origin.cpp
+    data/data_file_origin.h
+    data/data_flags.h
+    data/data_game.h
+    data/data_groups.cpp
+    data/data_groups.h
+    data/data_location.cpp
+    data/data_location.h
+    data/data_media_types.cpp
+    data/data_media_types.h
+    data/data_messages.cpp
+    data/data_messages.h
+    data/data_notify_settings.cpp
+    data/data_notify_settings.h
+    data/data_peer.cpp
+    data/data_peer.h
+    data/data_peer_values.cpp
+    data/data_peer_values.h
+    data/data_photo.cpp
+    data/data_photo.h
+    data/data_poll.cpp
+    data/data_poll.h
+    data/data_pts_waiter.cpp
+    data/data_pts_waiter.h
+    data/data_search_controller.cpp
+    data/data_search_controller.h
+    data/data_session.cpp
+    data/data_session.h
+    data/data_scheduled_messages.cpp
+    data/data_scheduled_messages.h
+    data/data_shared_media.cpp
+    data/data_shared_media.h
+    data/data_sparse_ids.cpp
+    data/data_sparse_ids.h
+    data/data_types.cpp
+    data/data_types.h
+    data/data_user.cpp
+    data/data_user.h
+    data/data_user_photos.cpp
+    data/data_user_photos.h
+    data/data_wall_paper.cpp
+    data/data_wall_paper.h
+    data/data_web_page.cpp
+    data/data_web_page.h
+    dialogs/dialogs_entry.cpp
+    dialogs/dialogs_entry.h
+    dialogs/dialogs_indexed_list.cpp
+    dialogs/dialogs_indexed_list.h
+    dialogs/dialogs_inner_widget.cpp
+    dialogs/dialogs_inner_widget.h
+    dialogs/dialogs_key.cpp
+    dialogs/dialogs_key.h
+    dialogs/dialogs_layout.cpp
+    dialogs/dialogs_layout.h
+    dialogs/dialogs_list.cpp
+    dialogs/dialogs_list.h
+    dialogs/dialogs_main_list.cpp
+    dialogs/dialogs_main_list.h
+    dialogs/dialogs_pinned_list.cpp
+    dialogs/dialogs_pinned_list.h
+    dialogs/dialogs_row.cpp
+    dialogs/dialogs_row.h
+    dialogs/dialogs_search_from_controllers.cpp
+    dialogs/dialogs_search_from_controllers.h
+    dialogs/dialogs_widget.cpp
+    dialogs/dialogs_widget.h
+    export/view/export_view_content.cpp
+    export/view/export_view_content.h
+    export/view/export_view_panel_controller.cpp
+    export/view/export_view_panel_controller.h
+    export/view/export_view_progress.cpp
+    export/view/export_view_progress.h
+    export/view/export_view_settings.cpp
+    export/view/export_view_settings.h
+    export/view/export_view_top_bar.cpp
+    export/view/export_view_top_bar.h
+    history/admin_log/history_admin_log_filter.cpp
+    history/admin_log/history_admin_log_filter.h
+    history/admin_log/history_admin_log_inner.cpp
+    history/admin_log/history_admin_log_inner.h
+    history/admin_log/history_admin_log_item.cpp
+    history/admin_log/history_admin_log_item.h
+    history/admin_log/history_admin_log_section.cpp
+    history/admin_log/history_admin_log_section.h
+    # history/feed/history_feed_section.cpp
+    # history/feed/history_feed_section.h
+    history/view/media/history_view_call.h
+    history/view/media/history_view_call.cpp
+    history/view/media/history_view_contact.h
+    history/view/media/history_view_contact.cpp
+    history/view/media/history_view_document.h
+    history/view/media/history_view_document.cpp
+    history/view/media/history_view_file.h
+    history/view/media/history_view_file.cpp
+    history/view/media/history_view_game.h
+    history/view/media/history_view_game.cpp
+    history/view/media/history_view_gif.h
+    history/view/media/history_view_gif.cpp
+    history/view/media/history_view_invoice.h
+    history/view/media/history_view_invoice.cpp
+    history/view/media/history_view_large_emoji.h
+    history/view/media/history_view_large_emoji.cpp
+    history/view/media/history_view_location.h
+    history/view/media/history_view_location.cpp
+    history/view/media/history_view_media.h
+    history/view/media/history_view_media.cpp
+    history/view/media/history_view_media_common.h
+    history/view/media/history_view_media_common.cpp
+    history/view/media/history_view_media_grouped.h
+    history/view/media/history_view_media_grouped.cpp
+    history/view/media/history_view_media_unwrapped.h
+    history/view/media/history_view_media_unwrapped.cpp
+    history/view/media/history_view_photo.h
+    history/view/media/history_view_photo.cpp
+    history/view/media/history_view_poll.h
+    history/view/media/history_view_poll.cpp
+    history/view/media/history_view_sticker.h
+    history/view/media/history_view_sticker.cpp
+    history/view/media/history_view_theme_document.h
+    history/view/media/history_view_theme_document.cpp
+    history/view/media/history_view_video.h
+    history/view/media/history_view_video.cpp
+    history/view/media/history_view_web_page.h
+    history/view/media/history_view_web_page.cpp
+    history/view/history_view_compose_controls.cpp
+    history/view/history_view_compose_controls.h
+    history/view/history_view_contact_status.cpp
+    history/view/history_view_contact_status.h
+    history/view/history_view_context_menu.cpp
+    history/view/history_view_context_menu.h
+    history/view/history_view_cursor_state.cpp
+    history/view/history_view_cursor_state.h
+    history/view/history_view_element.cpp
+    history/view/history_view_element.h
+    history/view/history_view_list_widget.cpp
+    history/view/history_view_list_widget.h
+    history/view/history_view_message.cpp
+    history/view/history_view_message.h
+    history/view/history_view_object.h
+    history/view/history_view_schedule_box.cpp
+    history/view/history_view_schedule_box.h
+    history/view/history_view_scheduled_section.cpp
+    history/view/history_view_scheduled_section.h
+    history/view/history_view_service_message.cpp
+    history/view/history_view_service_message.h
+    history/view/history_view_top_bar_widget.cpp
+    history/view/history_view_top_bar_widget.h
+    history/history.cpp
+    history/history.h
+    history/history_drag_area.cpp
+    history/history_drag_area.h
+    history/history_item.cpp
+    history/history_item.h
+    history/history_item_components.cpp
+    history/history_item_components.h
+    history/history_item_text.cpp
+    history/history_item_text.h
+    history/history_inner_widget.cpp
+    history/history_inner_widget.h
+    history/history_location_manager.cpp
+    history/history_location_manager.h
+    history/history_message.cpp
+    history/history_message.h
+    history/history_service.cpp
+    history/history_service.h
+    history/history_widget.cpp
+    history/history_widget.h
+    info/info_content_widget.cpp
+    info/info_content_widget.h
+    info/info_controller.cpp
+    info/info_controller.h
+    info/info_layer_widget.cpp
+    info/info_layer_widget.h
+    info/info_memento.cpp
+    info/info_memento.h
+    info/info_section_widget.cpp
+    info/info_section_widget.h
+    info/info_top_bar.cpp
+    info/info_top_bar.h
+    info/info_wrap_widget.cpp
+    info/info_wrap_widget.h
+    # info/channels/info_channels_widget.cpp
+    # info/channels/info_channels_widget.h
+    info/common_groups/info_common_groups_inner_widget.cpp
+    info/common_groups/info_common_groups_inner_widget.h
+    info/common_groups/info_common_groups_widget.cpp
+    info/common_groups/info_common_groups_widget.h
+    # info/feed/info_feed_channels.cpp
+    # info/feed/info_feed_channels.h
+    # info/feed/info_feed_channels_controllers.cpp
+    # info/feed/info_feed_channels_controllers.h
+    # info/feed/info_feed_cover.cpp
+    # info/feed/info_feed_cover.h
+    # info/feed/info_feed_profile_inner_widget.cpp
+    # info/feed/info_feed_profile_inner_widget.h
+    # info/feed/info_feed_profile_widget.cpp
+    # info/feed/info_feed_profile_widget.h
+    info/media/info_media_buttons.h
+    info/media/info_media_empty_widget.cpp
+    info/media/info_media_empty_widget.h
+    info/media/info_media_inner_widget.cpp
+    info/media/info_media_inner_widget.h
+    info/media/info_media_list_widget.cpp
+    info/media/info_media_list_widget.h
+    info/media/info_media_widget.cpp
+    info/media/info_media_widget.h
+    info/members/info_members_widget.cpp
+    info/members/info_members_widget.h
+    info/profile/info_profile_actions.cpp
+    info/profile/info_profile_actions.h
+    info/profile/info_profile_cover.cpp
+    info/profile/info_profile_cover.h
+    info/profile/info_profile_icon.cpp
+    info/profile/info_profile_icon.h
+    info/profile/info_profile_inner_widget.cpp
+    info/profile/info_profile_inner_widget.h
+    info/profile/info_profile_members.cpp
+    info/profile/info_profile_members.h
+    info/profile/info_profile_members_controllers.cpp
+    info/profile/info_profile_members_controllers.h
+    info/profile/info_profile_text.cpp
+    info/profile/info_profile_text.h
+    info/profile/info_profile_values.cpp
+    info/profile/info_profile_values.h
+    info/profile/info_profile_widget.cpp
+    info/profile/info_profile_widget.h
+    info/settings/info_settings_widget.cpp
+    info/settings/info_settings_widget.h
+    inline_bots/inline_bot_layout_internal.cpp
+    inline_bots/inline_bot_layout_internal.h
+    inline_bots/inline_bot_layout_item.cpp
+    inline_bots/inline_bot_layout_item.h
+    inline_bots/inline_bot_result.cpp
+    inline_bots/inline_bot_result.h
+    inline_bots/inline_bot_send_data.cpp
+    inline_bots/inline_bot_send_data.h
+    inline_bots/inline_results_widget.cpp
+    inline_bots/inline_results_widget.h
+    intro/introwidget.cpp
+    intro/introwidget.h
+    intro/introcode.cpp
+    intro/introcode.h
+    intro/introphone.cpp
+    intro/introphone.h
+    intro/intropwdcheck.cpp
+    intro/intropwdcheck.h
+    intro/introsignup.cpp
+    intro/introsignup.h
+    intro/introstart.cpp
+    intro/introstart.h
+    lang/lang_cloud_manager.cpp
+    lang/lang_cloud_manager.h
+    lang/lang_file_parser.cpp
+    lang/lang_file_parser.h
+    lang/lang_hardcoded.h
+    lang/lang_instance.cpp
+    lang/lang_instance.h
+    lang/lang_keys.cpp
+    lang/lang_keys.h
+    lang/lang_numbers_animation.cpp
+    lang/lang_numbers_animation.h
+    lang/lang_tag.cpp
+    lang/lang_tag.h
+    lang/lang_text_entity.cpp
+    lang/lang_text_entity.h
+    lang/lang_translator.cpp
+    lang/lang_translator.h
+    lang/lang_values.cpp
+    lang/lang_values.h
+    main/main_account.cpp
+    main/main_account.h
+    main/main_app_config.cpp
+    main/main_app_config.h
+    main/main_session.cpp
+    main/main_session.h
+    main/main_settings.cpp
+    main/main_settings.h
+    media/audio/media_audio.cpp
+    media/audio/media_audio.h
+    media/audio/media_audio_capture.cpp
+    media/audio/media_audio_capture.h
+    media/audio/media_audio_ffmpeg_loader.cpp
+    media/audio/media_audio_ffmpeg_loader.h
+    media/audio/media_audio_loader.cpp
+    media/audio/media_audio_loader.h
+    media/audio/media_audio_loaders.cpp
+    media/audio/media_audio_loaders.h
+    media/audio/media_audio_track.cpp
+    media/audio/media_audio_track.h
+    media/audio/media_child_ffmpeg_loader.cpp
+    media/audio/media_child_ffmpeg_loader.h
+    media/clip/media_clip_check_streaming.cpp
+    media/clip/media_clip_check_streaming.h
+    media/clip/media_clip_ffmpeg.cpp
+    media/clip/media_clip_ffmpeg.h
+    media/clip/media_clip_implementation.cpp
+    media/clip/media_clip_implementation.h
+    media/clip/media_clip_reader.cpp
+    media/clip/media_clip_reader.h
+    media/player/media_player_button.cpp
+    media/player/media_player_button.h
+    media/player/media_player_float.cpp
+    media/player/media_player_float.h
+    media/player/media_player_instance.cpp
+    media/player/media_player_instance.h
+    media/player/media_player_panel.cpp
+    media/player/media_player_panel.h
+    media/player/media_player_volume_controller.cpp
+    media/player/media_player_volume_controller.h
+    media/player/media_player_widget.cpp
+    media/player/media_player_widget.h
+    media/streaming/media_streaming_audio_track.cpp
+    media/streaming/media_streaming_audio_track.h
+    media/streaming/media_streaming_common.h
+    media/streaming/media_streaming_file.cpp
+    media/streaming/media_streaming_file.h
+    media/streaming/media_streaming_file_delegate.h
+    media/streaming/media_streaming_loader.cpp
+    media/streaming/media_streaming_loader.h
+    media/streaming/media_streaming_loader_local.cpp
+    media/streaming/media_streaming_loader_local.h
+    media/streaming/media_streaming_loader_mtproto.cpp
+    media/streaming/media_streaming_loader_mtproto.h
+    media/streaming/media_streaming_player.cpp
+    media/streaming/media_streaming_player.h
+    media/streaming/media_streaming_reader.cpp
+    media/streaming/media_streaming_reader.h
+    media/streaming/media_streaming_utility.cpp
+    media/streaming/media_streaming_utility.h
+    media/streaming/media_streaming_video_track.cpp
+    media/streaming/media_streaming_video_track.h
+    media/view/media_view_playback_controls.cpp
+    media/view/media_view_playback_controls.h
+    media/view/media_view_playback_progress.cpp
+    media/view/media_view_playback_progress.h
+    media/view/media_view_group_thumbs.cpp
+    media/view/media_view_group_thumbs.h
+    media/view/media_view_overlay_widget.cpp
+    media/view/media_view_overlay_widget.h
+    mtproto/auth_key.cpp
+    mtproto/auth_key.h
+    mtproto/concurrent_sender.cpp
+    mtproto/concurrent_sender.h
+    mtproto/config_loader.cpp
+    mtproto/config_loader.h
+    mtproto/connection.cpp
+    mtproto/connection.h
+    mtproto/connection_abstract.cpp
+    mtproto/connection_abstract.h
+    mtproto/connection_http.cpp
+    mtproto/connection_http.h
+    mtproto/connection_resolving.cpp
+    mtproto/connection_resolving.h
+    mtproto/connection_tcp.cpp
+    mtproto/connection_tcp.h
+    mtproto/core_types.cpp
+    mtproto/core_types.h
+    mtproto/dcenter.cpp
+    mtproto/dcenter.h
+    mtproto/dc_options.cpp
+    mtproto/dc_options.h
+    mtproto/dedicated_file_loader.cpp
+    mtproto/dedicated_file_loader.h
+    mtproto/facade.cpp
+    mtproto/facade.h
+    mtproto/mtp_instance.cpp
+    mtproto/mtp_instance.h
+    mtproto/rsa_public_key.cpp
+    mtproto/rsa_public_key.h
+    mtproto/rpc_sender.cpp
+    mtproto/rpc_sender.h
+    mtproto/sender.h
+    mtproto/session.cpp
+    mtproto/session.h
+    mtproto/special_config_request.cpp
+    mtproto/special_config_request.h
+    mtproto/type_utils.h
+    overview/overview_layout.cpp
+    overview/overview_layout.h
+    passport/passport_encryption.cpp
+    passport/passport_encryption.h
+    passport/passport_form_controller.cpp
+    passport/passport_form_controller.h
+    passport/passport_form_view_controller.cpp
+    passport/passport_form_view_controller.h
+    passport/passport_panel.cpp
+    passport/passport_panel.h
+    passport/passport_panel_controller.cpp
+    passport/passport_panel_controller.h
+    passport/passport_panel_details_row.cpp
+    passport/passport_panel_details_row.h
+    passport/passport_panel_edit_contact.cpp
+    passport/passport_panel_edit_contact.h
+    passport/passport_panel_edit_document.cpp
+    passport/passport_panel_edit_document.h
+    passport/passport_panel_edit_scans.cpp
+    passport/passport_panel_edit_scans.h
+    passport/passport_panel_form.cpp
+    passport/passport_panel_form.h
+    passport/passport_panel_password.cpp
+    passport/passport_panel_password.h
+    platform/linux/linux_desktop_environment.cpp
+    platform/linux/linux_desktop_environment.h
+    platform/linux/linux_gdk_helper.cpp
+    platform/linux/linux_gdk_helper.h
+    platform/linux/linux_libnotify.cpp
+    platform/linux/linux_libnotify.h
+    platform/linux/linux_libs.cpp
+    platform/linux/linux_libs.h
+    platform/linux/file_utilities_linux.cpp
+    platform/linux/file_utilities_linux.h
+    platform/linux/launcher_linux.cpp
+    platform/linux/launcher_linux.h
+    platform/linux/main_window_linux.cpp
+    platform/linux/main_window_linux.h
+    platform/linux/notifications_manager_linux.cpp
+    platform/linux/notifications_manager_linux.h
+    platform/linux/specific_linux.cpp
+    platform/linux/specific_linux.h
+    platform/mac/file_utilities_mac.mm
+    platform/mac/file_utilities_mac.h
+    platform/mac/launcher_mac.mm
+    platform/mac/launcher_mac.h
+    platform/mac/mac_iconv_helper.c
+    platform/mac/main_window_mac.mm
+    platform/mac/main_window_mac.h
+    platform/mac/notifications_manager_mac.mm
+    platform/mac/notifications_manager_mac.h
+    platform/mac/specific_mac.mm
+    platform/mac/specific_mac.h
+    platform/mac/specific_mac_p.mm
+    platform/mac/specific_mac_p.h
+    platform/mac/window_title_mac.mm
+    platform/mac/window_title_mac.h
+    platform/mac/mac_touchbar.h
+    platform/mac/mac_touchbar.mm
+    platform/win/audio_win.cpp
+    platform/win/audio_win.h
+    platform/win/file_utilities_win.cpp
+    platform/win/file_utilities_win.h
+    platform/win/launcher_win.cpp
+    platform/win/launcher_win.h
+    platform/win/main_window_win.cpp
+    platform/win/main_window_win.h
+    platform/win/notifications_manager_win.cpp
+    platform/win/notifications_manager_win.h
+    platform/win/specific_win.cpp
+    platform/win/specific_win.h
+    platform/win/window_title_win.cpp
+    platform/win/window_title_win.h
+    platform/win/windows_app_user_model_id.cpp
+    platform/win/windows_app_user_model_id.h
+    platform/win/windows_dlls.cpp
+    platform/win/windows_dlls.h
+    platform/win/windows_event_filter.cpp
+    platform/win/windows_event_filter.h
+    platform/win/wrapper_wrl_implements_h.h
+    platform/platform_audio.h
+    platform/platform_file_utilities.h
+    platform/platform_launcher.h
+    platform/platform_main_window.h
+    platform/platform_notifications_manager.h
+    platform/platform_specific.h
+    platform/platform_window_title.h
+    profile/profile_back_button.cpp
+    profile/profile_back_button.h
+    profile/profile_block_group_members.cpp
+    profile/profile_block_group_members.h
+    profile/profile_block_peer_list.cpp
+    profile/profile_block_peer_list.h
+    profile/profile_block_widget.cpp
+    profile/profile_block_widget.h
+    profile/profile_cover_drop_area.cpp
+    profile/profile_cover_drop_area.h
+    settings/settings_advanced.cpp
+    settings/settings_advanced.h
+    settings/settings_chat.cpp
+    settings/settings_chat.h
+    settings/settings_calls.cpp
+    settings/settings_calls.h
+    settings/settings_codes.cpp
+    settings/settings_codes.h
+    settings/settings_common.cpp
+    settings/settings_common.h
+    settings/settings_information.cpp
+    settings/settings_information.h
+    settings/settings_intro.cpp
+    settings/settings_intro.h
+    settings/settings_main.cpp
+    settings/settings_main.h
+    settings/settings_notifications.cpp
+    settings/settings_notifications.h
+    settings/settings_privacy_controllers.cpp
+    settings/settings_privacy_controllers.h
+    settings/settings_privacy_security.cpp
+    settings/settings_privacy_security.h
+    storage/file_download.cpp
+    storage/file_download.h
+    storage/file_upload.cpp
+    storage/file_upload.h
+    storage/localimageloader.cpp
+    storage/localimageloader.h
+    storage/localstorage.cpp
+    storage/localstorage.h
+    storage/serialize_common.cpp
+    storage/serialize_common.h
+    storage/serialize_document.cpp
+    storage/serialize_document.h
+    storage/storage_facade.cpp
+    storage/storage_facade.h
+    # storage/storage_feed_messages.cpp
+    # storage/storage_feed_messages.h
+    storage/storage_media_prepare.cpp
+    storage/storage_media_prepare.h
+    storage/storage_shared_media.cpp
+    storage/storage_shared_media.h
+    storage/storage_sparse_ids_list.cpp
+    storage/storage_sparse_ids_list.h
+    storage/storage_user_photos.cpp
+    storage/storage_user_photos.h
+    storage/streamed_file_downloader.cpp
+    storage/streamed_file_downloader.h
+    support/support_autocomplete.cpp
+    support/support_autocomplete.h
+    support/support_common.cpp
+    support/support_common.h
+    support/support_helper.cpp
+    support/support_helper.h
+    support/support_templates.cpp
+    support/support_templates.h
+    ui/effects/round_checkbox.cpp
+    ui/effects/round_checkbox.h
+    ui/effects/send_action_animations.cpp
+    ui/effects/send_action_animations.h
+    ui/image/image.cpp
+    ui/image/image.h
+    ui/image/image_location.cpp
+    ui/image/image_location.h
+    ui/image/image_source.cpp
+    ui/image/image_source.h
+    ui/widgets/continuous_sliders.cpp
+    ui/widgets/continuous_sliders.h
+    ui/widgets/discrete_sliders.cpp
+    ui/widgets/discrete_sliders.h
+    ui/widgets/level_meter.cpp
+    ui/widgets/level_meter.h
+    ui/widgets/multi_select.cpp
+    ui/widgets/multi_select.h
+    ui/widgets/separate_panel.cpp
+    ui/widgets/separate_panel.h
+    ui/countryinput.cpp
+    ui/countryinput.h
+    ui/empty_userpic.cpp
+    ui/empty_userpic.h
+    ui/grouped_layout.cpp
+    ui/grouped_layout.h
+    ui/resize_area.h
+    ui/search_field_controller.cpp
+    ui/search_field_controller.h
+    ui/special_buttons.cpp
+    ui/special_buttons.h
+    ui/special_fields.cpp
+    ui/special_fields.h
+    ui/text_options.cpp
+    ui/text_options.h
+    ui/unread_badge.cpp
+    ui/unread_badge.h
+    window/main_window.cpp
+    window/main_window.h
+    window/notifications_manager.cpp
+    window/notifications_manager.h
+    window/notifications_manager_default.cpp
+    window/notifications_manager_default.h
+    window/notifications_utilities.cpp
+    window/notifications_utilities.h
+    window/section_memento.h
+    window/section_widget.cpp
+    window/section_widget.h
+    window/window_connecting_widget.cpp
+    window/window_connecting_widget.h
+    window/window_controller.cpp
+    window/window_controller.h
+    window/window_history_hider.cpp
+    window/window_history_hider.h
+    window/window_lock_widgets.cpp
+    window/window_lock_widgets.h
+    window/window_main_menu.cpp
+    window/window_main_menu.h
+    window/window_media_preview.cpp
+    window/window_media_preview.h
+    window/window_outdated_bar.cpp
+    window/window_outdated_bar.h
+    window/window_peer_menu.cpp
+    window/window_peer_menu.h
+    window/window_session_controller.cpp
+    window/window_session_controller.h
+    window/window_slide_animation.cpp
+    window/window_slide_animation.h
+    window/window_title.h
+    window/window_top_bar_wrap.h
+    window/themes/window_theme.cpp
+    window/themes/window_theme.h
+    window/themes/window_theme_editor.cpp
+    window/themes/window_theme_editor.h
+    window/themes/window_theme_editor_block.cpp
+    window/themes/window_theme_editor_block.h
+    window/themes/window_theme_editor_box.cpp
+    window/themes/window_theme_editor_box.h
+    window/themes/window_theme_preview.cpp
+    window/themes/window_theme_preview.h
+    window/themes/window_theme_warning.cpp
+    window/themes/window_theme_warning.h
+    window/themes/window_themes_cloud_list.cpp
+    window/themes/window_themes_cloud_list.h
+    window/themes/window_themes_embedded.cpp
+    window/themes/window_themes_embedded.h
+    window/themes/window_themes_generate_name.cpp
+    window/themes/window_themes_generate_name.h
+    apiwrap.cpp
+    apiwrap.h
+    app.cpp
+    app.h
+    config.h
+    facades.cpp
+    facades.h
+    layout.cpp
+    layout.h
+    logs.cpp
+    logs.h
+    main.cpp
+    mainwidget.cpp
+    mainwidget.h
+    mainwindow.cpp
+    mainwindow.h
+    observer_peer.cpp
+    observer_peer.h
+    qt_static_plugins.cpp
+    settings.cpp
+    settings.h
 
-# target_link_libraries(Telegram
-# PRIVATE
-#     lib_base
-#     lib_ui
-# )
+# platforms: !win
+# <(minizip_loc)/crypt.h
+# <(minizip_loc)/ioapi.c
+# <(minizip_loc)/ioapi.h
+# <(minizip_loc)/zip.c
+# <(minizip_loc)/zip.h
+# <(minizip_loc)/unzip.c
+# <(minizip_loc)/unzip.h
+
+# platforms: win
+# <(res_loc)/winrc/Telegram.rc
+
+# platforms: mac
+# <(sp_media_key_tap_loc)/SPMediaKeyTap.m
+# <(sp_media_key_tap_loc)/SPMediaKeyTap.h
+# <(sp_media_key_tap_loc)/SPInvocationGrabbing/NSObject+SPInvocationGrabbing.m
+# <(sp_media_key_tap_loc)/SPInvocationGrabbing/NSObject+SPInvocationGrabbing.h
+)
+nice_target_sources(Telegram ${src_loc} "${telegram_sources}")
+
+force_include(Telegram stdafx.h)
+
+target_include_directories(Telegram
+PRIVATE
+    ${src_loc}
+)
+
+target_compile_definitions(Telegram
+PRIVATE
+    TDESKTOP_API_ID=17349
+    TDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb
+)
+
+target_link_libraries(Telegram
+PRIVATE
+    lib_base
+    lib_ui
+    lib_tl
+)
diff --git a/Telegram/cmake/generate_lang.cmake b/Telegram/cmake/generate_lang.cmake
new file mode 100644
index 000000000..d93516b38
--- /dev/null
+++ b/Telegram/cmake/generate_lang.cmake
@@ -0,0 +1,20 @@
+function(generate_lang target_name lang_file)
+    set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
+    set(generated_files
+        ${gen_dst}/lang_auto.cpp
+        ${gen_dst}/lang_auto.h
+    )
+    add_custom_command(
+    OUTPUT
+        ${generated_files}
+    COMMAND
+        codegen_lang
+        -o${gen_dst}
+        ${lang_file}
+    COMMENT "Generating lang (${target_name})"
+    DEPENDS
+        codegen_lang
+        ${lang_file}
+    )
+    generate_target(${target_name} lang "${generated_files}" ${gen_dst})
+endfunction()
diff --git a/Telegram/cmake/generate_numbers.cmake b/Telegram/cmake/generate_numbers.cmake
new file mode 100644
index 000000000..0e5a0eb10
--- /dev/null
+++ b/Telegram/cmake/generate_numbers.cmake
@@ -0,0 +1,20 @@
+function(generate_numbers target_name numbers_file)
+    set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
+    set(generated_files
+        ${gen_dst}/numbers.cpp
+        ${gen_dst}/numbers.h
+    )
+    add_custom_command(
+    OUTPUT
+        ${generated_files}
+    COMMAND
+        codegen_numbers
+        -o${gen_dst}
+        ${numbers_file}
+    COMMENT "Generating numbers (${target_name})"
+    DEPENDS
+        codegen_numbers
+        ${gen_src}
+    )
+    generate_target(${target_name} numbers "${generated_files}" ${gen_dst})
+endfunction()
diff --git a/Telegram/cmake/generate_scheme.cmake b/Telegram/cmake/generate_scheme.cmake
new file mode 100644
index 000000000..6cb2513f1
--- /dev/null
+++ b/Telegram/cmake/generate_scheme.cmake
@@ -0,0 +1,22 @@
+function(generate_scheme target_name script scheme_files)
+    set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
+    set(generated_files
+        ${gen_dst}/scheme.cpp
+        ${gen_dst}/scheme.h
+    )
+    add_custom_command(
+    OUTPUT
+        ${generated_files}
+    COMMAND
+        python
+        ${script}
+        -o${gen_dst}/scheme
+        ${scheme_files}
+    COMMENT "Generating scheme (${target_name})"
+    DEPENDS
+        ${script}
+        ${submodules_loc}/lib_tl/tl/generate_tl.py
+        ${scheme_files}
+    )
+    generate_target(${target_name} scheme "${generated_files}" ${gen_dst})
+endfunction()
diff --git a/Telegram/codegen b/Telegram/codegen
index 2f972846a..8e8d1de1a 160000
--- a/Telegram/codegen
+++ b/Telegram/codegen
@@ -1 +1 @@
-Subproject commit 2f972846ad4beb64f068dac236ab95b04aa343a9
+Subproject commit 8e8d1de1a1ad5fbc9db0ec797880b5c754be8be7
diff --git a/Telegram/lib_tl b/Telegram/lib_tl
index 89a1e3fed..54f5073dc 160000
--- a/Telegram/lib_tl
+++ b/Telegram/lib_tl
@@ -1 +1 @@
-Subproject commit 89a1e3fed24bc0bfc268fa0352e7d2658ee4ef22
+Subproject commit 54f5073dc49b518f75e57352fde5df47973791d5
diff --git a/Telegram/lib_ui b/Telegram/lib_ui
index ab76dcd08..d32f772e5 160000
--- a/Telegram/lib_ui
+++ b/Telegram/lib_ui
@@ -1 +1 @@
-Subproject commit ab76dcd0879e684b34c3de243e44e3751b68356f
+Subproject commit d32f772e5274e8490ade20e88c6bfa10b8ecfee5
diff --git a/cmake/force_include.cmake b/cmake/force_include.cmake
new file mode 100644
index 000000000..5e684c194
--- /dev/null
+++ b/cmake/force_include.cmake
@@ -0,0 +1,13 @@
+function(force_include target_name file_path)
+    if (MSVC)
+        target_compile_options(${target_name}
+        PRIVATE
+            /FI${file_path}
+        )
+    else()
+        target_compile_options(${target_name}
+        PRIVATE
+            -include ${file_path}
+        )
+    endif()
+endfunction()
diff --git a/cmake/generate_target.cmake b/cmake/generate_target.cmake
new file mode 100644
index 000000000..e4e07aec7
--- /dev/null
+++ b/cmake/generate_target.cmake
@@ -0,0 +1,8 @@
+function(generate_target parent_name postfix generated_files gen_dst)
+    add_custom_target(${parent_name}_${postfix} DEPENDS ${generated_files})
+    init_target(${parent_name}_${postfix} "(gen)")
+    add_dependencies(${parent_name} ${parent_name}_${postfix})
+    target_sources(${parent_name} PRIVATE ${generated_files})
+    target_include_directories(${parent_name} PUBLIC ${gen_dst})
+    source_group("(gen)" FILES ${generated_files})
+endfunction()
diff --git a/cmake/init_target.cmake b/cmake/init_target.cmake
new file mode 100644
index 000000000..539371b79
--- /dev/null
+++ b/cmake/init_target.cmake
@@ -0,0 +1,9 @@
+function(init_target target_name) # init_target(my_target folder_name)
+    set(folder_name "${ARGV1}")
+    set_property(TARGET ${target_name} PROPERTY
+        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+    if (NOT "${folder_name}" STREQUAL "")
+        set_target_properties(${target_name} PROPERTIES FOLDER ${folder_name})
+    endif()
+endfunction()
+
diff --git a/cmake/functions.cmake b/cmake/nice_target_sources.cmake
similarity index 77%
rename from cmake/functions.cmake
rename to cmake/nice_target_sources.cmake
index 7ee1f985d..afacbfdd3 100644
--- a/cmake/functions.cmake
+++ b/cmake/nice_target_sources.cmake
@@ -1,26 +1,3 @@
-function(force_include target_name file_path)
-if (MSVC)
-    target_compile_options(${target_name}
-    PRIVATE
-        /FI${file_path}
-    )
-else()
-    target_compile_options(${target_name}
-    PRIVATE
-        -include ${file_path}
-    )
-endif()
-endfunction()
-
-function(init_target target_name) # init_target(my_target folder_name)
-    set(folder_name "${ARGV1}")
-    set_property(TARGET ${target_name} PROPERTY
-        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
-    if (NOT "${folder_name}" STREQUAL "")
-        set_target_properties(${target_name} PROPERTIES FOLDER ${folder_name})
-    endif()
-endfunction()
-
 function(nice_target_sources target_name src_loc list)
     set(writing_now "")
     set(private_sources "")
@@ -55,7 +32,7 @@ function(nice_target_sources target_name src_loc list)
             else()
                 message(FATAL_ERROR "Unknown sources scope for target ${target_name}")
             endif()
-            source_group(TREE ${src_loc} FILES ${full_name})
+            source_group(TREE ${src_loc} PREFIX Sources FILES ${full_name})
         endif()
     endforeach()
 
diff --git a/cmake/constants.cmake b/cmake/paths.cmake
similarity index 65%
rename from cmake/constants.cmake
rename to cmake/paths.cmake
index f36dcd5fe..148a2f7f0 100644
--- a/cmake/constants.cmake
+++ b/cmake/paths.cmake
@@ -1,9 +1,3 @@
 get_filename_component(libs_loc "../Libraries" REALPATH)
 get_filename_component(third_party_loc "Telegram/ThirdParty" REALPATH)
 get_filename_component(submodules_loc "Telegram" REALPATH)
-
-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
-    set(build_debug 1)
-else()
-    set(build_debug 0)
-endif()