cmake: Port to FindPoppler from extra-cmake-modules

REVIEW: 127049
This commit is contained in:
Armin K 2016-03-08 19:54:21 +01:00
parent 154c98fdaa
commit 568079625d
4 changed files with 21 additions and 143 deletions

View file

@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 2.8.9)
project(okular)
cmake_minimum_required(VERSION 2.8.12)
@ -6,7 +5,7 @@ cmake_minimum_required(VERSION 2.8.12)
set(QT_REQUIRED_VERSION "5.2.0")
set(KF5_REQUIRED_VERSION "5.16.0")
find_package(ECM 1.7.0 CONFIG REQUIRED)
find_package(ECM 5.19.0 CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
include(ECMInstallIcons)

View file

@ -1,126 +0,0 @@
# - 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(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)
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(NOT "${_pc_poppler_VERSION}" VERSION_GREATER 0.5.3)
endif(_pc_poppler_FOUND)
endif(NOT WIN32)
if(NOT _poppler_version_bad)
set(POPPLER_FOUND FALSE)
find_library(POPPLER_LIBRARY poppler-qt5
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(POPPLER_LIBRARY AND POPPLER_INCLUDE_DIR AND POPPLER_INCLUDE_DIR_core)
endif(NOT _poppler_version_bad)
if (POPPLER_FOUND)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIR} ${QT_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_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)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::Page *p = 0;
p->annotations( QSet<Poppler::Annotation::SubType>() << Poppler::Annotation::ARichMedia );
return 0;
}
" HAVE_POPPLER_0_36)
check_cxx_source_compiles("
#include <poppler-qt4.h>
int main()
{
Poppler::PageTransition *p = 0;
return p->durationReal();
}
" HAVE_POPPLER_0_37)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
if (HAVE_POPPLER_0_37)
set(popplerVersionMessage "0.37")
elseif (HAVE_POPPLER_0_28)
set(popplerVersionMessage "0.28")
elseif (HAVE_POPPLER_0_24)
set(popplerVersionMessage "0.24")
elseif (HAVE_POPPLER_0_36)
set(popplerVersionMessage "0.36")
endif ()
if (NOT Poppler_FIND_QUIETLY)
message(STATUS "Found Poppler-Qt5: ${POPPLER_LIBRARY}, (>= ${popplerVersionMessage})")
endif (NOT Poppler_FIND_QUIETLY)
else (POPPLER_FOUND)
if (Poppler_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find Poppler-Qt5")
endif (Poppler_FIND_REQUIRED)
message(STATUS "Could not find OPTIONAL package Poppler-Qt5")
endif (POPPLER_FOUND)
# 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(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)

View file

@ -7,10 +7,8 @@ function(okular_add_generator _target)
)
endfunction()
find_package(Poppler-Qt5 "0.12.1")
set_package_properties("Poppler-Qt5" PROPERTIES
DESCRIPTION "A PDF rendering library"
URL "http://poppler.freedesktop.org"
find_package(Poppler "0.12.1" COMPONENTS Qt5)
set_package_properties("Poppler" PROPERTIES
TYPE RECOMMENDED
PURPOSE "Support for PDF files in okular.")
@ -87,9 +85,9 @@ set_package_properties("libqmobipocket" PROPERTIES
# let's enable the generators properly configured
if(POPPLER_FOUND)
if(Poppler_Qt5_FOUND)
add_subdirectory(poppler)
endif(POPPLER_FOUND)
endif(Poppler_Qt5_FOUND)
if(LIBSPECTRE_FOUND)
add_subdirectory(spectre)

View file

@ -1,19 +1,26 @@
add_subdirectory( conf )
set(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIR} ${QT_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_LIBRARY} Qt5::Xml)
if (Poppler_VERSION VERSION_GREATER "0.23.99")
set (HAVE_POPPLER_0_24 1)
endif()
if (Poppler_VERSION VERSION_GREATER "0.27.99")
set (HAVE_POPPLER_0_28 1)
endif()
if (Poppler_VERSION VERSION_GREATER "0.35.99")
set (HAVE_POPPLER_0_36 1)
endif()
if (Poppler_VERSION VERSION_GREATER "0.36.99")
set (HAVE_POPPLER_0_37 1)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-okular-poppler.h
)
# Can be multiple include directories for poppler
separate_arguments(POPPLER_INCLUDE_DIR)
foreach(_include_dir ${POPPLER_INCLUDE_DIR})
include_directories(${_include_dir})
endforeach(_include_dir ${POPPLER_INCLUDE_DIR})
include_directories(
${CMAKE_BINARY_DIR}/okular
${CMAKE_CURRENT_SOURCE_DIR}/../..
@ -35,7 +42,7 @@ kconfig_add_kcfg_files(okularGenerator_poppler_PART_SRCS conf/pdfsettings.kcfgc
okular_add_generator(okularGenerator_poppler ${okularGenerator_poppler_PART_SRCS})
target_link_libraries(okularGenerator_poppler ${POPPLER_LIBRARY} okularcore KF5::I18n Qt5::Xml KF5::Completion)
target_link_libraries(okularGenerator_poppler okularcore KF5::I18n KF5::Completion Poppler::Qt5 Qt5::Xml)
########### install files ###############