From 118ce81dd412306900f862be412b419cf243cfa2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 21 Nov 2019 14:54:32 +0300 Subject: [PATCH] Add more options and external_ libs. --- external/CMakeLists.txt | 2 ++ external/lz4/CMakeLists.txt | 28 +++++++++++++++ external/openal/CMakeLists.txt | 6 ++++ external/qt/CMakeLists.txt | 19 +++++++++++ external/xxhash/CMakeLists.txt | 17 ++++++++++ force_include.cmake | 19 ----------- options.cmake | 14 ++++++++ options_linux.cmake | 5 +++ paths.cmake => options_mac.cmake | 8 +++-- options_win.cmake | 6 ++-- variables.cmake | 58 ++++++++++++++++++++++++++++++++ 11 files changed, 158 insertions(+), 24 deletions(-) create mode 100644 external/lz4/CMakeLists.txt create mode 100644 external/xxhash/CMakeLists.txt delete mode 100644 force_include.cmake create mode 100644 options_linux.cmake rename paths.cmake => options_mac.cmake (55%) create mode 100644 variables.cmake diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 9adedc7..485adb7 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -9,8 +9,10 @@ add_subdirectory(openssl) add_subdirectory(variant) add_subdirectory(ranges) add_subdirectory(gsl) +add_subdirectory(lz4) add_subdirectory(crash_reports) add_subdirectory(auto_updates) add_subdirectory(zlib) add_subdirectory(opus) add_subdirectory(openal) +add_subdirectory(xxhash) diff --git a/external/lz4/CMakeLists.txt b/external/lz4/CMakeLists.txt new file mode 100644 index 0000000..38330d7 --- /dev/null +++ b/external/lz4/CMakeLists.txt @@ -0,0 +1,28 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + +add_library(external_lz4 OBJECT) +init_target(external_lz4 "(external)") + +set(lz4_loc ${third_party_loc}/lz4/lib) + +target_sources(external_lz4 +PRIVATE + ${lz4_loc}/lz4.c + ${lz4_loc}/lz4.h + ${lz4_loc}/lz4frame.c + ${lz4_loc}/lz4frame.h + ${lz4_loc}/lz4frame_static.h + ${lz4_loc}/lz4hc.c + ${lz4_loc}/lz4hc.h + ${lz4_loc}/xxhash.c + ${lz4_loc}/xxhash.h +) + +target_include_directories(external_lz4 +PUBLIC + ${lz4_loc} +) diff --git a/external/openal/CMakeLists.txt b/external/openal/CMakeLists.txt index b734151..4cf15a6 100644 --- a/external/openal/CMakeLists.txt +++ b/external/openal/CMakeLists.txt @@ -20,3 +20,9 @@ target_link_libraries(external_openal INTERFACE OpenAL32 ) + +target_compile_definitions(external_openal +INTERFACE + AL_LIBTYPE_STATIC + AL_ALEXT_PROTOTYPES +) diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index 96c411c..236b273 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -6,6 +6,14 @@ add_library(external_qt INTERFACE IMPORTED GLOBAL) +if (LINUX) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + target_compile_definitions(external_qt INTERFACE Q_OS_LINUX64) + else() + target_compile_definitions(external_qt INTERFACE Q_OS_LINUX32) + endif() +endif() + target_include_directories(external_qt SYSTEM INTERFACE ${qt_loc}/include @@ -18,6 +26,17 @@ INTERFACE ${qt_loc}/include/QtGui/${qt_version}/QtGui ) +target_compile_definitions(external_qt +INTERFACE + _REENTRANT + QT_STATICPLUGIN + QT_PLUGIN + QT_WIDGETS_LIB + QT_NETWORK_LIB + QT_GUI_LIB + QT_CORE_LIB +) + set(common_qt_libs qwebp qgif diff --git a/external/xxhash/CMakeLists.txt b/external/xxhash/CMakeLists.txt new file mode 100644 index 0000000..bf962a6 --- /dev/null +++ b/external/xxhash/CMakeLists.txt @@ -0,0 +1,17 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + +add_library(external_xxhash INTERFACE IMPORTED GLOBAL) + +target_include_directories(external_xxhash SYSTEM +INTERFACE + ${third_party_loc}/xxHash +) + +target_compile_definitions(external_xxhash +INTERFACE + XXH_INLINE_ALL +) diff --git a/force_include.cmake b/force_include.cmake deleted file mode 100644 index 61ad673..0000000 --- a/force_include.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of Desktop App Toolkit, -# a set of libraries for developing nice desktop applications. -# -# For license and copyright information please follow this link: -# https://github.com/desktop-app/legal/blob/master/LEGAL - -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/options.cmake b/options.cmake index cbd686c..4f5fdfc 100644 --- a/options.cmake +++ b/options.cmake @@ -14,9 +14,23 @@ INTERFACE target_compile_definitions(common_options INTERFACE UNICODE + _UNICODE + $,_DEBUG,NDEBUG> ) +if (DESKTOP_APP_DISABLE_CRASH_REPORTS) + target_compile_definitions(common_options + INTERFACE + DESKTOP_APP_DISABLE_CRASH_REPORTS + ) +endif() + if (WIN32) include(cmake/options_win.cmake) +elseif(APPLE) + include(cmake/options_mac.cmake) +elseif(LINUX) + include(cmake/options_linux.cmake) else() + message(FATAL_ERROR "Unknown platform type") endif() diff --git a/options_linux.cmake b/options_linux.cmake new file mode 100644 index 0000000..eb476a5 --- /dev/null +++ b/options_linux.cmake @@ -0,0 +1,5 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL diff --git a/paths.cmake b/options_mac.cmake similarity index 55% rename from paths.cmake rename to options_mac.cmake index e6dfab1..17300b6 100644 --- a/paths.cmake +++ b/options_mac.cmake @@ -4,6 +4,8 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -get_filename_component(libs_loc "../Libraries" REALPATH) -get_filename_component(third_party_loc "Telegram/ThirdParty" REALPATH) -get_filename_component(submodules_loc "Telegram" REALPATH) +if (build_osx) + target_compile_definitions(common_options INTERFACE OS_OSX) +elseif (build_macstore) + target_compile_definitions(common_options INTERFACE OS_MAC_STORE) +endif() diff --git a/options_win.cmake b/options_win.cmake index 7844cfd..9defb46 100644 --- a/options_win.cmake +++ b/options_win.cmake @@ -8,8 +8,6 @@ target_compile_definitions(common_options INTERFACE WIN32 _WINDOWS - _UNICODE - UNICODE _SCL_SECURE_NO_WARNINGS _USING_V110_SDK71_ NOMINMAX @@ -65,3 +63,7 @@ INTERFACE Rstrtmgr Crypt32 ) + +if (build_uwp) + target_compile_definitions(common_options INTERFACE OS_WIN_STORE) +endif() diff --git a/variables.cmake b/variables.cmake new file mode 100644 index 0000000..d40d80c --- /dev/null +++ b/variables.cmake @@ -0,0 +1,58 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + +get_filename_component(libs_loc "../Libraries" REALPATH) +get_filename_component(third_party_loc "Telegram/ThirdParty" REALPATH) +get_filename_component(submodules_loc "Telegram" REALPATH) + +set(DESKTOP_APP_SPECIAL_TARGET "" CACHE STRING "Use special platform target, like 'mas' for Mac App Store.") +option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." OFF) +option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF) +option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON) + +function(report_bad_special_target) + message(FATAL_ERROR "Bad special target '${DESKTOP_APP_SPECIAL_TARGET}'") +endfunction() + +if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "" + OR DESKTOP_APP_SPECIAL_TARGET STREQUAL "uwp" + OR DESKTOP_APP_SPECIAL_TARGET STREQUAL "mas") + set(disable_autoupdate 1) +endif() + +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12) + +if (WIN32) + if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "uwp") + set(build_uwp 1) + elseif (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "" + AND NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "win") + report_bad_special_target() + endif() +elseif (APPLE) + if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "osx") + set(build_osx 1) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10) + elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "mas") + set(build_macstore 1) + elseif (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "" + AND NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "mac") + report_bad_special_target() + endif() +else() + set(LINUX 1) + if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "linux") + if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + report_bad_special_target() + endif() + elseif (DESKTOP_APP_SPECIAL_TARGET STREQUAL "linux32") + if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4) + report_bad_special_target() + endif() + elseif (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") + report_bad_special_target() + endif() +endif()