Skip to content

Commit

Permalink
Initial Linux build.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Dec 4, 2019
1 parent 01ecd73 commit 619dbe9
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ stage
/snap/plugins/__pycache__

/Telegram/*.user.*
*.txt.user
*.pro.user
/Linux/
/Telegram/Makefile
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ project(Telegram
)

include(cmake/nice_target_sources.cmake)
include(cmake/target_link_static_libraries.cmake)
include(cmake/target_link_frameworks.cmake)
include(cmake/init_target.cmake)
include(cmake/generate_target.cmake)
Expand Down
52 changes: 41 additions & 11 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ PRIVATE
desktop-app::lib_ffmpeg
desktop-app::external_lz4
desktop-app::external_rlottie
desktop-app::external_zlib
desktop-app::external_qt
desktop-app::external_auto_updates
desktop-app::external_openssl
desktop-app::external_zlib
desktop-app::external_opus
desktop-app::external_openal
)
Expand All @@ -91,7 +91,8 @@ if (NOT DESKTOP_APP_DISABLE_CRASH_REPORTS)
target_link_libraries(Telegram PRIVATE desktop-app::external_crash_reports)
endif()

set(telegram_sources
target_precompile_headers(Telegram PRIVATE ${src_loc}/stdafx.h)
nice_target_sources(Telegram ${src_loc}
PRIVATE
${style_files}

Expand Down Expand Up @@ -931,9 +932,8 @@ PRIVATE
settings.cpp
settings.h
)
nice_target_sources(Telegram ${src_loc} "${telegram_sources}")

set(telegram_resources
nice_target_sources(Telegram ${res_loc}
PRIVATE
qrc/emoji_1.qrc
qrc/emoji_2.qrc
Expand All @@ -948,9 +948,6 @@ PRIVATE
langs/lang.strings
numbers.txt
)
nice_target_sources(Telegram ${res_loc} "${telegram_resources}")

target_precompile_headers(Telegram PRIVATE ${src_loc}/stdafx.h)

if (WIN32)
# message(${CMAKE_GENERATOR})
Expand Down Expand Up @@ -1009,6 +1006,34 @@ elseif (APPLE)
)
endif()
endif()
elseif (LINUX)
find_package(PkgConfig REQUIRED)

pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
target_include_directories(Telegram PRIVATE ${GTK2_INCLUDE_DIRS})
target_compile_options(Telegram PRIVATE -Wno-register)

set(appindicator_packages
ayatana-appindicator3-0.1
ayatana-appindicator-0.1
appindicator3-0.1
appindicator-0.1
)
set(appindicator_found 0)
foreach (package ${appindicator_packages})
pkg_check_modules(APPIND_${package} ${package})
if (APPIND_${package}_FOUND)
set(appindicator_found 1)
target_include_directories(Telegram PRIVATE "${APPIND_${package}_INCLUDE_DIRS}")
if (${package} MATCHES "ayatana")
target_compile_definitions(Telegram PRIVATE TDESKTOP_USE_AYATANA_INDICATORS)
endif()
break()
endif()
endforeach()
if (NOT ${appindicator_found})
message(FATAL_ERROR "No libappindicator found by pkg-config.")
endif()
endif()

if (build_macstore)
Expand Down Expand Up @@ -1081,22 +1106,27 @@ if (disable_autoupdate)
)
endif()

set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
if (${CMAKE_GENERATOR} MATCHES "(Visual Studio|Xcode|Ninja)")
set(output_folder ${CMAKE_BINARY_DIR})
else()
set(output_folder ${CMAKE_BINARY_DIR}/$<IF:$<CONFIG:Debug>,Debug,Release>)
endif()

set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder})

if (NOT build_macstore AND NOT build_winstore)
add_executable(Updater WIN32)
init_target(Updater)

add_dependencies(Telegram Updater)

set(updater_sources
nice_target_sources(Updater ${src_loc}
PRIVATE
_other/updater_win.cpp
_other/updater_linux.cpp
_other/updater_osx.m
_other/updater.h
)
nice_target_sources(Updater ${src_loc} "${updater_sources}")

set_target_properties(Updater PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set_target_properties(Updater PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder})
endif()
12 changes: 6 additions & 6 deletions Telegram/cmake/generate_lang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ function(generate_lang target_name lang_file)
set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
file(MAKE_DIRECTORY ${gen_dst})

set(generated_files
set(gen_timestamp ${gen_dst}/lang_auto.timestamp)
set(gen_files
${gen_dst}/lang_auto.cpp
${gen_dst}/lang_auto.h
${gen_dst}/lang_auto.timestamp
)

add_custom_command(
OUTPUT
${gen_dst}/lang_auto.timestamp
${gen_timestamp}
BYPRODUCTS
${gen_dst}/lang_auto.cpp
${gen_dst}/lang_auto.h
${gen_files}
COMMAND
codegen_lang
-o${gen_dst}
Expand All @@ -28,5 +28,5 @@ function(generate_lang target_name lang_file)
codegen_lang
${lang_file}
)
generate_target(${target_name} lang "${generated_files}" ${gen_dst})
generate_target(${target_name} lang ${gen_timestamp} "${gen_files}" ${gen_dst})
endfunction()
12 changes: 6 additions & 6 deletions Telegram/cmake/generate_numbers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ function(generate_numbers target_name numbers_file)
set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
file(MAKE_DIRECTORY ${gen_dst})

set(generated_files
set(gen_timestamp ${gen_dst}/numbers.timestamp)
set(gen_files
${gen_dst}/numbers.cpp
${gen_dst}/numbers.h
${gen_dst}/numbers.timestamp
)

add_custom_command(
OUTPUT
${gen_dst}/numbers.timestamp
${gen_timestamp}
BYPRODUCTS
${gen_dst}/numbers.cpp
${gen_dst}/numbers.h
${gen_files}
COMMAND
codegen_numbers
-o${gen_dst}
Expand All @@ -28,5 +28,5 @@ function(generate_numbers target_name numbers_file)
codegen_numbers
${numbers_file}
)
generate_target(${target_name} numbers "${generated_files}" ${gen_dst})
generate_target(${target_name} numbers ${gen_timestamp} "${gen_files}" ${gen_dst})
endfunction()
12 changes: 6 additions & 6 deletions Telegram/cmake/generate_scheme.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ function(generate_scheme target_name script scheme_files)
set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen)
file(MAKE_DIRECTORY ${gen_dst})

set(generated_files
set(gen_timestamp ${gen_dst}/scheme.timestamp)
set(gen_files
${gen_dst}/scheme.cpp
${gen_dst}/scheme.h
${gen_dst}/scheme.timestamp
)

add_custom_command(
OUTPUT
${gen_dst}/scheme.timestamp
${gen_timestamp}
BYPRODUCTS
${gen_dst}/scheme.cpp
${gen_dst}/scheme.h
${gen_files}
COMMAND
python
${script}
Expand All @@ -30,5 +30,5 @@ function(generate_scheme target_name script scheme_files)
${submodules_loc}/lib_tl/tl/generate_tl.py
${scheme_files}
)
generate_target(${target_name} scheme "${generated_files}" ${gen_dst})
generate_target(${target_name} scheme ${gen_timestamp} "${gen_files}" ${gen_dst})
endfunction()
6 changes: 2 additions & 4 deletions Telegram/cmake/lib_export.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ add_library(lib_export OBJECT)
init_target(lib_export)
add_library(tdesktop::lib_export ALIAS lib_export)

set(lib_export_sources
target_precompile_headers(lib_export PRIVATE ${src_loc}/export/export_pch.h)
nice_target_sources(lib_export ${src_loc}
PRIVATE
export/export_api_wrap.cpp
export/export_api_wrap.h
Expand All @@ -32,9 +33,6 @@ PRIVATE
export/output/export_output_text.cpp
export/output/export_output_text.h
)
nice_target_sources(lib_export ${src_loc} "${lib_export_sources}")

target_precompile_headers(lib_export PRIVATE ${src_loc}/export/export_pch.h)

target_include_directories(lib_export
PUBLIC
Expand Down
12 changes: 2 additions & 10 deletions Telegram/cmake/lib_ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,19 @@ add_library(lib_ffmpeg OBJECT)
add_library(desktop-app::lib_ffmpeg ALIAS lib_ffmpeg)
init_target(lib_ffmpeg)

set(lib_ffmpeg_sources
nice_target_sources(lib_ffmpeg ${src_loc}
PRIVATE
ffmpeg/ffmpeg_utility.cpp
ffmpeg/ffmpeg_utility.h
)
nice_target_sources(lib_ffmpeg ${src_loc} "${lib_ffmpeg_sources}")

target_include_directories(lib_ffmpeg
PUBLIC
${src_loc}
${libs_loc}/ffmpeg
)

set(ffmpeg_lib_loc ${libs_loc}/ffmpeg)

target_link_libraries(lib_ffmpeg
PUBLIC
desktop-app::lib_base
${ffmpeg_lib_loc}/libavformat/libavformat.a
${ffmpeg_lib_loc}/libavcodec/libavcodec.a
${ffmpeg_lib_loc}/libavutil/libavutil.a
${ffmpeg_lib_loc}/libswresample/libswresample.a
${ffmpeg_lib_loc}/libswscale/libswscale.a
desktop-app::external_ffmpeg
)
6 changes: 2 additions & 4 deletions Telegram/cmake/lib_mtproto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ add_library(lib_mtproto OBJECT)
init_target(lib_mtproto)
add_library(tdesktop::lib_mtproto ALIAS lib_mtproto)

set(lib_mtproto_sources
target_precompile_headers(lib_mtproto PRIVATE ${src_loc}/mtproto/mtp_pch.h)
nice_target_sources(lib_mtproto ${src_loc}
PRIVATE
mtproto/mtp_abstract_socket.cpp
mtproto/mtp_abstract_socket.h
Expand All @@ -17,9 +18,6 @@ PRIVATE
mtproto/mtp_tls_socket.cpp
mtproto/mtp_tls_socket.h
)
nice_target_sources(lib_mtproto ${src_loc} "${lib_mtproto_sources}")

target_precompile_headers(lib_mtproto PRIVATE ${src_loc}/mtproto/mtp_pch.h)

target_include_directories(lib_mtproto
PUBLIC
Expand Down
25 changes: 16 additions & 9 deletions Telegram/cmake/lib_tgvoip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL

add_library(lib_tgvoip STATIC)
init_target(lib_tgvoip cxx_std_11)
init_target(lib_tgvoip)
add_library(tdesktop::lib_tgvoip ALIAS lib_tgvoip)

set(tgvoip_loc ${third_party_loc}/libtgvoip)

set(lib_tgvoip_sources
nice_target_sources(lib_tgvoip ${tgvoip_loc}
PRIVATE
BlockingQueue.cpp
BlockingQueue.h
Expand Down Expand Up @@ -710,10 +710,8 @@ PRIVATE
# webrtc_dsp/common_audio/signal_processing/filter_ar_fast_q12_armv7.S
)

nice_target_sources(lib_tgvoip ${tgvoip_loc} "${lib_tgvoip_sources}")

target_compile_definitions(lib_tgvoip
PRIVATE
PUBLIC
WEBRTC_APM_DEBUG_DUMP=0
TGVOIP_USE_DESKTOP_DSP
WEBRTC_NS_FLOAT
Expand All @@ -726,26 +724,35 @@ if (WIN32)
/wd4244 # conversion from 'int' to 'float', possible loss of data (several in webrtc)
)
target_compile_definitions(lib_tgvoip
PRIVATE
PUBLIC
WEBRTC_WIN
)
elseif (APPLE)
target_compile_definitions(lib_tgvoip
PRIVATE
PUBLIC
WEBRTC_POSIX
WEBRTC_MAC
TARGET_OS_OSX
TARGET_OSX
)
if (build_macstore)
target_compile_definitions(lib_tgvoip
PRIVATE
PUBLIC
TGVOIP_NO_OSX_PRIVATE_API
)
endif()
else()
target_compile_definitions(lib_tgvoip
target_compile_options(lib_tgvoip
PRIVATE
-Wno-unknown-pragmas
-Wno-error=sequence-point
-Wno-error=unused-result
)
if (build_linux32)
target_compile_options(lib_tgvoip PRIVATE -msse2)
endif()
target_compile_definitions(lib_tgvoip
PUBLIC
WEBRTC_POSIX
WEBRTC_LINUX
)
Expand Down
2 changes: 1 addition & 1 deletion Telegram/lib_base
2 changes: 1 addition & 1 deletion Telegram/lib_crl
Submodule lib_crl updated 1 files
+1 −2 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_lottie
Submodule lib_lottie updated 1 files
+1 −2 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_rpl
Submodule lib_rpl updated 1 files
+1 −2 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_spellcheck
Submodule lib_spellcheck updated 1 files
+2 −4 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_storage
Submodule lib_storage updated 1 files
+2 −4 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_tl
Submodule lib_tl updated 1 files
+1 −2 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_ui

0 comments on commit 619dbe9

Please sign in to comment.