diff --git a/.gitmodules b/.gitmodules index 2ae139598e..76a2a7f44b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,3 +52,6 @@ [submodule "Telegram/lib_storage"] path = Telegram/lib_storage url = https://github.com/desktop-app/lib_storage.git +[submodule "cmake"] + path = cmake + url = https://github.com/desktop-app/cmake_helpers.git diff --git a/cmake b/cmake new file mode 160000 index 0000000000..2a87436d39 --- /dev/null +++ b/cmake @@ -0,0 +1 @@ +Subproject commit 2a87436d39b8c0248a2e717b2ef1834329489ccc diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt deleted file mode 100644 index 126657d2a2..0000000000 --- a/cmake/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(external) diff --git a/cmake/external/CMakeLists.txt b/cmake/external/CMakeLists.txt deleted file mode 100644 index e232a576c7..0000000000 --- a/cmake/external/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -add_subdirectory(qt) -add_subdirectory(openssl) -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) diff --git a/cmake/external/auto_updates/CMakeLists.txt b/cmake/external/auto_updates/CMakeLists.txt deleted file mode 100644 index 4a2ff4bca2..0000000000 --- a/cmake/external/auto_updates/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -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() diff --git a/cmake/external/auto_updates/lzma/CMakeLists.txt b/cmake/external/auto_updates/lzma/CMakeLists.txt deleted file mode 100644 index a58fbaab8c..0000000000 --- a/cmake/external/auto_updates/lzma/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -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/$,Debug,Release> -) - -target_link_libraries(external_lzma -INTERFACE - LzmaLib -) diff --git a/cmake/external/crash_reports/CMakeLists.txt b/cmake/external/crash_reports/CMakeLists.txt deleted file mode 100644 index 8633b4a51a..0000000000 --- a/cmake/external/crash_reports/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -add_library(external_crash_reports INTERFACE IMPORTED GLOBAL) - -if (WIN32) - add_subdirectory(breakpad) - target_link_libraries(external_crash_reports - INTERFACE - external_breakpad - ) -else() - target_link_libraries(external_crash_reports - INTERFACE - external_crashpad - ) -endif() diff --git a/cmake/external/crash_reports/breakpad/CMakeLists.txt b/cmake/external/crash_reports/breakpad/CMakeLists.txt deleted file mode 100644 index 7ef281a67c..0000000000 --- a/cmake/external/crash_reports/breakpad/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -add_library(external_breakpad INTERFACE IMPORTED GLOBAL) - -target_include_directories(external_breakpad SYSTEM -INTERFACE - ${libs_loc}/breakpad/src -) - -target_link_libraries(external_breakpad -INTERFACE - windows/common - windows/handler/exception_handler - windows/crash_generation/crash_generation_client -) - -target_link_directories(external_breakpad -INTERFACE - ${libs_loc}/breakpad/src/out/$,Debug,Release>/obj/client -) diff --git a/cmake/external/gsl/CMakeLists.txt b/cmake/external/gsl/CMakeLists.txt deleted file mode 100644 index 5a3e4ec335..0000000000 --- a/cmake/external/gsl/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_library(external_gsl INTERFACE IMPORTED GLOBAL) - -target_include_directories(external_gsl SYSTEM -INTERFACE - ${third_party_loc}/GSL/include -) diff --git a/cmake/external/openal/CMakeLists.txt b/cmake/external/openal/CMakeLists.txt deleted file mode 100644 index 58f0a5c878..0000000000 --- a/cmake/external/openal/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -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/$,Debug,Release> -) - -target_link_libraries(external_openal -INTERFACE - OpenAL32 -) diff --git a/cmake/external/openssl/CMakeLists.txt b/cmake/external/openssl/CMakeLists.txt deleted file mode 100644 index 8ebdd5901f..0000000000 --- a/cmake/external/openssl/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -add_library(external_openssl INTERFACE IMPORTED GLOBAL) - -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$<$:.dbg> -) - -target_link_libraries(external_openssl -INTERFACE - libcrypto - libssl -) diff --git a/cmake/external/opus/CMakeLists.txt b/cmake/external/opus/CMakeLists.txt deleted file mode 100644 index 3aed144fe8..0000000000 --- a/cmake/external/opus/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -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/$,Debug,Release> -) - -target_link_libraries(external_opus -INTERFACE - opus -) diff --git a/cmake/external/qt/CMakeLists.txt b/cmake/external/qt/CMakeLists.txt deleted file mode 100644 index bf16462a91..0000000000 --- a/cmake/external/qt/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -add_library(external_qt INTERFACE IMPORTED GLOBAL) - -target_include_directories(external_qt SYSTEM -INTERFACE - ${qt_loc}/include - ${qt_loc}/include/QtCore - ${qt_loc}/include/QtGui - ${qt_loc}/include/QtDBus - ${qt_loc}/include/QtCore/${qt_version} - ${qt_loc}/include/QtGui/${qt_version} - ${qt_loc}/include/QtCore/${qt_version}/QtCore - ${qt_loc}/include/QtGui/${qt_version}/QtGui -) - -set(common_qt_libs - qwebp - qgif - qjpeg - Qt5PrintSupport - Qt5AccessibilitySupport - Qt5FontDatabaseSupport - Qt5EventDispatcherSupport - Qt5ThemeSupport - Qt5Network - Qt5Widgets - Qt5Gui - qtharfbuzz - qtlibpng -) - -if (WIN32) - set(qt_libs - ${common_qt_libs} - Qt5Core - Qt5WindowsUIAutomationSupport - qtmain - qwindows - qtfreetype - qtpcre2 - ) - set(qt_libs_list "") - foreach(lib ${qt_libs}) - list(APPEND qt_libs_list "${lib}$<$:d>") - endforeach() -else() -endif() - -target_link_directories(external_qt -INTERFACE - ${qt_loc}/lib - ${qt_loc}/plugins - ${qt_loc}/plugins/bearer - ${qt_loc}/plugins/platforms - ${qt_loc}/plugins/imageformats -) - -target_link_libraries(external_qt -INTERFACE - ${qt_libs_list} -) diff --git a/cmake/external/qt/package.cmake b/cmake/external/qt/package.cmake deleted file mode 100644 index 8c9cfb1e37..0000000000 --- a/cmake/external/qt/package.cmake +++ /dev/null @@ -1,17 +0,0 @@ -set(qt_version 5.12.5) - -if (WIN32) - set(qt_loc ${libs_loc}/Qt-${qt_version}) -else() -endif() - -set(Qt5_DIR ${qt_loc}/lib/cmake/Qt5) - -find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED) - -if (LINUX) - find_package(Qt5 COMPONENTS DBus) -endif() - -set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "(gen)") -set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "(gen)") diff --git a/cmake/external/ranges/CMakeLists.txt b/cmake/external/ranges/CMakeLists.txt deleted file mode 100644 index f6b3c85902..0000000000 --- a/cmake/external/ranges/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -add_library(external_ranges INTERFACE IMPORTED GLOBAL) - -target_include_directories(external_ranges SYSTEM -INTERFACE - ${libs_loc}/range-v3/include -) - -if (WIN32) - target_compile_options(external_ranges - INTERFACE - /experimental:preprocessor # need for range-v3 see https://github.com/ericniebler/range-v3#supported-compilers - /wd5105 # needed for `/experimental:preprocessor`, suppressing C5105 "macro expansion producing 'defined' has undefined behavior" - ) -endif() \ No newline at end of file diff --git a/cmake/external/variant/CMakeLists.txt b/cmake/external/variant/CMakeLists.txt deleted file mode 100644 index b0bee9a76c..0000000000 --- a/cmake/external/variant/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_library(external_variant INTERFACE IMPORTED GLOBAL) - -target_include_directories(external_variant SYSTEM -INTERFACE - ${third_party_loc}/variant/include -) diff --git a/cmake/external/zlib/CMakeLists.txt b/cmake/external/zlib/CMakeLists.txt deleted file mode 100644 index b29adf0981..0000000000 --- a/cmake/external/zlib/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -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$,Debug,ReleaseWithoutAsm> -) - -target_link_libraries(external_zlib -INTERFACE - zlibstat -) diff --git a/cmake/force_include.cmake b/cmake/force_include.cmake deleted file mode 100644 index 5e684c1942..0000000000 --- a/cmake/force_include.cmake +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index cca0f5a5ec..0000000000 --- a/cmake/generate_target.cmake +++ /dev/null @@ -1,8 +0,0 @@ -function(generate_target parent_name postfix generated_files gen_dst) - add_custom_target(${parent_name}_${postfix} DEPENDS ${generated_files}) - init_target_folder(${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 deleted file mode 100644 index 08ae1e35c4..0000000000 --- a/cmake/init_target.cmake +++ /dev/null @@ -1,15 +0,0 @@ -function(init_target_folder target_name folder_name) - if (NOT "${folder_name}" STREQUAL "") - set_target_properties(${target_name} PROPERTIES FOLDER ${folder_name}) - endif() -endfunction() - -function(init_target target_name) # init_target(my_target folder_name) - init_target_folder(${target_name} "${ARGV1}") - if (WIN32) - set_property(TARGET ${target_name} PROPERTY - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() - target_link_libraries(${target_name} PUBLIC common_options) -endfunction() - diff --git a/cmake/nice_target_sources.cmake b/cmake/nice_target_sources.cmake deleted file mode 100644 index 3026b0d7ff..0000000000 --- a/cmake/nice_target_sources.cmake +++ /dev/null @@ -1,58 +0,0 @@ -function(nice_target_sources target_name src_loc list) - set(writing_now "") - set(private_sources "") - set(public_sources "") - set(interface_sources "") - set(not_win_sources "") - set(not_mac_sources "") - set(not_linux_sources "") - foreach(file ${list}) - if (${file} STREQUAL "PRIVATE" OR ${file} STREQUAL "PUBLIC" OR ${file} STREQUAL "INTERFACE") - set(writing_now ${file}) - else() - set(full_name ${src_loc}/${file}) - 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 "(^|/)darwin/" OR ${file} MATCHES "(^|/)osx/" OR ${file} MATCHES "[_\\/]mac\\." OR ${file} MATCHES "[_\\/]darwin\\." OR ${file} MATCHES "[_\\/]osx\\.") - list(APPEND not_win_sources ${full_name}) - list(APPEND not_linux_sources ${full_name}) - 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\\.") - list(APPEND not_win_sources ${full_name}) - endif() - if ("${writing_now}" STREQUAL "PRIVATE") - list(APPEND private_sources ${full_name}) - elseif ("${writing_now}" STREQUAL "PUBLIC") - list(APPEND public_sources ${full_name}) - elseif ("${writing_now}" STREQUAL "INTERFACE") - list(APPEND interface_sources ${full_name}) - else() - message(FATAL_ERROR "Unknown sources scope for target ${target_name}") - endif() - source_group(TREE ${src_loc} PREFIX Sources FILES ${full_name}) - endif() - endforeach() - - if (NOT "${public_sources}" STREQUAL "") - target_sources(${target_name} PUBLIC ${public_sources}) - endif() - if (NOT "${private_sources}" STREQUAL "") - target_sources(${target_name} PRIVATE ${private_sources}) - endif() - if (NOT "${interface_sources}" STREQUAL "") - target_sources(${target_name} INTERFACE ${interface_sources}) - 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() diff --git a/cmake/options.cmake b/cmake/options.cmake deleted file mode 100644 index aab86150d1..0000000000 --- a/cmake/options.cmake +++ /dev/null @@ -1,16 +0,0 @@ -add_library(common_options INTERFACE) - -target_compile_features(common_options -INTERFACE - cxx_std_17 -) - -target_compile_definitions(common_options -INTERFACE - UNICODE -) - -if (WIN32) - include(cmake/options_win.cmake) -else() -endif() diff --git a/cmake/options_win.cmake b/cmake/options_win.cmake deleted file mode 100644 index 570e9e644f..0000000000 --- a/cmake/options_win.cmake +++ /dev/null @@ -1,61 +0,0 @@ -target_compile_definitions(common_options -INTERFACE - WIN32 - _WINDOWS - _UNICODE - UNICODE - _SCL_SECURE_NO_WARNINGS - _USING_V110_SDK71_ - NOMINMAX -) -target_compile_options(common_options -INTERFACE - /permissive- - # /Qspectre - /W1 - /WX - /MP # Enable multi process build. - /EHsc # Catch C++ exceptions only, extern C functions never throw a C++ exception. - /w14834 # [[nodiscard]] - /w15038 # wrong initialization order - /w14265 # class has virtual functions, but destructor is not virtual - /wd4068 # Disable "warning C4068: unknown pragma" - /Zc:wchar_t- # don't tread wchar_t as builtin type -) - -target_link_options(common_options -INTERFACE - /NODEFAULTLIB:LIBCMT -) - -target_link_libraries(common_options -INTERFACE - winmm - imm32 - ws2_32 - kernel32 - user32 - gdi32 - winspool - comdlg32 - advapi32 - shell32 - ole32 - oleaut32 - uuid - odbc32 - odbccp32 - Shlwapi - Iphlpapi - Gdiplus - Strmiids - Netapi32 - Userenv - Version - Dwmapi - Wtsapi32 - UxTheme - DbgHelp - Rstrtmgr - Crypt32 -) diff --git a/cmake/paths.cmake b/cmake/paths.cmake deleted file mode 100644 index 148a2f7f04..0000000000 --- a/cmake/paths.cmake +++ /dev/null @@ -1,3 +0,0 @@ -get_filename_component(libs_loc "../Libraries" REALPATH) -get_filename_component(third_party_loc "Telegram/ThirdParty" REALPATH) -get_filename_component(submodules_loc "Telegram" REALPATH)