Skip to content

Commit

Permalink
Initial Windows Debug build with cmake.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 11, 2019
1 parent 85060cd commit 61723bd
Show file tree
Hide file tree
Showing 20 changed files with 201 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0076 NEW)
cmake_policy(SET CMP0091 NEW)

Expand Down
79 changes: 58 additions & 21 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_subdirectory(lib_base)
add_subdirectory(lib_ui)
add_subdirectory(lib_tl)
add_subdirectory(lib_spellcheck)
add_subdirectory(lib_storage)
add_subdirectory(lib_lottie)
add_subdirectory(lib_rlottie)
add_subdirectory(codegen)
Expand Down Expand Up @@ -54,17 +55,33 @@ 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 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
lib_mtproto
lib_scheme
lib_export
lib_ffmpeg
lib_tgvoip
lib_lz4
external_qt
external_openssl
external_crash_reports
external_auto_updates
external_zlib
external_opus
external_openal
)

set(telegram_sources
Expand Down Expand Up @@ -904,35 +921,55 @@ PRIVATE
qt_static_plugins.cpp
settings.cpp
settings.h

# 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}")

set(telegram_resources
PRIVATE
qrc/emoji_1.qrc
qrc/emoji_2.qrc
qrc/emoji_3.qrc
qrc/emoji_4.qrc
qrc/emoji_5.qrc
qrc/emoji_preview.qrc
qrc/telegram/telegram.qrc
qrc/telegram/sounds.qrc
winrc/Telegram.rc
winrc/Telegram.manifest
)
nice_target_sources(Telegram ${res_loc} "${telegram_resources}")

force_include(Telegram stdafx.h)

if (WIN32)
# message(${CMAKE_GENERATOR})
# mt.exe -manifest "${res_loc}/winrc/Telegram.manifest" "-inputresource:\"$<TARGET_FILE:Telegram>\";#1" "-outputresource:\"$<TARGET_FILE:Telegram>\";#1" >NUL
# set(hash_symbol "#")
# set(release $<CONFIG:Release>)
# add_custom_command(
# TARGET
# Telegram
# POST_BUILD COMMAND
# $<IF:${release},mt.exe,echo.> $<${release}:-manifest> $<${release}:"${res_loc}/winrc/Telegram.manifest"> $<${release}:-inputresource:"$<TARGET_FILE:Telegram>"$<SEMICOLON>${hash_symbol}1> $<${release}:-outputresource:"$<TARGET_FILE:Telegram>"$<SEMICOLON>${hash_symbol}1> $<${release}:$<ANGLE-R>NUL>
# COMMENT
# $<IF:${release},"Appending compatibility manifest.","Finalizing build.">
# )
else()
target_link_libraries(Telegram
PRIVATE
external_minizip
)
if (APPLE)
target_link_libraries(Telegram
PRIVATE
external_sp_media_key_tap
)
endif()
endif()

target_include_directories(Telegram
PRIVATE
${src_loc}
${libs_loc}/zlib
${libs_loc}/lzma/C
${libs_loc}/openal-soft/include
${third_party_loc}/minizip
)

Expand Down
2 changes: 1 addition & 1 deletion Telegram/ThirdParty/libtgvoip
10 changes: 10 additions & 0 deletions Telegram/cmake/lib_ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ PUBLIC
${libs_loc}/ffmpeg
)

target_link_directories(lib_ffmpeg
PUBLIC
${libs_loc}/ffmpeg
)

target_link_libraries(lib_ffmpeg
PUBLIC
lib_base
${libs_loc}/ffmpeg/libavformat/libavformat.a
${libs_loc}/ffmpeg/libavcodec/libavcodec.a
${libs_loc}/ffmpeg/libavutil/libavutil.a
${libs_loc}/ffmpeg/libswresample/libswresample.a
${libs_loc}/ffmpeg/libswscale/libswscale.a
)
5 changes: 5 additions & 0 deletions Telegram/cmake/lib_tgvoip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ 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
external_openssl
Expand Down
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_rlottie
Submodule lib_rlottie updated 1 files
+2 −1 CMakeLists.txt
2 changes: 1 addition & 1 deletion Telegram/lib_ui
Submodule lib_ui updated 1 files
+11 −1 CMakeLists.txt
9 changes: 6 additions & 3 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ if (WIN32)
_WINDOWS
_UNICODE
UNICODE
# HAVE_STDINT_H
# ZLIB_WINAPI
_SCL_SECURE_NO_WARNINGS
_USING_V110_SDK71_
NOMINMAX
Expand All @@ -50,6 +48,10 @@ if (WIN32)
/wd5105 # needed for `/experimental:preprocessor`, suppressing C5105 "macro expansion producing 'defined' has undefined behavior"
/Zc:wchar_t- # don't tread wchar_t as builtin type
)
target_link_options(common_no_ranges
INTERFACE
/NODEFAULTLIB:LIBCMT
)
target_link_libraries(common_no_ranges
INTERFACE
winmm
Expand Down Expand Up @@ -79,7 +81,8 @@ if (WIN32)
UxTheme
DbgHelp
Rstrtmgr
)
Crypt32
)
else()
endif()

Expand Down
4 changes: 4 additions & 0 deletions cmake/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ add_subdirectory(variant)
add_subdirectory(ranges)
add_subdirectory(gsl)
add_subdirectory(crash_reports)
add_subdirectory(auto_updates)
add_subdirectory(zlib)
add_subdirectory(opus)
add_subdirectory(openal)
15 changes: 15 additions & 0 deletions cmake/external/auto_updates/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
add_library(external_auto_updates INTERFACE IMPORTED GLOBAL)

if (WIN32)
add_subdirectory(lzma)
target_link_libraries(external_auto_updates
INTERFACE
external_lzma
)
else()
add_subdirectory(xz)
target_link_libraries(external_auto_updates
INTERFACE
external_xz
)
endif()
16 changes: 16 additions & 0 deletions cmake/external/auto_updates/lzma/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_library(external_lzma INTERFACE IMPORTED GLOBAL)

target_include_directories(external_lzma SYSTEM
INTERFACE
${libs_loc}/lzma/C
)

target_link_directories(external_lzma
INTERFACE
${libs_loc}/lzma/C/Util/LzmaLib/$<IF:$<CONFIG:Debug>,Debug,Release>
)

target_link_libraries(external_lzma
INTERFACE
LzmaLib
)
3 changes: 1 addition & 2 deletions cmake/external/crash_reports/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
add_library(external_crash_reports INTERFACE IMPORTED GLOBAL)

add_subdirectory(breakpad)

if (WIN32)
add_subdirectory(breakpad)
target_link_libraries(external_crash_reports
INTERFACE
external_breakpad
Expand Down
16 changes: 16 additions & 0 deletions cmake/external/openal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_library(external_openal INTERFACE IMPORTED GLOBAL)

target_include_directories(external_openal SYSTEM
INTERFACE
${libs_loc}/openal-soft/include
)

target_link_directories(external_openal
INTERFACE
${libs_loc}/openal-soft/build/$<IF:$<CONFIG:Debug>,Debug,Release>
)

target_link_libraries(external_openal
INTERFACE
OpenAL32
)
11 changes: 11 additions & 0 deletions cmake/external/openssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ target_include_directories(external_openssl SYSTEM
INTERFACE
${libs_loc}/openssl_1_1_1/include
)

target_link_directories(external_openssl
INTERFACE
${libs_loc}/openssl_1_1_1/out32$<$<CONFIG:Debug>:.dbg>
)

target_link_libraries(external_openssl
INTERFACE
libcrypto
libssl
)
16 changes: 16 additions & 0 deletions cmake/external/opus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_library(external_opus INTERFACE IMPORTED GLOBAL)

target_include_directories(external_opus SYSTEM
INTERFACE
${libs_loc}/opus/include
)

target_link_directories(external_opus
INTERFACE
${libs_loc}/opus/win32/VS2015/Win32/$<IF:$<CONFIG:Debug>,Debug,Release>
)

target_link_libraries(external_opus
INTERFACE
opus
)
24 changes: 24 additions & 0 deletions cmake/external/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
add_library(external_zlib INTERFACE IMPORTED GLOBAL)

target_include_directories(external_zlib SYSTEM
INTERFACE
${libs_loc}/zlib
${libs_loc}/zlib/contrib/minizip
)

if (WIN32)
target_compile_definitions(external_zlib
INTERFACE
ZLIB_WINAPI
)
endif()

target_link_directories(external_zlib
INTERFACE
${libs_loc}/zlib/contrib/vstudio/vc14/x86/ZlibStat$<IF:$<CONFIG:Debug>,Debug,ReleaseWithoutAsm>
)

target_link_libraries(external_zlib
INTERFACE
zlibstat
)
6 changes: 6 additions & 0 deletions cmake/init_target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ function(init_target_no_ranges target_name) # init_target(my_target folder_name)
init_target_folder(${target_name} "${ARGV1}")
set_property(TARGET ${target_name} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if (WIN32)
target_compile_options(${target_name}
INTERFACE
/W1
)
endif()
target_link_libraries(${target_name} PUBLIC common_no_ranges)
endfunction()

Expand Down
11 changes: 7 additions & 4 deletions cmake/nice_target_sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ function(nice_target_sources target_name src_loc list)
set(writing_now ${file})
else()
set(full_name ${src_loc}/${file})
if (${file} MATCHES "/win/" OR ${file} MATCHES "_win\\." OR ${file} MATCHES "/windows/")
if (${file} MATCHES "(^|/)win/" OR ${file} MATCHES "(^|/)winrc/" OR ${file} MATCHES "(^|/)windows/" OR ${file} MATCHES "[_\\/]win\\.")
list(APPEND not_mac_sources ${full_name})
list(APPEND not_linux_sources ${full_name})
elseif (${file} MATCHES "/mac/" OR ${file} MATCHES "_mac\\." OR ${file} MATCHES "/darwin/")
elseif (${file} MATCHES "(^|/)mac/" OR ${file} MATCHES "(^|/)darwin/" OR ${file} MATCHES "[_\\/]mac\\.")
list(APPEND not_win_sources ${full_name})
list(APPEND not_linux_sources ${full_name})
elseif (${file} MATCHES "/linux/" OR ${file} MATCHES "_linux\\.")
elseif (${file} MATCHES "(^|/)linux/" OR ${file} MATCHES "[_\\/]linux\\.")
list(APPEND not_win_sources ${full_name})
list(APPEND not_mac_sources ${full_name})
elseif (${file} MATCHES "/posix/" OR ${file} MATCHES "_posix\\.")
elseif (${file} MATCHES "(^|/)posix/" OR ${file} MATCHES "[_\\/]posix\\.")
list(APPEND not_win_sources ${full_name})
endif()
if ("${writing_now}" STREQUAL "PRIVATE")
Expand All @@ -47,9 +47,12 @@ function(nice_target_sources target_name src_loc list)
endif()
if (WIN32)
set_source_files_properties(${not_win_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties(${not_win_sources} PROPERTIES SKIP_AUTOGEN TRUE)
elseif (APPLE)
set_source_files_properties(${not_mac_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties(${not_mac_sources} PROPERTIES SKIP_AUTOGEN TRUE)
elseif (LINUX)
set_source_files_properties(${not_linux_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties(${not_linux_sources} PROPERTIES SKIP_AUTOGEN TRUE)
endif()
endfunction()

0 comments on commit 61723bd

Please sign in to comment.