Android: improve a bit the "androiddeployqt is not smart and needs help" code

We do that by:
 * Remembering all the generators we're building
 * Linking the dependencies of all those generators against the app

For that to work we do three things:
 * Move the creation of the app target to after the generator targets
   have been created
 * Have a global variable that lists all the created generators
 * Move the find_package of the generator dependencies to the top level
   so it can be used from the mobile app target
remotes/origin/work/aacid/moreecm585defines
Albert Astals Cid 4 years ago
parent d72d3a01a5
commit 5944ce059f
  1. 100
      CMakeLists.txt
  2. 94
      generators/CMakeLists.txt
  3. 19
      mobile/app/CMakeLists.txt

@ -162,12 +162,102 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules)
find_package(ZLIB REQUIRED)
# This is here instead of in generators since we use if(Poppler_Qt5_FOUND) in autotests/
find_package(Poppler "0.86.0" COMPONENTS Qt5)
set_package_properties("Poppler" PROPERTIES
TYPE RECOMMENDED
PURPOSE "Support for PDF files in okular.")
find_package(Freetype)
set_package_properties("FreeType" PROPERTIES
DESCRIPTION "A font rendering engine"
URL "https://www.freetype.org"
TYPE RECOMMENDED
PURPOSE "Provides freetype font support in the okular DVI generator.")
find_package(TIFF)
set_package_properties("libTIFF" PROPERTIES
DESCRIPTION "A library for reading and writing TIFF formatted files,"
URL "http://www.libtiff.org"
TYPE RECOMMENDED
PURPOSE "Support for TIFF files in okular.")
find_package(JPEG)
set_package_properties("JPEG" PROPERTIES
DESCRIPTION "A library for reading and writing JPEG image files."
URL "https://www.ijg.org"
TYPE RECOMMENDED
PURPOSE "Support for PalmDB documents in okular.")
set(LIBSPECTRE_MINIMUM_VERSION "0.2")
find_package(LibSpectre "${LIBSPECTRE_MINIMUM_VERSION}")
set_package_properties(LibSpectre PROPERTIES
DESCRIPTION "A PostScript rendering library"
URL "https://libspectre.freedesktop.org"
TYPE RECOMMENDED
PURPOSE "Support for PS files in okular.")
find_package(KF5KExiv2 CONFIG)
set_package_properties("LibKExiv2" PROPERTIES
DESCRIPTION "Wrapper around Exiv2 library"
URL "https://commits.kde.org/libkexiv2"
TYPE RECOMMENDED
PURPOSE "Support for image files")
find_package(CHM)
set_package_properties("CHM" PROPERTIES
DESCRIPTION "A library for dealing with Microsoft ITSS/CHM format files"
URL "http://www.jedrea.com/chmlib"
TYPE RECOMMENDED
PURPOSE "Support CHM files in okular.")
find_package(KF5KHtml CONFIG)
set_package_properties("KF5KHtml" PROPERTIES
DESCRIPTION "HTML rendering library"
TYPE RECOMMENDED
PURPOSE "Support CHM files in okular.")
find_package(LibZip)
set_package_properties("LibZip" PROPERTIES
DESCRIPTION "A library for reading, creating, and modifying zip archives"
URL "https://libzip.org/"
TYPE RECOMMENDED
PURPOSE "Support CHM files in okular.")
find_package(DjVuLibre "3.5.17")
set_package_properties("DjVuLibre" PROPERTIES
DESCRIPTION "A library for dealing with DjVu formatted files"
URL "https://djvulibre.djvuzone.org"
TYPE RECOMMENDED
PURPOSE "Support for DjVu files in okular.")
find_package(ZLIB)
set_package_properties("ZLib" PROPERTIES
DESCRIPTION "The Zlib compression library"
URL "https://www.zlib.net"
TYPE RECOMMENDED
PURPOSE "Support for Plucker files in Okular.")
find_package(EPub)
set_package_properties("libepub" PROPERTIES
DESCRIPTION "A library for reading EPub documents"
URL "http://sourceforge.net/projects/ebook-tools"
TYPE RECOMMENDED
PURPOSE "Support for EPub documents in Okular.")
find_package(QMobipocket "2" CONFIG)
set_package_properties("libqmobipocket" PROPERTIES
DESCRIPTION "A library for reading Mobipocket documents"
URL "https://commits.kde.org/kdegraphics-mobipocket"
TYPE RECOMMENDED
PURPOSE "Support for Mobipocket documents in Okular.")
find_package(Discount)
set_package_properties("Discount" PROPERTIES
DESCRIPTION "A library that gives you formatting functions suitable for marking down entire documents or lines of text"
URL "https://www.pell.portland.or.us/~orc/Code/discount/"
TYPE RECOMMENDED
PURPOSE "Support for Markdown documents in Okular.")
add_definitions(-DQT_USE_QSTRINGBUILDER)
add_definitions(-DTRANSLATION_DOMAIN="okular")
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
@ -182,9 +272,6 @@ if(BUILD_MOBILE AND KF5Kirigami2_VERSION VERSION_LESS "5.85")
set(BUILD_MOBILE OFF)
endif()
if(BUILD_MOBILE)
add_subdirectory( mobile )
endif()
option(BUILD_COVERAGE "Build the project with gcov support" OFF)
if(BUILD_COVERAGE)
@ -198,6 +285,11 @@ if(BUILD_DESKTOP)
add_subdirectory( shell )
endif()
add_subdirectory( generators )
if(BUILD_MOBILE)
add_subdirectory( mobile )
endif()
if(BUILD_TESTING)
add_subdirectory( autotests )
endif()

@ -6,99 +6,11 @@ function(okular_add_generator _target)
SOURCES ${ARGN}
)
set_target_properties(${_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/plugins/okular")
get_property(aux_list GLOBAL PROPERTY okular_generator_list)
list(APPEND aux_list ${_target})
set_property(GLOBAL PROPERTY okular_generator_list ${aux_list})
endfunction()
set(LIBSPECTRE_MINIMUM_VERSION "0.2")
find_package(LibSpectre "${LIBSPECTRE_MINIMUM_VERSION}")
set_package_properties(LibSpectre PROPERTIES
DESCRIPTION "A PostScript rendering library"
URL "https://libspectre.freedesktop.org"
TYPE RECOMMENDED
PURPOSE "Support for PS files in okular.")
find_package(KF5KExiv2 CONFIG)
set_package_properties("LibKExiv2" PROPERTIES
DESCRIPTION "Wrapper around Exiv2 library"
URL "https://commits.kde.org/libkexiv2"
TYPE RECOMMENDED
PURPOSE "Support for image files")
find_package(CHM)
set_package_properties("CHM" PROPERTIES
DESCRIPTION "A library for dealing with Microsoft ITSS/CHM format files"
URL "http://www.jedrea.com/chmlib"
TYPE RECOMMENDED
PURPOSE "Support CHM files in okular.")
find_package(KF5KHtml CONFIG)
set_package_properties("KF5KHtml" PROPERTIES
DESCRIPTION "HTML rendering library"
TYPE RECOMMENDED
PURPOSE "Support CHM files in okular.")
find_package(LibZip)
set_package_properties("LibZip" PROPERTIES
DESCRIPTION "A library for reading, creating, and modifying zip archives"
URL "https://libzip.org/"
TYPE RECOMMENDED
PURPOSE "Support CHM files in okular.")
find_package(DjVuLibre "3.5.17")
set_package_properties("DjVuLibre" PROPERTIES
DESCRIPTION "A library for dealing with DjVu formatted files"
URL "https://djvulibre.djvuzone.org"
TYPE RECOMMENDED
PURPOSE "Support for DjVu files in okular.")
find_package(TIFF)
set_package_properties("libTIFF" PROPERTIES
DESCRIPTION "A library for reading and writing TIFF formatted files,"
URL "http://www.libtiff.org"
TYPE RECOMMENDED
PURPOSE "Support for TIFF files in okular.")
find_package(Freetype)
set_package_properties("FreeType" PROPERTIES
DESCRIPTION "A font rendering engine"
URL "https://www.freetype.org"
TYPE RECOMMENDED
PURPOSE "Provides freetype font support in the okular DVI generator.")
find_package(JPEG)
set_package_properties("JPEG" PROPERTIES
DESCRIPTION "A library for reading and writing JPEG image files."
URL "https://www.ijg.org"
TYPE RECOMMENDED
PURPOSE "Support for PalmDB documents in okular.")
find_package(ZLIB)
set_package_properties("ZLib" PROPERTIES
DESCRIPTION "The Zlib compression library"
URL "https://www.zlib.net"
TYPE RECOMMENDED
PURPOSE "Support for Plucker files in Okular.")
find_package(EPub)
set_package_properties("libepub" PROPERTIES
DESCRIPTION "A library for reading EPub documents"
URL "http://sourceforge.net/projects/ebook-tools"
TYPE RECOMMENDED
PURPOSE "Support for EPub documents in Okular.")
find_package(QMobipocket "2" CONFIG)
set_package_properties("libqmobipocket" PROPERTIES
DESCRIPTION "A library for reading Mobipocket documents"
URL "https://commits.kde.org/kdegraphics-mobipocket"
TYPE RECOMMENDED
PURPOSE "Support for Mobipocket documents in Okular.")
find_package(Discount)
set_package_properties("Discount" PROPERTIES
DESCRIPTION "A library that gives you formatting functions suitable for marking down entire documents or lines of text"
URL "https://www.pell.portland.or.us/~orc/Code/discount/"
TYPE RECOMMENDED
PURPOSE "Support for Markdown documents in Okular.")
# let's enable the generators properly configured
if(Poppler_Qt5_FOUND)

@ -11,16 +11,23 @@ if (ANDROID)
target_sources(okularkirigami PRIVATE android.cpp)
target_link_libraries(okularkirigami Qt5::AndroidExtras)
# androiddeployqt only packages libraries needed by the main binary.
# That is problematic because some of the libraries we need we only use in plugins
# here we help androiddeployqt by linking those plugins dependencies
# to the app.
get_property(aux_list GLOBAL PROPERTY okular_generator_list)
foreach(okular_generator ${aux_list})
get_target_property(okular_generator_dependencies ${okular_generator} LINK_LIBRARIES)
target_link_libraries(okularkirigami ${okular_generator_dependencies})
endforeach()
# Unfortunately gitlab CI for now doesn't use Craft so we need
# to differentiate between gitlab CI and the binary factory
if (ANDROID_LINK_EXTRA_LIBRARIES)
message("Linking in extra libraries to help androiddeployqt")
# androiddeployqt is not super smart and sometimes fails packaging
# some of the libraries we only use in plugins, here we help it by linking to those "extra" libs
# that are not really needed
# The Okular PDF plugin needs poppler
target_link_libraries(okularkirigami Poppler::Qt5)
# Poppler in turn needs NSS which needs this plugins
# androiddeployqt only packages libraries needed by the main binary.
# the pdf/poppler generator links to poppler that links to NSS
# and NSS has plugins. Here we link to those plugins so they get packaged
pkg_check_modules(NSS "nss")
target_link_directories(okularkirigami PRIVATE ${NSS_LIBRARY_DIRS})
target_link_libraries(okularkirigami -lsoftokn3 -lnssckbi -lfreebl3)

Loading…
Cancel
Save