Skip to content

Commit

Permalink
Initial build with Xcode.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 25, 2019
1 parent fe1aacd commit 5bfb98b
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 27 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ project(Telegram
HOMEPAGE_URL "https://desktop.telegram.org"
)

include(cmake/options.cmake)
include(cmake/nice_target_sources.cmake)
include(cmake/target_link_frameworks.cmake)
include(cmake/init_target.cmake)
include(cmake/generate_target.cmake)
include(cmake/nice_target_sources.cmake)

include(cmake/options.cmake)

include(cmake/external/qt/package.cmake)

add_subdirectory(cmake)
Expand Down
82 changes: 68 additions & 14 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
add_executable(Telegram WIN32 MACOSX_BUNDLE)
init_target(Telegram)

add_executable(Updater WIN32)
init_target(Updater)

add_subdirectory(lib_rpl)
add_subdirectory(lib_crl)
add_subdirectory(lib_base)
Expand Down Expand Up @@ -63,8 +60,7 @@ 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)

set_target_properties(Telegram PROPERTIES AUTOMOC ON)
set_target_properties(Telegram PROPERTIES AUTORCC ON)
set_target_properties(Telegram PROPERTIES AUTOMOC ON AUTORCC ON)

target_link_libraries(Telegram
PRIVATE
Expand All @@ -82,14 +78,17 @@ PRIVATE
desktop-app::external_lz4
desktop-app::external_rlottie
desktop-app::external_qt
desktop-app::external_openssl
desktop-app::external_crash_reports
desktop-app::external_auto_updates
desktop-app::external_openssl
desktop-app::external_zlib
desktop-app::external_opus
desktop-app::external_openal
)

if (NOT DESKTOP_APP_DISABLE_CRASH_REPORTS)
target_link_libraries(Telegram PRIVATE desktop-app::external_crash_reports)
endif()

set(telegram_sources
PRIVATE
api/api_common.h
Expand Down Expand Up @@ -960,19 +959,70 @@ if (WIN32)
# COMMENT
# $<IF:${release},"Appending compatibility manifest.","Finalizing build.">
# )
else()
elseif (APPLE)
target_link_libraries(Telegram
PRIVATE
desktop-app::external_minizip
desktop-app::external_sp_media_key_tap
desktop-app::external_iconv
)

set(icons_path ${CMAKE_CURRENT_SOURCE_DIR}/Telegram/Images.xcassets)
set_target_properties(Telegram PROPERTIES RESOURCE ${icons_path})
target_sources(Telegram PRIVATE ${icons_path})

set(lang_packs
en
de
es
it
nl
ko
pt-BR
)
if (APPLE)
target_link_libraries(Telegram
PRIVATE
desktop-app::external_sp_media_key_tap
foreach (lang ${lang_packs})
set(strings_path ${res_loc}/langs/${lang}.lproj/Localizable.strings)
set_source_files_properties(${strings_path} PROPERTIES
MACOSX_PACKAGE_LOCATION
Resources/${lang}.lproj/Localizable.strings
)
target_sources(Telegram PRIVATE ${strings_path})
endforeach()

add_custom_command(TARGET Telegram
PRE_LINK
COMMAND mkdir -p $<TARGET_FILE_DIR:Telegram>/../Frameworks
COMMAND cp $<TARGET_FILE:Updater> $<TARGET_FILE_DIR:Telegram>/../Frameworks/
)

if (NOT DESKTOP_APP_DISABLE_CRASH_REPORTS)
add_custom_command(TARGET Telegram
PRE_LINK
COMMAND mkdir -p $<TARGET_FILE_DIR:Telegram>/../Helpers
COMMAND cp ${libs_loc}/crashpad/out/$<IF:$<CONFIG:Debug>,Debug,Release>/crashpad_handler $<TARGET_FILE_DIR:Telegram>/../Helpers/
)
endif()
endif()

if (build_macstore)
set(bundle_identifier "org.telegram.desktop")
elseif (build_osx)
set(bundle_identifier "com.tdesktop.Telegram$<$<CONFIG:Debug>:DebugOsx>")
else()
set(bundle_identifier "com.tdesktop.Telegram$<$<CONFIG:Debug>:Debug>")
endif()
set_target_properties(Telegram PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER ${bundle_identifier}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Telegram.plist
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT $<$<NOT:$<CONFIG:Debug>>:dwarf-with-dsym>
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES YES
XCODE_ATTRIBUTE_COPY_PHASE_STRIP NO
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO
XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY libc++
XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS --deep
)

target_include_directories(Telegram
PRIVATE
${src_loc}
Expand All @@ -987,6 +1037,11 @@ PRIVATE
AL_ALEXT_PROTOTYPES
)

set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

add_executable(Updater WIN32)
init_target(Updater)

add_dependencies(Telegram Updater)

set(updater_sources
Expand All @@ -998,5 +1053,4 @@ PRIVATE
)
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}")
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/platform/mac/mac_touchbar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "mainwindow.h"
#include "observer_peer.h"
#include "base/platform/mac/base_utilities_mac.h"
#include "stickers.h"
#include "chat_helpers/stickers.h"
#include "styles/style_dialogs.h"
#include "styles/style_media_player.h"
#include "styles/style_settings.h"
Expand Down
2 changes: 2 additions & 0 deletions Telegram/cmake/generate_lang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

function(generate_lang target_name lang_file)
set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
file(MAKE_DIRECTORY ${gen_dst})

set(generated_files
${gen_dst}/lang_auto.cpp
${gen_dst}/lang_auto.h
Expand Down
2 changes: 2 additions & 0 deletions Telegram/cmake/generate_numbers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

function(generate_numbers target_name numbers_file)
set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
file(MAKE_DIRECTORY ${gen_dst})

set(generated_files
${gen_dst}/numbers.cpp
${gen_dst}/numbers.h
Expand Down
2 changes: 2 additions & 0 deletions Telegram/cmake/generate_scheme.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

function(generate_scheme target_name script scheme_files)
set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
file(MAKE_DIRECTORY ${gen_dst})

set(generated_files
${gen_dst}/scheme.cpp
${gen_dst}/scheme.h
Expand Down
13 changes: 6 additions & 7 deletions Telegram/cmake/lib_tgvoip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# 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)
add_library(lib_tgvoip STATIC)
init_target(lib_tgvoip cxx_std_11)
add_library(tdesktop::lib_tgvoip ALIAS lib_tgvoip)

set(tgvoip_loc ${third_party_loc}/libtgvoip)
Expand Down Expand Up @@ -168,6 +168,8 @@ PRIVATE
webrtc_dsp/rtc_base/sanitizer.h
webrtc_dsp/rtc_base/scoped_ref_ptr.h
webrtc_dsp/rtc_base/logging.h
webrtc_dsp/rtc_base/logging_mac.h
webrtc_dsp/rtc_base/logging_mac.mm
webrtc_dsp/rtc_base/timeutils.h
webrtc_dsp/rtc_base/atomicops.h
webrtc_dsp/rtc_base/stringencode.cc
Expand Down Expand Up @@ -721,6 +723,7 @@ if (WIN32)
target_compile_options(lib_tgvoip
PRIVATE
/wd4005
/wd4244 # conversion from 'int' to 'float', possible loss of data (several in webrtc)
)
target_compile_definitions(lib_tgvoip
PRIVATE
Expand All @@ -732,6 +735,7 @@ elseif (APPLE)
WEBRTC_POSIX
WEBRTC_MAC
TARGET_OS_OSX
TARGET_OSX
)
if (build_macstore)
target_compile_definitions(lib_tgvoip
Expand All @@ -755,11 +759,6 @@ PRIVATE
${libs_loc}/opus/include
)

target_compile_options(lib_tgvoip
PRIVATE
/wd4244 # conversion from 'int' to 'float', possible loss of data (several in webrtc)
)

target_link_libraries(lib_tgvoip
PRIVATE
desktop-app::external_openssl
Expand Down
2 changes: 1 addition & 1 deletion Telegram/lib_rlottie
Submodule lib_rlottie updated 1 files
+0 −112 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_ui

0 comments on commit 5bfb98b

Please sign in to comment.