1
0
Fork 0

Get rid of USE_PACKAGED options by automatic fallback

This commit is contained in:
Ilya Fedin 2020-08-07 12:55:16 +04:00 committed by John Preston
parent 2d8bd57e22
commit 2d6b9aeab5
13 changed files with 210 additions and 124 deletions

View file

@ -4,16 +4,24 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
add_library(external_dbusmenu_qt INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_dbusmenu_qt ALIAS external_dbusmenu_qt)
add_library(external_dbusmenu_qt INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_dbusmenu_qt ALIAS external_dbusmenu_qt)
find_package(dbusmenu-qt5 REQUIRED)
target_link_libraries(external_dbusmenu_qt INTERFACE dbusmenu-qt5)
else()
add_library(external_dbusmenu_qt STATIC)
add_library(desktop-app::external_dbusmenu_qt ALIAS external_dbusmenu_qt)
init_target(external_dbusmenu_qt "(external)")
if (DESKTOP_APP_USE_PACKAGED)
if (DESKTOP_APP_USE_PACKAGED_LAZY)
find_package(dbusmenu-qt5 QUIET)
else()
find_package(dbusmenu-qt5)
endif()
if (dbusmenu-qt5_FOUND)
target_link_libraries(external_dbusmenu_qt INTERFACE dbusmenu-qt5)
endif()
endif()
if (NOT dbusmenu-qt5_FOUND)
add_library(external_dbusmenu_qt_bundled STATIC)
init_target(external_dbusmenu_qt_bundled "(external)")
set(dbusmenu_qt_VERSION_MAJOR 0)
set(dbusmenu_qt_VERSION_MINOR 9)
@ -21,7 +29,7 @@ else()
set(dbusmenu_qt_loc ${third_party_loc}/libdbusmenu-qt/src)
set_target_properties(external_dbusmenu_qt PROPERTIES AUTOMOC ON)
set_target_properties(external_dbusmenu_qt_bundled PROPERTIES AUTOMOC ON)
# QIcon::name was introduced in Qt 4.7.
set(HAVE_QICON_NAME ON)
@ -29,7 +37,7 @@ else()
configure_file(${dbusmenu_qt_loc}/dbusmenu_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/dbusmenu_config.h" @ONLY)
configure_file(${dbusmenu_qt_loc}/dbusmenu_version.h.in "${CMAKE_CURRENT_BINARY_DIR}/dbusmenu_version.h")
nice_target_sources(external_dbusmenu_qt ${dbusmenu_qt_loc}
nice_target_sources(external_dbusmenu_qt_bundled ${dbusmenu_qt_loc}
PRIVATE
dbusmenu_p.cpp
dbusmenuexporter.cpp
@ -46,16 +54,21 @@ else()
DBusMenuExporterDBus
)
target_sources(external_dbusmenu_qt PRIVATE ${dbusmenu_adaptor})
target_sources(external_dbusmenu_qt_bundled PRIVATE ${dbusmenu_adaptor})
target_include_directories(external_dbusmenu_qt
target_include_directories(external_dbusmenu_qt_bundled
PUBLIC
${dbusmenu_qt_loc}
"${CMAKE_CURRENT_BINARY_DIR}"
)
target_link_libraries(external_dbusmenu_qt
target_link_libraries(external_dbusmenu_qt_bundled
PRIVATE
desktop-app::external_qt
)
target_link_libraries(external_dbusmenu_qt
INTERFACE
external_dbusmenu_qt_bundled
)
endif()

View file

@ -7,10 +7,19 @@
add_library(external_expected INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_expected ALIAS external_expected)
if (DESKTOP_APP_USE_PACKAGED_EXPECTED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
find_package(tl-expected CONFIG REQUIRED)
target_link_libraries(external_expected INTERFACE tl::expected)
else()
if (DESKTOP_APP_USE_PACKAGED)
if (DESKTOP_APP_USE_PACKAGED_LAZY)
find_package(tl-expected QUIET)
else()
find_package(tl-expected)
endif()
if (tl-expected_FOUND)
target_link_libraries(external_expected INTERFACE tl::expected)
endif()
endif()
if (NOT tl-expected_FOUND)
target_include_directories(external_expected SYSTEM
INTERFACE
${third_party_loc}/expected/include

View file

@ -7,10 +7,19 @@
add_library(external_gsl INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_gsl ALIAS external_gsl)
if (DESKTOP_APP_USE_PACKAGED_GSL AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
find_package(Microsoft.GSL CONFIG REQUIRED)
target_link_libraries(external_gsl INTERFACE Microsoft.GSL::GSL)
else()
if (DESKTOP_APP_USE_PACKAGED)
if (DESKTOP_APP_USE_PACKAGED_LAZY)
find_package(Microsoft.GSL QUIET)
else()
find_package(Microsoft.GSL)
endif()
if (Microsoft.GSL_FOUND)
target_link_libraries(external_gsl INTERFACE Microsoft.GSL::GSL)
endif()
endif()
if(NOT Microsoft.GSL_FOUND)
target_include_directories(external_gsl SYSTEM
INTERFACE
${third_party_loc}/GSL/include

View file

@ -4,23 +4,26 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
add_library(external_hunspell INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_hunspell ALIAS external_hunspell)
add_library(external_hunspell INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_hunspell ALIAS external_hunspell)
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(HUNSPELL REQUIRED IMPORTED_TARGET hunspell)
pkg_check_modules(HUNSPELL IMPORTED_TARGET hunspell)
target_link_libraries(external_hunspell INTERFACE PkgConfig::HUNSPELL)
else()
add_library(external_hunspell STATIC)
add_library(desktop-app::external_hunspell ALIAS external_hunspell)
init_target(external_hunspell "(external)")
if (HUNSPELL_FOUND)
target_link_libraries(external_hunspell INTERFACE PkgConfig::HUNSPELL)
endif()
endif()
if (NOT HUNSPELL_FOUND)
add_library(external_hunspell_bundled STATIC)
init_target(external_hunspell_bundled "(external)")
set(hunspell_loc ${third_party_loc}/hunspell)
set(hunspell_src ${hunspell_loc}/src)
nice_target_sources(external_hunspell ${hunspell_src}
nice_target_sources(external_hunspell_bundled ${hunspell_src}
PRIVATE
hunspell/affentry.cxx
hunspell/affentry.hxx
@ -50,14 +53,19 @@ else()
hunspell/utf_info.hxx
)
target_include_directories(external_hunspell
target_include_directories(external_hunspell_bundled
PUBLIC
${hunspell_src}
)
target_compile_definitions(external_hunspell
target_compile_definitions(external_hunspell_bundled
PUBLIC
HUNSPELL_STATIC
MAXSUGGESTION=5
)
target_link_libraries(external_hunspell
INTERFACE
external_hunspell_bundled
)
endif()

View file

@ -4,22 +4,25 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
add_library(external_lz4 INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_lz4 ALIAS external_lz4)
add_library(external_lz4 INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_lz4 ALIAS external_lz4)
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LZ4 IMPORTED_TARGET liblz4)
target_link_libraries(external_lz4 INTERFACE PkgConfig::LZ4)
else()
add_library(external_lz4 STATIC)
add_library(desktop-app::external_lz4 ALIAS external_lz4)
init_target(external_lz4 "(external)")
if (LZ4_FOUND)
target_link_libraries(external_lz4 INTERFACE PkgConfig::LZ4)
endif()
endif()
if (NOT LZ4_FOUND)
add_library(external_lz4_bundled STATIC)
init_target(external_lz4_bundled "(external)")
set(lz4_loc ${third_party_loc}/lz4/lib)
target_sources(external_lz4
target_sources(external_lz4_bundled
PRIVATE
${lz4_loc}/lz4.c
${lz4_loc}/lz4.h
@ -32,8 +35,13 @@ else()
${lz4_loc}/xxhash.h
)
target_include_directories(external_lz4
target_include_directories(external_lz4_bundled
PUBLIC
${lz4_loc}
)
target_link_libraries(external_lz4
INTERFACE
external_lz4_bundled
)
endif()

View file

@ -7,37 +7,46 @@
add_library(external_minizip INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_minizip ALIAS external_minizip)
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(MINIZIP REQUIRED IMPORTED_TARGET minizip)
pkg_check_modules(MINIZIP IMPORTED_TARGET minizip)
target_link_libraries(external_minizip INTERFACE PkgConfig::MINIZIP)
elseif (NOT WIN32 OR DESKTOP_APP_USE_PACKAGED_LAZY)
add_library(external_minizip_bundled STATIC)
init_target(external_minizip_bundled "(external)")
set(minizip_loc ${third_party_loc}/minizip)
target_sources(external_minizip_bundled
PRIVATE
${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
)
target_include_directories(external_minizip_bundled SYSTEM
PUBLIC
${minizip_loc}
)
target_link_libraries(external_minizip INTERFACE external_minizip_bundled)
else()
target_include_directories(external_minizip SYSTEM
INTERFACE
${libs_loc}/zlib/contrib/minizip
)
if (MINIZIP_FOUND)
target_link_libraries(external_minizip INTERFACE PkgConfig::MINIZIP)
endif()
endif()
if (NOT MINIZIP_FOUND)
if (NOT WIN32)
add_library(external_minizip_bundled STATIC)
init_target(external_minizip_bundled "(external)")
set(minizip_loc ${third_party_loc}/minizip)
target_sources(external_minizip_bundled
PRIVATE
${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
)
target_include_directories(external_minizip_bundled SYSTEM
PUBLIC
${minizip_loc}
)
target_link_libraries(external_minizip
INTERFACE
external_minizip_bundled
)
else()
target_include_directories(external_minizip SYSTEM
INTERFACE
${libs_loc}/zlib/contrib/minizip
)
endif()
endif()

View file

@ -4,24 +4,27 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED_QRCODE AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
add_library(external_qr_code_generator INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_qr_code_generator ALIAS external_qr_code_generator)
add_library(external_qr_code_generator INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_qr_code_generator ALIAS external_qr_code_generator)
if (DESKTOP_APP_USE_PACKAGED)
find_library(QRCODE_LIBRARIES NAMES qrcodegencpp)
find_path(QRCODE_INCLUDE_DIRS QrCode.hpp PATH_SUFFIXES qrcodegencpp qrcodegen)
target_include_directories(external_qr_code_generator INTERFACE ${QRCODE_INCLUDE_DIRS})
target_link_libraries(external_qr_code_generator INTERFACE ${QRCODE_LIBRARIES})
else()
add_library(external_qr_code_generator STATIC)
add_library(desktop-app::external_qr_code_generator ALIAS external_qr_code_generator)
init_target(external_qr_code_generator "(external)")
if (QRCODE_LIBRARIES AND QRCODE_INCLUDE_DIRS)
target_include_directories(external_qr_code_generator INTERFACE ${QRCODE_INCLUDE_DIRS})
target_link_libraries(external_qr_code_generator INTERFACE ${QRCODE_LIBRARIES})
endif()
endif()
if (NOT QRCODE_LIBRARIES OR NOT QRCODE_INCLUDE_DIRS)
add_library(external_qr_code_generator_bundled STATIC)
init_target(external_qr_code_generator_bundled "(external)")
set(qr_loc ${third_party_loc}/QR)
set(qr_src ${qr_loc}/cpp)
nice_target_sources(external_qr_code_generator ${qr_src}
nice_target_sources(external_qr_code_generator_bundled ${qr_src}
PRIVATE
BitBuffer.cpp
BitBuffer.hpp
@ -31,8 +34,13 @@ else()
QrSegment.hpp
)
target_include_directories(external_qr_code_generator
target_include_directories(external_qr_code_generator_bundled
PUBLIC
${qr_src}
)
target_link_libraries(external_qr_code_generator
INTERFACE
external_qr_code_generator_bundled
)
endif()

View file

@ -7,10 +7,19 @@
add_library(external_ranges INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_ranges ALIAS external_ranges)
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
find_package(range-v3 REQUIRED)
target_link_libraries(external_ranges INTERFACE range-v3::range-v3)
else()
if (DESKTOP_APP_USE_PACKAGED)
if (DESKTOP_APP_USE_PACKAGED_LAZY)
find_package(range-v3 QUIET)
else()
find_package(range-v3)
endif()
if (range-v3_FOUND)
target_link_libraries(external_ranges INTERFACE range-v3::range-v3)
endif()
endif()
if (NOT range-v3_FOUND)
target_include_directories(external_ranges SYSTEM
INTERFACE
${third_party_loc}/range-v3/include

View file

@ -4,28 +4,33 @@
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED_RLOTTIE AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
add_library(external_rlottie INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_rlottie ALIAS external_rlottie)
add_library(external_rlottie INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_rlottie ALIAS external_rlottie)
if (DESKTOP_APP_USE_PACKAGED)
find_package(rlottie QUIET)
find_package(rlottie)
if (rlottie_FOUND)
target_link_libraries(external_rlottie INTERFACE rlottie::rlottie)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(RLOTTIE REQUIRED IMPORTED_TARGET rlottie)
target_link_libraries(external_rlottie INTERFACE PkgConfig::RLOTTIE)
pkg_check_modules(RLOTTIE IMPORTED_TARGET rlottie)
if (RLOTTIE_FOUND)
target_link_libraries(external_rlottie INTERFACE PkgConfig::RLOTTIE)
endif()
endif()
else()
add_library(external_rlottie STATIC)
add_library(desktop-app::external_rlottie ALIAS external_rlottie)
init_target(external_rlottie "(external)")
endif()
if (NOT rlottie_FOUND AND NOT RLOTTIE_FOUND)
add_library(external_rlottie_bundled STATIC)
init_target(external_rlottie_bundled "(external)")
get_filename_component(src_loc . REALPATH)
set(rlottie_loc ${third_party_loc}/rlottie)
target_sources(external_rlottie PRIVATE ${src_loc}/config/config.h)
nice_target_sources(external_rlottie ${rlottie_loc}
target_sources(external_rlottie_bundled PRIVATE ${src_loc}/config/config.h)
nice_target_sources(external_rlottie_bundled ${rlottie_loc}
PRIVATE
inc/rlottie.h
inc/rlottie_capi.h
@ -103,7 +108,7 @@ else()
src/vector/vtaskqueue.h
)
target_compile_definitions(external_rlottie
target_compile_definitions(external_rlottie_bundled
PUBLIC
LOT_BUILD
PRIVATE
@ -111,7 +116,7 @@ else()
"RAPIDJSON_ASSERT=(void)"
)
target_include_directories(external_rlottie
target_include_directories(external_rlottie_bundled
PUBLIC
${rlottie_loc}/inc
PRIVATE
@ -123,17 +128,22 @@ else()
)
if (LINUX)
target_link_libraries(external_rlottie
target_link_libraries(external_rlottie_bundled
PRIVATE
pthread
)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(external_rlottie
target_compile_options(external_rlottie_bundled
PRIVATE
/w44244 # 'initializing': conversion from 'double' to 'float'
/w44251 # needs to have dll-interface to be used by clients of class
)
endif()
target_link_libraries(external_rlottie
INTERFACE
external_rlottie_bundled
)
endif()

View file

@ -7,12 +7,11 @@
add_library(external_variant INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_variant ALIAS external_variant)
if (DESKTOP_APP_USE_PACKAGED_VARIANT AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
if (DESKTOP_APP_USE_PACKAGED)
find_path(VARIANT_INCLUDE_DIRS mapbox/variant.hpp)
if (NOT VARIANT_INCLUDE_DIRS)
message(FATAL_ERROR "Packaged version of mapbox-variant library not found!")
endif()
else()
endif()
if (NOT VARIANT_INCLUDE_DIRS)
target_include_directories(external_variant SYSTEM
INTERFACE
${third_party_loc}/variant/include

View file

@ -7,13 +7,17 @@
add_library(external_xxhash INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_xxhash ALIAS external_xxhash)
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
if (DESKTOP_APP_USE_PACKAGED)
find_library(XXHASH_LIBRARY xxhash)
find_path(XXHASH_INCLUDE_DIRS xxhash.h)
target_include_directories(external_xxhash INTERFACE ${XXHASH_INCLUDE_DIRS})
target_link_libraries(external_xxhash INTERFACE ${XXHASH_LIBRARY})
else()
if (XXHASH_LIBRARY AND XXHASH_INCLUDE_DIRS)
target_include_directories(external_xxhash INTERFACE ${XXHASH_INCLUDE_DIRS})
target_link_libraries(external_xxhash INTERFACE ${XXHASH_LIBRARY})
endif()
endif()
if (NOT XXHASH_LIBRARY OR NOT XXHASH_INCLUDE_DIRS)
target_include_directories(external_xxhash SYSTEM
INTERFACE
${third_party_loc}/xxHash

View file

@ -54,7 +54,7 @@ if (DESKTOP_APP_USE_PACKAGED_FONTS)
)
endif()
if (DESKTOP_APP_USE_PACKAGED_RLOTTIE)
if (rlottie_FOUND OR RLOTTIE_FOUND)
target_compile_definitions(common_options
INTERFACE
DESKTOP_APP_USE_PACKAGED_RLOTTIE

View file

@ -23,17 +23,11 @@ option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON)
option(DESKTOP_APP_DISABLE_DBUS_INTEGRATION "Disable all code for D-Bus integration (Linux only)." OFF)
option(DESKTOP_APP_USE_GLIBC_WRAPS "Use wraps for new GLIBC features." ${linux_special_target})
option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." ${no_special_target})
option(DESKTOP_APP_USE_PACKAGED_LAZY "Find libraries that aren't in ThirdParty directory using CMake instead of exact paths." OFF)
option(DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES "Include platform themes into lazy packaged build. (Linux only)" ${DESKTOP_APP_USE_PACKAGED_LAZY})
option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages. (Linux only)" OFF)
option(DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES "Bundle recommended Qt platform themes for self-contained packages. (Linux only)" ${DESKTOP_APP_USE_PACKAGED_LAZY})
option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." ${osx_special_target})
option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${DESKTOP_APP_USE_PACKAGED})
option(DESKTOP_APP_USE_PACKAGED_RLOTTIE "Find rlottie using CMake instead of bundled one." ${DESKTOP_APP_USE_PACKAGED})
option(DESKTOP_APP_USE_PACKAGED_EXPECTED "Find expected using CMake instead of bundled one." ${DESKTOP_APP_USE_PACKAGED})
option(DESKTOP_APP_USE_PACKAGED_VARIANT "Find mapbox-variant using CMake instead of bundled one." ${DESKTOP_APP_USE_PACKAGED})
option(DESKTOP_APP_USE_PACKAGED_GSL "Find GSL using CMake instead of bundled one." ${DESKTOP_APP_USE_PACKAGED})
option(DESKTOP_APP_USE_PACKAGED_QRCODE "Find qr-code-generator library using CMake instead of bundled one." OFF)
option(DESKTOP_APP_USE_PACKAGED_FFMPEG_STATIC "Link found ffmpeg statically." OFF)
option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled one." ${DESKTOP_APP_USE_PACKAGED})
option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)
option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF)
@ -51,6 +45,12 @@ if (DESKTOP_APP_SPECIAL_TARGET STREQUAL ""
endif()
option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate})
set(dont_bundle_fonts 0)
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
set(dont_bundle_fonts 1)
endif()
option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled one." ${dont_bundle_fonts})
set(add_hunspell_library 0)
if ((WIN32
OR (LINUX AND NOT DESKTOP_APP_USE_ENCHANT)