mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Improve backends handling and make DECOMPRESSION_BACKEND and PDF_BACKEND settings easier to discover
This commit is contained in:
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -80,6 +80,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cmake -B build \
|
cmake -B build \
|
||||||
-DDECOMPRESSION_BACKEND=unarr \
|
-DDECOMPRESSION_BACKEND=unarr \
|
||||||
|
-DPDF_BACKEND=poppler \
|
||||||
-DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" \
|
-DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" \
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build build --parallel 2
|
cmake --build build --parallel 2
|
||||||
@ -113,6 +114,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cmake -B build \
|
cmake -B build \
|
||||||
-DDECOMPRESSION_BACKEND=7zip \
|
-DDECOMPRESSION_BACKEND=7zip \
|
||||||
|
-DPDF_BACKEND=poppler \
|
||||||
-DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" \
|
-DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" \
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build build --parallel 2
|
cmake --build build --parallel 2
|
||||||
@ -201,7 +203,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
set PATH=C:\Qt\6.9.3\msvc2022_64\bin;%PATH%
|
set PATH=C:\Qt\6.9.3\msvc2022_64\bin;%PATH%
|
||||||
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DDECOMPRESSION_BACKEND=7zip -DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.3\msvc2022_64
|
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DDECOMPRESSION_BACKEND=7zip -DPDF_BACKEND=pdfium -DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.3\msvc2022_64
|
||||||
cmake --build build --parallel
|
cmake --build build --parallel
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
@ -346,7 +348,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64_arm64
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64_arm64
|
||||||
set PATH=C:\Qt\6.9.3\msvc2022_arm64\bin;%PATH%
|
set PATH=C:\Qt\6.9.3\msvc2022_arm64\bin;%PATH%
|
||||||
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DDECOMPRESSION_BACKEND=7zip -DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.3\msvc2022_arm64 -DQT_HOST_PATH=C:\Qt\6.9.3\msvc2022_64 -DCMAKE_SYSTEM_PROCESSOR=ARM64
|
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DDECOMPRESSION_BACKEND=7zip -DPDF_BACKEND=pdfium -DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.3\msvc2022_arm64 -DQT_HOST_PATH=C:\Qt\6.9.3\msvc2022_64 -DCMAKE_SYSTEM_PROCESSOR=ARM64
|
||||||
cmake --build build --parallel
|
cmake --build build --parallel
|
||||||
|
|
||||||
- name: Upload executables for signing
|
- name: Upload executables for signing
|
||||||
|
|||||||
@ -30,21 +30,13 @@ endif()
|
|||||||
|
|
||||||
# Install paths
|
# Install paths
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
find_package(PkgConfig)
|
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
# Compiler options (MSVC flags, NOMINMAX, etc.)
|
# Compiler options (MSVC flags, NOMINMAX, etc.)
|
||||||
include(cmake/CompilerOptions.cmake)
|
include(cmake/CompilerOptions.cmake)
|
||||||
|
|
||||||
# --- Build options ---
|
# --- Build options ---
|
||||||
|
|
||||||
# Archive decompression backend (mutually exclusive)
|
|
||||||
set(DECOMPRESSION_BACKEND "" CACHE STRING "Archive backend: unarr | 7zip | libarchive")
|
|
||||||
set_property(CACHE DECOMPRESSION_BACKEND PROPERTY STRINGS "unarr" "7zip" "libarchive")
|
|
||||||
|
|
||||||
# PDF rendering backend (mutually exclusive)
|
|
||||||
set(PDF_BACKEND "" CACHE STRING "PDF backend: pdfium | poppler | pdfkit | no_pdf")
|
|
||||||
set_property(CACHE PDF_BACKEND PROPERTY STRINGS "pdfium" "poppler" "pdfkit" "no_pdf")
|
|
||||||
|
|
||||||
# Build configuration
|
# Build configuration
|
||||||
option(BUILD_TESTS "Build tests" ON)
|
option(BUILD_TESTS "Build tests" ON)
|
||||||
option(BUILD_SERVER_STANDALONE "Server standalone install (Linux only)" OFF)
|
option(BUILD_SERVER_STANDALONE "Server standalone install (Linux only)" OFF)
|
||||||
@ -52,25 +44,63 @@ option(BUILD_SERVER_STANDALONE "Server standalone install (Linux only)" OFF)
|
|||||||
# Build number (set by CI)
|
# Build number (set by CI)
|
||||||
set(BUILD_NUMBER "" CACHE STRING "CI build number")
|
set(BUILD_NUMBER "" CACHE STRING "CI build number")
|
||||||
|
|
||||||
|
set(YACREADER_DECOMPRESSION_BACKENDS unarr 7zip libarchive)
|
||||||
|
set(YACREADER_PDF_BACKENDS pdfium poppler pdfkit no_pdf)
|
||||||
|
|
||||||
# --- Platform defaults (mirrors config.pri) ---
|
# --- Platform defaults (mirrors config.pri) ---
|
||||||
if(NOT DECOMPRESSION_BACKEND OR DECOMPRESSION_BACKEND STREQUAL "")
|
if(UNIX AND NOT APPLE)
|
||||||
if(UNIX AND NOT APPLE)
|
set(_default_decompression_backend "unarr")
|
||||||
set(DECOMPRESSION_BACKEND "unarr")
|
set(_default_pdf_backend "poppler")
|
||||||
else()
|
elseif(APPLE)
|
||||||
set(DECOMPRESSION_BACKEND "7zip")
|
set(_default_decompression_backend "7zip")
|
||||||
endif()
|
set(_default_pdf_backend "pdfkit")
|
||||||
message(STATUS "DECOMPRESSION_BACKEND defaulted to: ${DECOMPRESSION_BACKEND}")
|
else()
|
||||||
|
set(_default_decompression_backend "7zip")
|
||||||
|
set(_default_pdf_backend "pdfium")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT PDF_BACKEND OR PDF_BACKEND STREQUAL "")
|
# Archive decompression backend (mutually exclusive)
|
||||||
if(UNIX AND NOT APPLE)
|
set(_decompression_backend_value "")
|
||||||
set(PDF_BACKEND "poppler")
|
if(DEFINED CACHE{DECOMPRESSION_BACKEND})
|
||||||
elseif(APPLE)
|
set(_decompression_backend_value "$CACHE{DECOMPRESSION_BACKEND}")
|
||||||
set(PDF_BACKEND "pdfkit")
|
endif()
|
||||||
else()
|
if(_decompression_backend_value STREQUAL "")
|
||||||
set(PDF_BACKEND "pdfium")
|
set(_decompression_backend_value "${_default_decompression_backend}")
|
||||||
endif()
|
string(JOIN ", " _available_decompression_backends ${YACREADER_DECOMPRESSION_BACKENDS})
|
||||||
message(STATUS "PDF_BACKEND defaulted to: ${PDF_BACKEND}")
|
message(STATUS
|
||||||
|
"DECOMPRESSION_BACKEND not set, defaulting to ${_decompression_backend_value}. "
|
||||||
|
"Available: ${_available_decompression_backends}.")
|
||||||
|
endif()
|
||||||
|
set(DECOMPRESSION_BACKEND "${_decompression_backend_value}" CACHE STRING
|
||||||
|
"Archive backend: unarr | 7zip | libarchive" FORCE)
|
||||||
|
set_property(CACHE DECOMPRESSION_BACKEND PROPERTY STRINGS ${YACREADER_DECOMPRESSION_BACKENDS})
|
||||||
|
if(NOT DECOMPRESSION_BACKEND IN_LIST YACREADER_DECOMPRESSION_BACKENDS)
|
||||||
|
string(JOIN ", " _valid_decompression_backends ${YACREADER_DECOMPRESSION_BACKENDS})
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Unknown DECOMPRESSION_BACKEND: '${DECOMPRESSION_BACKEND}'. "
|
||||||
|
"Use one of: ${_valid_decompression_backends}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# PDF rendering backend (mutually exclusive)
|
||||||
|
set(_pdf_backend_value "")
|
||||||
|
if(DEFINED CACHE{PDF_BACKEND})
|
||||||
|
set(_pdf_backend_value "$CACHE{PDF_BACKEND}")
|
||||||
|
endif()
|
||||||
|
if(_pdf_backend_value STREQUAL "")
|
||||||
|
set(_pdf_backend_value "${_default_pdf_backend}")
|
||||||
|
string(JOIN ", " _available_pdf_backends ${YACREADER_PDF_BACKENDS})
|
||||||
|
message(STATUS
|
||||||
|
"PDF_BACKEND not set, defaulting to ${_pdf_backend_value}. "
|
||||||
|
"Available: ${_available_pdf_backends}.")
|
||||||
|
endif()
|
||||||
|
set(PDF_BACKEND "${_pdf_backend_value}" CACHE STRING
|
||||||
|
"PDF backend: pdfium | poppler | pdfkit | no_pdf" FORCE)
|
||||||
|
set_property(CACHE PDF_BACKEND PROPERTY STRINGS ${YACREADER_PDF_BACKENDS})
|
||||||
|
if(NOT PDF_BACKEND IN_LIST YACREADER_PDF_BACKENDS)
|
||||||
|
string(JOIN ", " _valid_pdf_backends ${YACREADER_PDF_BACKENDS})
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Unknown PDF_BACKEND: '${PDF_BACKEND}'. "
|
||||||
|
"Use one of: ${_valid_pdf_backends}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# macOS universal binary default
|
# macOS universal binary default
|
||||||
@ -114,7 +144,7 @@ endif()
|
|||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
|
|
||||||
# PDF backend detection (creates pdf_backend_iface INTERFACE target)
|
# PDF backend detection (creates pdf_backend_iface INTERFACE target)
|
||||||
include(cmake/PdfBackend.cmake)
|
include(PdfBackend)
|
||||||
|
|
||||||
# Output directory
|
# Output directory
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
|||||||
44
cmake/BackendHelpers.cmake
Normal file
44
cmake/BackendHelpers.cmake
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
|
function(yacreader_get_windows_arch_subdir out_var)
|
||||||
|
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64" OR CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64")
|
||||||
|
set(_arch "arm64")
|
||||||
|
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
set(_arch "x86")
|
||||||
|
else()
|
||||||
|
set(_arch "x64")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${out_var} "${_arch}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(yacreader_add_imported_library target_name)
|
||||||
|
set(options)
|
||||||
|
set(oneValueArgs TYPE LOCATION IMPORTED_IMPLIB INCLUDE_DIR)
|
||||||
|
set(multiValueArgs LINK_LIBRARIES)
|
||||||
|
cmake_parse_arguments(YR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT YR_TYPE)
|
||||||
|
set(YR_TYPE UNKNOWN)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT TARGET "${target_name}")
|
||||||
|
add_library("${target_name}" ${YR_TYPE} IMPORTED GLOBAL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(YR_LOCATION)
|
||||||
|
set_property(TARGET "${target_name}" PROPERTY IMPORTED_LOCATION "${YR_LOCATION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(YR_IMPORTED_IMPLIB)
|
||||||
|
set_property(TARGET "${target_name}" PROPERTY IMPORTED_IMPLIB "${YR_IMPORTED_IMPLIB}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(YR_INCLUDE_DIR)
|
||||||
|
set_property(TARGET "${target_name}" PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${YR_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(YR_LINK_LIBRARIES)
|
||||||
|
set_property(TARGET "${target_name}" PROPERTY INTERFACE_LINK_LIBRARIES "${YR_LINK_LIBRARIES}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
@ -2,6 +2,8 @@
|
|||||||
# Creates an INTERFACE target 'pdf_backend_iface' that propagates
|
# Creates an INTERFACE target 'pdf_backend_iface' that propagates
|
||||||
# compile definitions and link libraries based on PDF_BACKEND.
|
# compile definitions and link libraries based on PDF_BACKEND.
|
||||||
|
|
||||||
|
include(BackendHelpers)
|
||||||
|
|
||||||
add_library(pdf_backend_iface INTERFACE)
|
add_library(pdf_backend_iface INTERFACE)
|
||||||
|
|
||||||
if(PDF_BACKEND STREQUAL "no_pdf")
|
if(PDF_BACKEND STREQUAL "no_pdf")
|
||||||
@ -12,37 +14,64 @@ elseif(PDF_BACKEND STREQUAL "pdfium")
|
|||||||
message(STATUS "PDF backend: pdfium")
|
message(STATUS "PDF backend: pdfium")
|
||||||
target_compile_definitions(pdf_backend_iface INTERFACE USE_PDFIUM)
|
target_compile_definitions(pdf_backend_iface INTERFACE USE_PDFIUM)
|
||||||
|
|
||||||
if(MSVC)
|
if(WIN32)
|
||||||
target_include_directories(pdf_backend_iface INTERFACE
|
yacreader_get_windows_arch_subdir(_pdfium_arch)
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/public")
|
set(_pdfium_include_dir "${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/public")
|
||||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64" OR CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64")
|
set(_pdfium_implib "${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/${_pdfium_arch}/pdfium.lib")
|
||||||
target_link_directories(pdf_backend_iface INTERFACE
|
set(_pdfium_dll "${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/${_pdfium_arch}/pdfium.dll")
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/arm64")
|
if(NOT EXISTS "${_pdfium_include_dir}/fpdfview.h"
|
||||||
else()
|
OR NOT EXISTS "${_pdfium_implib}"
|
||||||
target_link_directories(pdf_backend_iface INTERFACE
|
OR NOT EXISTS "${_pdfium_dll}")
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/x64")
|
message(FATAL_ERROR
|
||||||
|
"Could not find bundled pdfium for ${_pdfium_arch}. "
|
||||||
|
"Expected files under dependencies/pdfium/win/${_pdfium_arch}.")
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(pdf_backend_iface INTERFACE pdfium)
|
|
||||||
|
message(STATUS " Using bundled pdfium (${_pdfium_arch}, Windows)")
|
||||||
|
yacreader_add_imported_library(YACReader::pdfium
|
||||||
|
TYPE SHARED
|
||||||
|
LOCATION "${_pdfium_dll}"
|
||||||
|
IMPORTED_IMPLIB "${_pdfium_implib}"
|
||||||
|
INCLUDE_DIR "${_pdfium_include_dir}")
|
||||||
|
target_link_libraries(pdf_backend_iface INTERFACE YACReader::pdfium)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
target_include_directories(pdf_backend_iface INTERFACE
|
set(_pdfium_include_dir "${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/include")
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/include")
|
set(_pdfium_library "${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/bin/libpdfium.a")
|
||||||
target_link_directories(pdf_backend_iface INTERFACE
|
if(NOT EXISTS "${_pdfium_include_dir}/fpdfview.h" OR NOT EXISTS "${_pdfium_library}")
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/bin")
|
message(FATAL_ERROR "Could not find bundled pdfium under dependencies/pdfium/macx.")
|
||||||
target_link_libraries(pdf_backend_iface INTERFACE pdfium)
|
endif()
|
||||||
|
|
||||||
|
message(STATUS " Using bundled pdfium (macOS)")
|
||||||
|
yacreader_add_imported_library(YACReader::pdfium
|
||||||
|
TYPE STATIC
|
||||||
|
LOCATION "${_pdfium_library}"
|
||||||
|
INCLUDE_DIR "${_pdfium_include_dir}")
|
||||||
|
target_link_libraries(pdf_backend_iface INTERFACE YACReader::pdfium)
|
||||||
else()
|
else()
|
||||||
# Linux: try pkg-config first, then system path
|
# Linux: try pkg-config first, then a normal CMake search.
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
pkg_check_modules(PDFIUM QUIET IMPORTED_TARGET libpdfium)
|
pkg_check_modules(PDFIUM QUIET IMPORTED_TARGET libpdfium)
|
||||||
if(PDFIUM_FOUND)
|
endif()
|
||||||
|
|
||||||
|
if(TARGET PkgConfig::PDFIUM)
|
||||||
message(STATUS " Found pdfium via pkg-config")
|
message(STATUS " Found pdfium via pkg-config")
|
||||||
target_link_libraries(pdf_backend_iface INTERFACE PkgConfig::PDFIUM)
|
target_link_libraries(pdf_backend_iface INTERFACE PkgConfig::PDFIUM)
|
||||||
elseif(EXISTS "/usr/include/pdfium")
|
else()
|
||||||
message(STATUS " Found pdfium at /usr/include/pdfium")
|
find_path(PDFIUM_INCLUDE_DIR NAMES fpdfview.h PATH_SUFFIXES pdfium)
|
||||||
target_include_directories(pdf_backend_iface INTERFACE /usr/include/pdfium)
|
find_library(PDFIUM_LIBRARY NAMES pdfium libpdfium)
|
||||||
target_link_libraries(pdf_backend_iface INTERFACE pdfium)
|
if(PDFIUM_INCLUDE_DIR AND PDFIUM_LIBRARY)
|
||||||
|
message(STATUS " Found pdfium via CMake search")
|
||||||
|
yacreader_add_imported_library(YACReader::pdfium
|
||||||
|
TYPE UNKNOWN
|
||||||
|
LOCATION "${PDFIUM_LIBRARY}"
|
||||||
|
INCLUDE_DIR "${PDFIUM_INCLUDE_DIR}")
|
||||||
|
target_link_libraries(pdf_backend_iface INTERFACE YACReader::pdfium)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Could not find libpdfium. Install it or use a different PDF_BACKEND.")
|
message(FATAL_ERROR "Could not find libpdfium. Install it or use a different PDF_BACKEND.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
elseif(PDF_BACKEND STREQUAL "poppler")
|
elseif(PDF_BACKEND STREQUAL "poppler")
|
||||||
message(STATUS "PDF backend: poppler")
|
message(STATUS "PDF backend: poppler")
|
||||||
@ -60,22 +89,33 @@ elseif(PDF_BACKEND STREQUAL "poppler")
|
|||||||
target_link_libraries(pdf_backend_iface INTERFACE Poppler::Qt6)
|
target_link_libraries(pdf_backend_iface INTERFACE Poppler::Qt6)
|
||||||
else()
|
else()
|
||||||
# Fall back to pkg-config (standard on Linux; on Windows requires vcpkg pkgconf)
|
# Fall back to pkg-config (standard on Linux; on Windows requires vcpkg pkgconf)
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
pkg_check_modules(POPPLER QUIET IMPORTED_TARGET poppler-qt6)
|
pkg_check_modules(POPPLER QUIET IMPORTED_TARGET poppler-qt6)
|
||||||
if(POPPLER_FOUND)
|
endif()
|
||||||
|
|
||||||
|
if(TARGET PkgConfig::POPPLER)
|
||||||
message(STATUS " Found poppler-qt6 via pkg-config")
|
message(STATUS " Found poppler-qt6 via pkg-config")
|
||||||
target_link_libraries(pdf_backend_iface INTERFACE PkgConfig::POPPLER)
|
target_link_libraries(pdf_backend_iface INTERFACE PkgConfig::POPPLER)
|
||||||
elseif(NOT MSVC AND EXISTS "/usr/include/poppler/qt6")
|
|
||||||
message(STATUS " Found poppler-qt6 at /usr/include/poppler/qt6")
|
|
||||||
target_include_directories(pdf_backend_iface INTERFACE /usr/include/poppler/qt6)
|
|
||||||
target_link_libraries(pdf_backend_iface INTERFACE poppler-qt6)
|
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
message(FATAL_ERROR "Could not find poppler-qt6. "
|
message(FATAL_ERROR "Could not find poppler-qt6. "
|
||||||
"Install via vcpkg: vcpkg install poppler[qt6]:x64-windows "
|
"Install via vcpkg: vcpkg install poppler[qt6]:x64-windows "
|
||||||
"then configure cmake with the vcpkg toolchain file.")
|
"then configure cmake with the vcpkg toolchain file.")
|
||||||
|
else()
|
||||||
|
find_path(POPPLER_QT6_INCLUDE_DIR NAMES poppler-qt6.h PATH_SUFFIXES poppler/qt6)
|
||||||
|
find_library(POPPLER_QT6_LIBRARY NAMES poppler-qt6)
|
||||||
|
if(POPPLER_QT6_INCLUDE_DIR AND POPPLER_QT6_LIBRARY)
|
||||||
|
message(STATUS " Found poppler-qt6 via CMake search")
|
||||||
|
yacreader_add_imported_library(YACReader::poppler_qt6
|
||||||
|
TYPE UNKNOWN
|
||||||
|
LOCATION "${POPPLER_QT6_LIBRARY}"
|
||||||
|
INCLUDE_DIR "${POPPLER_QT6_INCLUDE_DIR}")
|
||||||
|
target_link_libraries(pdf_backend_iface INTERFACE YACReader::poppler_qt6)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Could not find poppler-qt6. Install libpoppler-qt6-dev or use a different PDF_BACKEND.")
|
message(FATAL_ERROR "Could not find poppler-qt6. Install libpoppler-qt6-dev or use a different PDF_BACKEND.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
elseif(PDF_BACKEND STREQUAL "pdfkit")
|
elseif(PDF_BACKEND STREQUAL "pdfkit")
|
||||||
message(STATUS "PDF backend: pdfkit (macOS)")
|
message(STATUS "PDF backend: pdfkit (macOS)")
|
||||||
|
|||||||
@ -33,6 +33,7 @@ echo "Configuring and building with CMake"
|
|||||||
cmake -B build \
|
cmake -B build \
|
||||||
-G Ninja \
|
-G Ninja \
|
||||||
-DDECOMPRESSION_BACKEND=7zip \
|
-DDECOMPRESSION_BACKEND=7zip \
|
||||||
|
-DPDF_BACKEND=pdfkit \
|
||||||
-DBUILD_NUMBER="${BUILD_NUMBER}" \
|
-DBUILD_NUMBER="${BUILD_NUMBER}" \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_OSX_ARCHITECTURES="${ARCHS}" \
|
-DCMAKE_OSX_ARCHITECTURES="${ARCHS}" \
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
# Comic archive decompression backend (cbx_backend)
|
# Comic archive decompression backend (cbx_backend)
|
||||||
# Switched on DECOMPRESSION_BACKEND: unarr | 7zip | libarchive
|
# Switched on DECOMPRESSION_BACKEND: unarr | 7zip | libarchive
|
||||||
|
|
||||||
|
include(BackendHelpers)
|
||||||
|
|
||||||
add_library(cbx_backend STATIC)
|
add_library(cbx_backend STATIC)
|
||||||
|
|
||||||
if(DECOMPRESSION_BACKEND STREQUAL "unarr")
|
if(DECOMPRESSION_BACKEND STREQUAL "unarr")
|
||||||
@ -14,44 +16,77 @@ if(DECOMPRESSION_BACKEND STREQUAL "unarr")
|
|||||||
target_include_directories(cbx_backend PUBLIC unarr)
|
target_include_directories(cbx_backend PUBLIC unarr)
|
||||||
target_compile_definitions(cbx_backend PUBLIC use_unarr)
|
target_compile_definitions(cbx_backend PUBLIC use_unarr)
|
||||||
|
|
||||||
# Try CMake config first, then pkg-config, then system path
|
# Try CMake config first, then pkg-config, then bundled/system libraries.
|
||||||
find_package(unarr QUIET)
|
set(_unarr_target "")
|
||||||
if(unarr_FOUND)
|
|
||||||
|
find_package(unarr QUIET CONFIG)
|
||||||
|
if(TARGET unarr::unarr)
|
||||||
message(STATUS " Found unarr via CMake config")
|
message(STATUS " Found unarr via CMake config")
|
||||||
target_link_libraries(cbx_backend PRIVATE unarr::unarr)
|
set(_unarr_target unarr::unarr)
|
||||||
else()
|
|
||||||
pkg_check_modules(UNARR QUIET IMPORTED_TARGET libunarr)
|
|
||||||
if(UNARR_FOUND)
|
|
||||||
message(STATUS " Found unarr via pkg-config")
|
|
||||||
target_link_libraries(cbx_backend PRIVATE PkgConfig::UNARR)
|
|
||||||
elseif(APPLE AND EXISTS "${CMAKE_SOURCE_DIR}/dependencies/unarr/macx/libunarr.a")
|
|
||||||
message(STATUS " Found prebuilt unarr in dependencies (macOS)")
|
|
||||||
target_include_directories(cbx_backend PRIVATE
|
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/unarr/macx")
|
|
||||||
target_link_directories(cbx_backend PRIVATE
|
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/unarr/macx")
|
|
||||||
target_link_libraries(cbx_backend PRIVATE unarr z bz2)
|
|
||||||
elseif(WIN32 AND EXISTS "${CMAKE_SOURCE_DIR}/dependencies/unarr/win/unarr.h")
|
|
||||||
message(STATUS " Found prebuilt unarr in dependencies (Windows)")
|
|
||||||
target_include_directories(cbx_backend PRIVATE
|
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/unarr/win")
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
|
|
||||||
target_link_directories(cbx_backend PRIVATE
|
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/unarr/win/arm64")
|
|
||||||
else()
|
|
||||||
target_link_directories(cbx_backend PRIVATE
|
|
||||||
"${CMAKE_SOURCE_DIR}/dependencies/unarr/win/x64")
|
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(cbx_backend PRIVATE unarr)
|
|
||||||
|
if(NOT _unarr_target AND APPLE)
|
||||||
|
set(_unarr_include_dir "${CMAKE_SOURCE_DIR}/dependencies/unarr/macx")
|
||||||
|
set(_unarr_library "${CMAKE_SOURCE_DIR}/dependencies/unarr/macx/libunarr.a")
|
||||||
|
if(EXISTS "${_unarr_include_dir}/unarr.h" AND EXISTS "${_unarr_library}")
|
||||||
|
message(STATUS " Using bundled unarr (macOS)")
|
||||||
|
yacreader_add_imported_library(YACReader::unarr
|
||||||
|
TYPE STATIC
|
||||||
|
LOCATION "${_unarr_library}"
|
||||||
|
INCLUDE_DIR "${_unarr_include_dir}"
|
||||||
|
LINK_LIBRARIES "z;bz2")
|
||||||
|
set(_unarr_target YACReader::unarr)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT _unarr_target AND WIN32)
|
||||||
|
yacreader_get_windows_arch_subdir(_unarr_arch)
|
||||||
|
set(_unarr_include_dir "${CMAKE_SOURCE_DIR}/dependencies/unarr/win")
|
||||||
|
set(_unarr_implib "${CMAKE_SOURCE_DIR}/dependencies/unarr/win/${_unarr_arch}/unarr.lib")
|
||||||
|
set(_unarr_dll "${CMAKE_SOURCE_DIR}/dependencies/unarr/win/${_unarr_arch}/unarr.dll")
|
||||||
|
if(EXISTS "${_unarr_include_dir}/unarr.h" AND EXISTS "${_unarr_implib}" AND EXISTS "${_unarr_dll}")
|
||||||
|
message(STATUS " Using bundled unarr (${_unarr_arch}, Windows)")
|
||||||
|
yacreader_add_imported_library(YACReader::unarr
|
||||||
|
TYPE SHARED
|
||||||
|
LOCATION "${_unarr_dll}"
|
||||||
|
IMPORTED_IMPLIB "${_unarr_implib}"
|
||||||
|
INCLUDE_DIR "${_unarr_include_dir}")
|
||||||
|
set(_unarr_target YACReader::unarr)
|
||||||
target_compile_definitions(cbx_backend PRIVATE UNARR_IS_SHARED_LIBRARY)
|
target_compile_definitions(cbx_backend PRIVATE UNARR_IS_SHARED_LIBRARY)
|
||||||
elseif(EXISTS "/usr/include/unarr.h")
|
endif()
|
||||||
message(STATUS " Found system unarr at /usr/include")
|
endif()
|
||||||
target_link_libraries(cbx_backend PRIVATE unarr)
|
|
||||||
else()
|
if(NOT _unarr_target)
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT _unarr_target AND PkgConfig_FOUND)
|
||||||
|
pkg_check_modules(UNARR QUIET IMPORTED_TARGET libunarr)
|
||||||
|
if(TARGET PkgConfig::UNARR)
|
||||||
|
message(STATUS " Found unarr via pkg-config")
|
||||||
|
set(_unarr_target PkgConfig::UNARR)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT _unarr_target)
|
||||||
|
find_path(UNARR_INCLUDE_DIR NAMES unarr.h)
|
||||||
|
find_library(UNARR_LIBRARY NAMES unarr libunarr)
|
||||||
|
if(UNARR_INCLUDE_DIR AND UNARR_LIBRARY)
|
||||||
|
message(STATUS " Found unarr via CMake search")
|
||||||
|
yacreader_add_imported_library(YACReader::unarr
|
||||||
|
TYPE UNKNOWN
|
||||||
|
LOCATION "${UNARR_LIBRARY}"
|
||||||
|
INCLUDE_DIR "${UNARR_INCLUDE_DIR}")
|
||||||
|
set(_unarr_target YACReader::unarr)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT _unarr_target)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Could not find unarr. Install libunarr or use a different DECOMPRESSION_BACKEND.")
|
"Could not find unarr. Install libunarr or use a different DECOMPRESSION_BACKEND.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
target_link_libraries(cbx_backend PRIVATE ${_unarr_target})
|
||||||
|
|
||||||
elseif(DECOMPRESSION_BACKEND STREQUAL "7zip")
|
elseif(DECOMPRESSION_BACKEND STREQUAL "7zip")
|
||||||
message(STATUS "Decompression backend: 7zip (in-tree)")
|
message(STATUS "Decompression backend: 7zip (in-tree)")
|
||||||
@ -135,18 +170,9 @@ elseif(DECOMPRESSION_BACKEND STREQUAL "libarchive")
|
|||||||
target_include_directories(cbx_backend PUBLIC libarchive)
|
target_include_directories(cbx_backend PUBLIC libarchive)
|
||||||
target_compile_definitions(cbx_backend PUBLIC use_libarchive)
|
target_compile_definitions(cbx_backend PUBLIC use_libarchive)
|
||||||
|
|
||||||
# Try pkg-config first, then system path
|
find_package(LibArchive REQUIRED)
|
||||||
pkg_check_modules(LIBARCHIVE QUIET IMPORTED_TARGET libarchive)
|
message(STATUS " Found libarchive ${LibArchive_VERSION}")
|
||||||
if(LIBARCHIVE_FOUND)
|
target_link_libraries(cbx_backend PRIVATE LibArchive::LibArchive)
|
||||||
message(STATUS " Found libarchive via pkg-config")
|
|
||||||
target_link_libraries(cbx_backend PRIVATE PkgConfig::LIBARCHIVE)
|
|
||||||
elseif(EXISTS "/usr/include/archive.h")
|
|
||||||
message(STATUS " Found system libarchive at /usr/include")
|
|
||||||
target_link_libraries(cbx_backend PRIVATE archive)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"Could not find libarchive. Install it or use a different DECOMPRESSION_BACKEND.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
|
|||||||
@ -65,6 +65,7 @@ RUN cd /src/git && \
|
|||||||
cmake -B build -G Ninja \
|
cmake -B build -G Ninja \
|
||||||
-DCMAKE_INSTALL_PREFIX=/app \
|
-DCMAKE_INSTALL_PREFIX=/app \
|
||||||
-DDECOMPRESSION_BACKEND=7zip \
|
-DDECOMPRESSION_BACKEND=7zip \
|
||||||
|
-DPDF_BACKEND=poppler \
|
||||||
-DBUILD_SERVER_STANDALONE=ON \
|
-DBUILD_SERVER_STANDALONE=ON \
|
||||||
-DCMAKE_BUILD_TYPE=Release && \
|
-DCMAKE_BUILD_TYPE=Release && \
|
||||||
cmake --build build --parallel && \
|
cmake --build build --parallel && \
|
||||||
|
|||||||
@ -62,6 +62,7 @@ RUN cd /src/git && \
|
|||||||
cmake -B build -G Ninja \
|
cmake -B build -G Ninja \
|
||||||
-DCMAKE_INSTALL_PREFIX=/app \
|
-DCMAKE_INSTALL_PREFIX=/app \
|
||||||
-DDECOMPRESSION_BACKEND=7zip \
|
-DDECOMPRESSION_BACKEND=7zip \
|
||||||
|
-DPDF_BACKEND=poppler \
|
||||||
-DBUILD_SERVER_STANDALONE=ON \
|
-DBUILD_SERVER_STANDALONE=ON \
|
||||||
-DCMAKE_BUILD_TYPE=Release && \
|
-DCMAKE_BUILD_TYPE=Release && \
|
||||||
cmake --build build --parallel && \
|
cmake --build build --parallel && \
|
||||||
|
|||||||
Reference in New Issue
Block a user