Improve backends handling and make DECOMPRESSION_BACKEND and PDF_BACKEND settings easier to discover

This commit is contained in:
luisangelsm
2026-03-29 22:55:16 +02:00
parent 27c94bcb53
commit 52dd4e4c3c
8 changed files with 250 additions and 105 deletions

View File

@ -80,6 +80,7 @@ jobs:
run: |
cmake -B build \
-DDECOMPRESSION_BACKEND=unarr \
-DPDF_BACKEND=poppler \
-DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel 2
@ -113,6 +114,7 @@ jobs:
run: |
cmake -B build \
-DDECOMPRESSION_BACKEND=7zip \
-DPDF_BACKEND=poppler \
-DBUILD_NUMBER="${{ needs.initialization.outputs.build_number }}" \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel 2
@ -201,7 +203,7 @@ jobs:
run: |
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%
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
- name: Run tests
@ -346,7 +348,7 @@ jobs:
run: |
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%
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
- name: Upload executables for signing

View File

@ -30,21 +30,13 @@ endif()
# Install paths
include(GNUInstallDirs)
find_package(PkgConfig)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Compiler options (MSVC flags, NOMINMAX, etc.)
include(cmake/CompilerOptions.cmake)
# --- 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
option(BUILD_TESTS "Build tests" ON)
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)
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) ---
if(NOT DECOMPRESSION_BACKEND OR DECOMPRESSION_BACKEND STREQUAL "")
if(UNIX AND NOT APPLE)
set(DECOMPRESSION_BACKEND "unarr")
else()
set(DECOMPRESSION_BACKEND "7zip")
endif()
message(STATUS "DECOMPRESSION_BACKEND defaulted to: ${DECOMPRESSION_BACKEND}")
if(UNIX AND NOT APPLE)
set(_default_decompression_backend "unarr")
set(_default_pdf_backend "poppler")
elseif(APPLE)
set(_default_decompression_backend "7zip")
set(_default_pdf_backend "pdfkit")
else()
set(_default_decompression_backend "7zip")
set(_default_pdf_backend "pdfium")
endif()
if(NOT PDF_BACKEND OR PDF_BACKEND STREQUAL "")
if(UNIX AND NOT APPLE)
set(PDF_BACKEND "poppler")
elseif(APPLE)
set(PDF_BACKEND "pdfkit")
else()
set(PDF_BACKEND "pdfium")
endif()
message(STATUS "PDF_BACKEND defaulted to: ${PDF_BACKEND}")
# Archive decompression backend (mutually exclusive)
set(_decompression_backend_value "")
if(DEFINED CACHE{DECOMPRESSION_BACKEND})
set(_decompression_backend_value "$CACHE{DECOMPRESSION_BACKEND}")
endif()
if(_decompression_backend_value STREQUAL "")
set(_decompression_backend_value "${_default_decompression_backend}")
string(JOIN ", " _available_decompression_backends ${YACREADER_DECOMPRESSION_BACKENDS})
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()
# macOS universal binary default
@ -114,7 +144,7 @@ endif()
qt_standard_project_setup()
# PDF backend detection (creates pdf_backend_iface INTERFACE target)
include(cmake/PdfBackend.cmake)
include(PdfBackend)
# Output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

View 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()

View File

@ -2,6 +2,8 @@
# Creates an INTERFACE target 'pdf_backend_iface' that propagates
# compile definitions and link libraries based on PDF_BACKEND.
include(BackendHelpers)
add_library(pdf_backend_iface INTERFACE)
if(PDF_BACKEND STREQUAL "no_pdf")
@ -12,35 +14,62 @@ elseif(PDF_BACKEND STREQUAL "pdfium")
message(STATUS "PDF backend: pdfium")
target_compile_definitions(pdf_backend_iface INTERFACE USE_PDFIUM)
if(MSVC)
target_include_directories(pdf_backend_iface INTERFACE
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/public")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64" OR CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64")
target_link_directories(pdf_backend_iface INTERFACE
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/arm64")
else()
target_link_directories(pdf_backend_iface INTERFACE
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/x64")
if(WIN32)
yacreader_get_windows_arch_subdir(_pdfium_arch)
set(_pdfium_include_dir "${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/public")
set(_pdfium_implib "${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/${_pdfium_arch}/pdfium.lib")
set(_pdfium_dll "${CMAKE_SOURCE_DIR}/dependencies/pdfium/win/${_pdfium_arch}/pdfium.dll")
if(NOT EXISTS "${_pdfium_include_dir}/fpdfview.h"
OR NOT EXISTS "${_pdfium_implib}"
OR NOT EXISTS "${_pdfium_dll}")
message(FATAL_ERROR
"Could not find bundled pdfium for ${_pdfium_arch}. "
"Expected files under dependencies/pdfium/win/${_pdfium_arch}.")
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)
target_include_directories(pdf_backend_iface INTERFACE
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/include")
target_link_directories(pdf_backend_iface INTERFACE
"${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/bin")
target_link_libraries(pdf_backend_iface INTERFACE pdfium)
set(_pdfium_include_dir "${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/include")
set(_pdfium_library "${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/bin/libpdfium.a")
if(NOT EXISTS "${_pdfium_include_dir}/fpdfview.h" OR NOT EXISTS "${_pdfium_library}")
message(FATAL_ERROR "Could not find bundled pdfium under dependencies/pdfium/macx.")
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()
# Linux: try pkg-config first, then system path
pkg_check_modules(PDFIUM QUIET IMPORTED_TARGET libpdfium)
if(PDFIUM_FOUND)
# 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)
endif()
if(TARGET PkgConfig::PDFIUM)
message(STATUS " Found pdfium via pkg-config")
target_link_libraries(pdf_backend_iface INTERFACE PkgConfig::PDFIUM)
elseif(EXISTS "/usr/include/pdfium")
message(STATUS " Found pdfium at /usr/include/pdfium")
target_include_directories(pdf_backend_iface INTERFACE /usr/include/pdfium)
target_link_libraries(pdf_backend_iface INTERFACE pdfium)
else()
message(FATAL_ERROR "Could not find libpdfium. Install it or use a different PDF_BACKEND.")
find_path(PDFIUM_INCLUDE_DIR NAMES fpdfview.h PATH_SUFFIXES pdfium)
find_library(PDFIUM_LIBRARY NAMES pdfium libpdfium)
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()
message(FATAL_ERROR "Could not find libpdfium. Install it or use a different PDF_BACKEND.")
endif()
endif()
endif()
@ -60,20 +89,31 @@ elseif(PDF_BACKEND STREQUAL "poppler")
target_link_libraries(pdf_backend_iface INTERFACE Poppler::Qt6)
else()
# Fall back to pkg-config (standard on Linux; on Windows requires vcpkg pkgconf)
pkg_check_modules(POPPLER QUIET IMPORTED_TARGET poppler-qt6)
if(POPPLER_FOUND)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(POPPLER QUIET IMPORTED_TARGET poppler-qt6)
endif()
if(TARGET PkgConfig::POPPLER)
message(STATUS " Found poppler-qt6 via pkg-config")
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)
message(FATAL_ERROR "Could not find poppler-qt6. "
"Install via vcpkg: vcpkg install poppler[qt6]:x64-windows "
"then configure cmake with the vcpkg toolchain file.")
else()
message(FATAL_ERROR "Could not find poppler-qt6. Install libpoppler-qt6-dev or use a different PDF_BACKEND.")
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()
message(FATAL_ERROR "Could not find poppler-qt6. Install libpoppler-qt6-dev or use a different PDF_BACKEND.")
endif()
endif()
endif()

View File

@ -33,6 +33,7 @@ echo "Configuring and building with CMake"
cmake -B build \
-G Ninja \
-DDECOMPRESSION_BACKEND=7zip \
-DPDF_BACKEND=pdfkit \
-DBUILD_NUMBER="${BUILD_NUMBER}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES="${ARCHS}" \

View File

@ -1,6 +1,8 @@
# Comic archive decompression backend (cbx_backend)
# Switched on DECOMPRESSION_BACKEND: unarr | 7zip | libarchive
include(BackendHelpers)
add_library(cbx_backend STATIC)
if(DECOMPRESSION_BACKEND STREQUAL "unarr")
@ -14,45 +16,78 @@ if(DECOMPRESSION_BACKEND STREQUAL "unarr")
target_include_directories(cbx_backend PUBLIC unarr)
target_compile_definitions(cbx_backend PUBLIC use_unarr)
# Try CMake config first, then pkg-config, then system path
find_package(unarr QUIET)
if(unarr_FOUND)
# Try CMake config first, then pkg-config, then bundled/system libraries.
set(_unarr_target "")
find_package(unarr QUIET CONFIG)
if(TARGET unarr::unarr)
message(STATUS " Found unarr via CMake config")
target_link_libraries(cbx_backend PRIVATE 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()
target_link_libraries(cbx_backend PRIVATE unarr)
target_compile_definitions(cbx_backend PRIVATE UNARR_IS_SHARED_LIBRARY)
elseif(EXISTS "/usr/include/unarr.h")
message(STATUS " Found system unarr at /usr/include")
target_link_libraries(cbx_backend PRIVATE unarr)
else()
message(FATAL_ERROR
"Could not find unarr. Install libunarr or use a different DECOMPRESSION_BACKEND.")
set(_unarr_target unarr::unarr)
endif()
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)
endif()
endif()
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
"Could not find unarr. Install libunarr or use a different DECOMPRESSION_BACKEND.")
endif()
target_link_libraries(cbx_backend PRIVATE ${_unarr_target})
elseif(DECOMPRESSION_BACKEND STREQUAL "7zip")
message(STATUS "Decompression backend: 7zip (in-tree)")
@ -135,18 +170,9 @@ elseif(DECOMPRESSION_BACKEND STREQUAL "libarchive")
target_include_directories(cbx_backend PUBLIC libarchive)
target_compile_definitions(cbx_backend PUBLIC use_libarchive)
# Try pkg-config first, then system path
pkg_check_modules(LIBARCHIVE QUIET IMPORTED_TARGET libarchive)
if(LIBARCHIVE_FOUND)
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()
find_package(LibArchive REQUIRED)
message(STATUS " Found libarchive ${LibArchive_VERSION}")
target_link_libraries(cbx_backend PRIVATE LibArchive::LibArchive)
else()
message(FATAL_ERROR

View File

@ -65,6 +65,7 @@ RUN cd /src/git && \
cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX=/app \
-DDECOMPRESSION_BACKEND=7zip \
-DPDF_BACKEND=poppler \
-DBUILD_SERVER_STANDALONE=ON \
-DCMAKE_BUILD_TYPE=Release && \
cmake --build build --parallel && \

View File

@ -62,6 +62,7 @@ RUN cd /src/git && \
cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX=/app \
-DDECOMPRESSION_BACKEND=7zip \
-DPDF_BACKEND=poppler \
-DBUILD_SERVER_STANDALONE=ON \
-DCMAKE_BUILD_TYPE=Release && \
cmake --build build --parallel && \