# FindPopplerQt6.cmake - Find Poppler Qt6 bindings # Sets: POPPLER_QT6_INCLUDE_DIR, POPPLER_QT6_LIBRARY, PopplerQt6::Poppler target if(POPPLER_QT6_INCLUDE_DIR AND POPPLER_QT6_LIBRARY) set(POPPLER_QT6_FOUND TRUE) else() set(_poppler_version_bad FALSE) if(NOT WIN32) include(FindPkgConfig) # Prefer poppler-qt6 pkg_check_modules(_pc_poppler poppler-qt6) if(_pc_poppler_FOUND) set(_pc_poppler_pkgname poppler-qt6) if(NOT "${_pc_poppler_VERSION}" VERSION_GREATER 0.24.0) set(_poppler_version_bad TRUE) endif() endif() endif() if(NOT _poppler_version_bad) set(POPPLER_QT6_FOUND FALSE) # Try library name discovered by pkg-config if(_pc_poppler_FOUND) set(_pkg_var "pkgcfg_lib__pc_poppler_${_pc_poppler_pkgname}") message(STATUS "FindPoppler: pkg-config found ${_pc_poppler_pkgname}, var ${_pkg_var} defined? ${${_pkg_var}}") if(DEFINED ${_pkg_var}) set(POPPLER_QT6_LIBRARY ${${_pkg_var}}) message(STATUS "FindPoppler: using pkgcfg path ${POPPLER_QT6_LIBRARY}") endif() endif() if(NOT POPPLER_QT6_LIBRARY) find_library(POPPLER_QT6_LIBRARY ${_pc_poppler_pkgname} HINTS ${_pc_poppler_LIBRARY_DIRS} ) endif() # Fallback: try common library names if(NOT POPPLER_QT6_LIBRARY) find_library(POPPLER_QT6_LIBRARY NAMES poppler-qt6 poppler-qt6) endif() # Extra fallback paths if(NOT POPPLER_QT6_LIBRARY) find_library(POPPLER_QT6_LIBRARY NAMES poppler-qt6 poppler-qt6 PATHS /usr/lib/x86_64-linux-gnu /usr/lib /usr/local/lib) endif() # Check for headers (Qt6 layout: poppler/qt6/poppler-qt6.h) find_path(POPPLER_QT6_INCLUDE_DIR poppler/qt6/poppler-qt6.h HINTS ${_pc_poppler_INCLUDE_DIRS} PATH_SUFFIXES poppler ) if(POPPLER_QT6_LIBRARY AND POPPLER_QT6_INCLUDE_DIR) set(POPPLER_QT6_FOUND TRUE) # Expose a modern imported target for consumers if(NOT TARGET PopplerQt6::Poppler) add_library(PopplerQt6::Poppler UNKNOWN IMPORTED) set_target_properties(PopplerQt6::Poppler PROPERTIES IMPORTED_LOCATION "${POPPLER_QT6_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${POPPLER_QT6_INCLUDE_DIR}" ) endif() # Cache the variables set(POPPLER_QT6_LIBRARY "${POPPLER_QT6_LIBRARY}" CACHE FILEPATH "Path to poppler-qt6 library") set(POPPLER_QT6_INCLUDE_DIR "${POPPLER_QT6_INCLUDE_DIR}" CACHE PATH "Poppler-Qt6 include dirs") endif() endif() if(POPPLER_QT6_LIBRARY AND POPPLER_QT6_INCLUDE_DIR) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PopplerQt6 DEFAULT_MSG POPPLER_QT6_LIBRARY POPPLER_QT6_INCLUDE_DIR) else() message(WARNING "Poppler Qt6 bindings not found. Creating placeholder PopplerQt6::Poppler target.") set(POPPLER_QT6_LIBRARY "" CACHE STRING "Placeholder poppler library" FORCE) set(POPPLER_QT6_INCLUDE_DIR "" CACHE STRING "Placeholder poppler include dir" FORCE) if(NOT TARGET PopplerQt6::Poppler) add_library(PopplerQt6::Poppler UNKNOWN IMPORTED) set_property(TARGET PopplerQt6::Poppler PROPERTY INTERFACE_INCLUDE_DIRECTORIES "") endif() set(POPPLER_QT6_FOUND TRUE CACHE INTERNAL "Poppler placeholder present") endif() endif()