Commit 2368e22c authored by Pino Toscano's avatar Pino Toscano Committed by Eliakin Costa

cmake: switch to the FindPoppler module from ECM

Summary:
Bump the ECM requirement to 5.19, which provides a better FindPoppler
than the local copy (which was itself copied from okular).
As result, we can search for Qt5 component specifically, and use the
Poppler::Qt5 target where needed, with no more manual include
directories.

Reviewers: #krita, rempt

Reviewed By: #krita, rempt

Subscribers: rempt

Differential Revision: https://phabricator.kde.org/D5849
parent 44070e5d
......@@ -198,7 +198,7 @@ find_package(PythonLibrary 3.0)
#########################
########################
find_package(ECM 1.7.0 REQUIRED NOMODULE)
find_package(ECM 5.19 REQUIRED NOMODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(ECMOptionalAddSubdirectory)
include(ECMAddAppIcon)
......@@ -587,7 +587,7 @@ test_big_endian(CMAKE_WORDS_BIGENDIAN)
##
## Test for qt-poppler
##
find_package(Poppler)
find_package(Poppler COMPONENTS Qt5)
set_package_properties(Poppler PROPERTIES
DESCRIPTION "A PDF rendering library"
URL "http://poppler.freedesktop.org"
......
# - Try to find the poppler PDF library
# Once done this will define
#
# POPPLER_FOUND - system has poppler
# POPPLER_INCLUDE_DIR - the poppler include directory
# POPPLER_LIBRARY - Link this to use poppler
#
# Copyright (c) 2006-2010, Pino Toscano, <pino@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)
# in cache already
set(POPPLER_FOUND TRUE)
else()
set(_poppler_version_bad FALSE)
if(NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
include(FindPkgConfig)
pkg_check_modules(_pc_poppler poppler-qt5)
if(_pc_poppler_FOUND)
if(NOT "${_pc_poppler_VERSION}" VERSION_GREATER 0.5.3)
set(_poppler_version_bad TRUE)
endif()
endif()
endif()
if(NOT _poppler_version_bad)
set(POPPLER_FOUND FALSE)
find_library(POPPLER_LIBRARY poppler-qt5
HINTS ${_pc_poppler_LIBRARY_DIRS}
)
find_library(POPPLER_CORE_LIBRARY poppler
HINTS ${_pc_poppler_LIBRARY_DIRS}
)
find_path(POPPLER_INCLUDE_DIR poppler-qt5.h
HINTS ${_pc_poppler_INCLUDE_DIRS}
PATH_SUFFIXES poppler/qt5
)
find_path(POPPLER_INCLUDE_DIR_core qt5/poppler-qt5.h
HINTS ${_pc_poppler_INCLUDE_DIRS}
PATH_SUFFIXES poppler
)
if(POPPLER_LIBRARY AND POPPLER_INCLUDE_DIR AND POPPLER_INCLUDE_DIR_core)
list(APPEND POPPLER_INCLUDE_DIR "${POPPLER_INCLUDE_DIR_core}")
set(POPPLER_FOUND TRUE)
endif()
endif()
if (POPPLER_FOUND)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIR} ${QT_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_LIBRARY} ${POPPLER_CORE_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY})
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::Document::RenderHint hint = Poppler::Document::ThinLineSolid;
return 0;
}
" HAVE_POPPLER_0_24)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::Page *p = 0;
p->annotations( QSet<Poppler::Annotation::SubType>() << Poppler::Annotation::ASound );
return 0;
}
" HAVE_POPPLER_0_28)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
if (HAVE_POPPLER_0_28)
set(popplerVersionMessage "0.28")
elseif (HAVE_POPPLER_0_24)
set(popplerVersionMessage "0.24")
endif ()
if (NOT Poppler_FIND_QUIETLY)
message(STATUS "Found Poppler-Qt5: ${POPPLER_LIBRARY}, (>= ${popplerVersionMessage})")
endif ()
else ()
if (Poppler_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find Poppler-Qt5")
endif ()
message(STATUS "Could not find OPTIONAL package Poppler-Qt5")
endif ()
# ensure that they are cached
set(POPPLER_INCLUDE_DIR ${POPPLER_INCLUDE_DIR} CACHE INTERNAL "The Poppler-Qt5 include path")
set(POPPLER_LIBRARY ${POPPLER_LIBRARY} CACHE INTERNAL "The Poppler-Qt5 library")
endif()
......@@ -23,7 +23,7 @@ if(OPENEXR_FOUND)
add_subdirectory(exr)
endif()
if(POPPLER_FOUND)
if(Poppler_Qt5_FOUND)
add_subdirectory(pdf)
endif()
......
include_directories( ${POPPLER_INCLUDE_DIR} )
set(kritapdfimport_SOURCES kis_pdf_import.cpp kis_pdf_import_widget.cpp )
ki18n_wrap_ui(kritapdfimport_SOURCES pdfimportwidgetbase.ui )
add_library(kritapdfimport MODULE ${kritapdfimport_SOURCES})
target_link_libraries(kritapdfimport kritaui ${POPPLER_LIBRARY} )
target_link_libraries(kritapdfimport kritaui Poppler::Qt5)
install(TARGETS kritapdfimport DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
install(PROGRAMS krita_pdf.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment