mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Use Find*.cmake files for backend discovery
This commit is contained in:
@ -15,7 +15,7 @@ endfunction()
|
||||
function(yacreader_add_imported_library target_name)
|
||||
set(options)
|
||||
set(oneValueArgs TYPE LOCATION IMPORTED_IMPLIB INCLUDE_DIR)
|
||||
set(multiValueArgs LINK_LIBRARIES)
|
||||
set(multiValueArgs LINK_LIBRARIES COMPILE_DEFINITIONS)
|
||||
cmake_parse_arguments(YR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT YR_TYPE)
|
||||
@ -41,4 +41,8 @@ function(yacreader_add_imported_library target_name)
|
||||
if(YR_LINK_LIBRARIES)
|
||||
set_property(TARGET "${target_name}" PROPERTY INTERFACE_LINK_LIBRARIES "${YR_LINK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if(YR_COMPILE_DEFINITIONS)
|
||||
set_property(TARGET "${target_name}" PROPERTY INTERFACE_COMPILE_DEFINITIONS "${YR_COMPILE_DEFINITIONS}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
43
cmake/FindPopplerQt6.cmake
Normal file
43
cmake/FindPopplerQt6.cmake
Normal file
@ -0,0 +1,43 @@
|
||||
include(BackendHelpers)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
set(PopplerQt6_PROVIDER "")
|
||||
set(PopplerQt6_TARGET "")
|
||||
set(PopplerQt6_INCLUDE_DIRS "")
|
||||
set(PopplerQt6_LIBRARIES "")
|
||||
|
||||
if(NOT TARGET Poppler::Qt6)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(POPPLERQT6 QUIET IMPORTED_TARGET poppler-qt6)
|
||||
if(TARGET PkgConfig::POPPLERQT6)
|
||||
yacreader_add_imported_library(Poppler::Qt6
|
||||
TYPE INTERFACE
|
||||
LINK_LIBRARIES "PkgConfig::POPPLERQT6")
|
||||
set(PopplerQt6_PROVIDER "pkg-config")
|
||||
set(PopplerQt6_INCLUDE_DIRS "${POPPLERQT6_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Poppler::Qt6)
|
||||
find_path(POPPLERQT6_INCLUDE_DIR NAMES poppler-qt6.h PATH_SUFFIXES poppler/qt6)
|
||||
find_library(POPPLERQT6_LIBRARY NAMES poppler-qt6)
|
||||
if(POPPLERQT6_INCLUDE_DIR AND POPPLERQT6_LIBRARY)
|
||||
yacreader_add_imported_library(Poppler::Qt6
|
||||
TYPE UNKNOWN
|
||||
LOCATION "${POPPLERQT6_LIBRARY}"
|
||||
INCLUDE_DIR "${POPPLERQT6_INCLUDE_DIR}")
|
||||
set(PopplerQt6_PROVIDER "CMake search")
|
||||
set(PopplerQt6_INCLUDE_DIRS "${POPPLERQT6_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET Poppler::Qt6)
|
||||
set(PopplerQt6_TARGET Poppler::Qt6)
|
||||
set(PopplerQt6_LIBRARIES Poppler::Qt6)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(PopplerQt6 REQUIRED_VARS PopplerQt6_TARGET)
|
||||
|
||||
mark_as_advanced(POPPLERQT6_INCLUDE_DIR POPPLERQT6_LIBRARY)
|
||||
72
cmake/Findpdfium.cmake
Normal file
72
cmake/Findpdfium.cmake
Normal file
@ -0,0 +1,72 @@
|
||||
include(BackendHelpers)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
set(pdfium_PROVIDER "")
|
||||
set(pdfium_TARGET "")
|
||||
set(pdfium_INCLUDE_DIRS "")
|
||||
set(pdfium_LIBRARIES "")
|
||||
|
||||
if(NOT TARGET pdfium::pdfium AND 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(EXISTS "${_pdfium_include_dir}/fpdfview.h" AND EXISTS "${_pdfium_implib}" AND EXISTS "${_pdfium_dll}")
|
||||
yacreader_add_imported_library(pdfium::pdfium
|
||||
TYPE SHARED
|
||||
LOCATION "${_pdfium_dll}"
|
||||
IMPORTED_IMPLIB "${_pdfium_implib}"
|
||||
INCLUDE_DIR "${_pdfium_include_dir}")
|
||||
set(pdfium_PROVIDER "bundled dependencies (${_pdfium_arch}, Windows)")
|
||||
set(pdfium_INCLUDE_DIRS "${_pdfium_include_dir}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET pdfium::pdfium AND APPLE)
|
||||
set(_pdfium_include_dir "${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/include")
|
||||
set(_pdfium_library "${CMAKE_SOURCE_DIR}/dependencies/pdfium/macx/bin/libpdfium.a")
|
||||
if(EXISTS "${_pdfium_include_dir}/fpdfview.h" AND EXISTS "${_pdfium_library}")
|
||||
yacreader_add_imported_library(pdfium::pdfium
|
||||
TYPE STATIC
|
||||
LOCATION "${_pdfium_library}"
|
||||
INCLUDE_DIR "${_pdfium_include_dir}")
|
||||
set(pdfium_PROVIDER "bundled dependencies (macOS)")
|
||||
set(pdfium_INCLUDE_DIRS "${_pdfium_include_dir}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET pdfium::pdfium)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(PDFIUM QUIET IMPORTED_TARGET libpdfium)
|
||||
if(TARGET PkgConfig::PDFIUM)
|
||||
yacreader_add_imported_library(pdfium::pdfium
|
||||
TYPE INTERFACE
|
||||
LINK_LIBRARIES "PkgConfig::PDFIUM")
|
||||
set(pdfium_PROVIDER "pkg-config")
|
||||
set(pdfium_INCLUDE_DIRS "${PDFIUM_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET pdfium::pdfium)
|
||||
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)
|
||||
yacreader_add_imported_library(pdfium::pdfium
|
||||
TYPE UNKNOWN
|
||||
LOCATION "${PDFIUM_LIBRARY}"
|
||||
INCLUDE_DIR "${PDFIUM_INCLUDE_DIR}")
|
||||
set(pdfium_PROVIDER "CMake search")
|
||||
set(pdfium_INCLUDE_DIRS "${PDFIUM_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET pdfium::pdfium)
|
||||
set(pdfium_TARGET pdfium::pdfium)
|
||||
set(pdfium_LIBRARIES pdfium::pdfium)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(pdfium REQUIRED_VARS pdfium_TARGET)
|
||||
|
||||
mark_as_advanced(PDFIUM_INCLUDE_DIR PDFIUM_LIBRARY)
|
||||
74
cmake/Findunarr.cmake
Normal file
74
cmake/Findunarr.cmake
Normal file
@ -0,0 +1,74 @@
|
||||
include(BackendHelpers)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
set(unarr_PROVIDER "")
|
||||
set(unarr_TARGET "")
|
||||
set(unarr_INCLUDE_DIRS "")
|
||||
set(unarr_LIBRARIES "")
|
||||
|
||||
if(NOT TARGET unarr::unarr 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}")
|
||||
yacreader_add_imported_library(unarr::unarr
|
||||
TYPE STATIC
|
||||
LOCATION "${_unarr_library}"
|
||||
INCLUDE_DIR "${_unarr_include_dir}"
|
||||
LINK_LIBRARIES "z;bz2")
|
||||
set(unarr_PROVIDER "bundled dependencies (macOS)")
|
||||
set(unarr_INCLUDE_DIRS "${_unarr_include_dir}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET unarr::unarr 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}")
|
||||
yacreader_add_imported_library(unarr::unarr
|
||||
TYPE SHARED
|
||||
LOCATION "${_unarr_dll}"
|
||||
IMPORTED_IMPLIB "${_unarr_implib}"
|
||||
INCLUDE_DIR "${_unarr_include_dir}"
|
||||
COMPILE_DEFINITIONS "UNARR_IS_SHARED_LIBRARY")
|
||||
set(unarr_PROVIDER "bundled dependencies (${_unarr_arch}, Windows)")
|
||||
set(unarr_INCLUDE_DIRS "${_unarr_include_dir}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET unarr::unarr)
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(UNARR QUIET IMPORTED_TARGET libunarr)
|
||||
if(TARGET PkgConfig::UNARR)
|
||||
yacreader_add_imported_library(unarr::unarr
|
||||
TYPE INTERFACE
|
||||
LINK_LIBRARIES "PkgConfig::UNARR")
|
||||
set(unarr_PROVIDER "pkg-config")
|
||||
set(unarr_INCLUDE_DIRS "${UNARR_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET unarr::unarr)
|
||||
find_path(UNARR_INCLUDE_DIR NAMES unarr.h)
|
||||
find_library(UNARR_LIBRARY NAMES unarr libunarr)
|
||||
if(UNARR_INCLUDE_DIR AND UNARR_LIBRARY)
|
||||
yacreader_add_imported_library(unarr::unarr
|
||||
TYPE UNKNOWN
|
||||
LOCATION "${UNARR_LIBRARY}"
|
||||
INCLUDE_DIR "${UNARR_INCLUDE_DIR}")
|
||||
set(unarr_PROVIDER "CMake search")
|
||||
set(unarr_INCLUDE_DIRS "${UNARR_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET unarr::unarr)
|
||||
set(unarr_TARGET unarr::unarr)
|
||||
set(unarr_LIBRARIES unarr::unarr)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(unarr REQUIRED_VARS unarr_TARGET)
|
||||
|
||||
mark_as_advanced(UNARR_INCLUDE_DIR UNARR_LIBRARY)
|
||||
@ -2,8 +2,6 @@
|
||||
# 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")
|
||||
@ -14,65 +12,21 @@ elseif(PDF_BACKEND STREQUAL "pdfium")
|
||||
message(STATUS "PDF backend: pdfium")
|
||||
target_compile_definitions(pdf_backend_iface INTERFACE USE_PDFIUM)
|
||||
|
||||
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()
|
||||
|
||||
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)
|
||||
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 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)
|
||||
else()
|
||||
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)
|
||||
find_package(pdfium QUIET CONFIG)
|
||||
if(TARGET pdfium::pdfium)
|
||||
message(STATUS " Found pdfium via CMake config")
|
||||
else()
|
||||
find_package(pdfium QUIET MODULE)
|
||||
if(NOT TARGET pdfium::pdfium)
|
||||
message(FATAL_ERROR "Could not find libpdfium. Install it or use a different PDF_BACKEND.")
|
||||
endif()
|
||||
if(pdfium_PROVIDER)
|
||||
message(STATUS " Found pdfium via ${pdfium_PROVIDER}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(pdf_backend_iface INTERFACE pdfium::pdfium)
|
||||
|
||||
elseif(PDF_BACKEND STREQUAL "poppler")
|
||||
message(STATUS "PDF backend: poppler")
|
||||
target_compile_definitions(pdf_backend_iface INTERFACE USE_POPPLER)
|
||||
@ -85,37 +39,23 @@ elseif(PDF_BACKEND STREQUAL "poppler")
|
||||
# On Windows: vcpkg install poppler[qt6]:x64-windows, then pass the vcpkg toolchain file
|
||||
find_package(Poppler QUIET CONFIG)
|
||||
if(TARGET Poppler::Qt6)
|
||||
message(STATUS " Found poppler-qt6 via cmake config")
|
||||
target_link_libraries(pdf_backend_iface INTERFACE Poppler::Qt6)
|
||||
message(STATUS " Found poppler-qt6 via CMake config")
|
||||
else()
|
||||
# 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)
|
||||
find_package(PopplerQt6 QUIET MODULE)
|
||||
if(TARGET Poppler::Qt6)
|
||||
if(PopplerQt6_PROVIDER)
|
||||
message(STATUS " Found poppler-qt6 via ${PopplerQt6_PROVIDER}")
|
||||
endif()
|
||||
|
||||
if(TARGET PkgConfig::POPPLER)
|
||||
message(STATUS " Found poppler-qt6 via pkg-config")
|
||||
target_link_libraries(pdf_backend_iface INTERFACE PkgConfig::POPPLER)
|
||||
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()
|
||||
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()
|
||||
|
||||
target_link_libraries(pdf_backend_iface INTERFACE Poppler::Qt6)
|
||||
|
||||
elseif(PDF_BACKEND STREQUAL "pdfkit")
|
||||
message(STATUS "PDF backend: pdfkit (macOS)")
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
# 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")
|
||||
@ -16,77 +14,23 @@ 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 bundled/system libraries.
|
||||
set(_unarr_target "")
|
||||
|
||||
find_package(unarr QUIET CONFIG)
|
||||
if(TARGET unarr::unarr)
|
||||
message(STATUS " Found unarr via CMake config")
|
||||
set(_unarr_target unarr::unarr)
|
||||
else()
|
||||
find_package(unarr QUIET MODULE)
|
||||
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)
|
||||
if(NOT TARGET unarr::unarr)
|
||||
message(FATAL_ERROR
|
||||
"Could not find unarr. Install libunarr or use a different DECOMPRESSION_BACKEND.")
|
||||
endif()
|
||||
|
||||
target_link_libraries(cbx_backend PRIVATE ${_unarr_target})
|
||||
if(unarr_PROVIDER)
|
||||
message(STATUS " Found unarr via ${unarr_PROVIDER}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(cbx_backend PRIVATE unarr::unarr)
|
||||
|
||||
elseif(DECOMPRESSION_BACKEND STREQUAL "7zip")
|
||||
message(STATUS "Decompression backend: 7zip (in-tree)")
|
||||
|
||||
Reference in New Issue
Block a user