From af76b804116efa33a7108e99dffb14a683aaf56d Mon Sep 17 00:00:00 2001 From: Jehan Date: Sat, 26 Jul 2014 14:56:40 +0000 Subject: [PATCH] configure/cmake: use new poppler-data pkg-config file if available. poppler-data package would now advertize its datadir path with a pkg-config file. This is better than having to guess it from poppler's prefix, or having the package builder manually set --datarootdir. --- CMakeLists.txt | 16 ++++++++++++++++ config.h.cmake | 2 +- configure.ac | 7 ++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e100cd3..913d9f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,22 @@ if(LCMS2_FOUND) include_directories(${LCMS2_INCLUDE_DIR}) endif(LCMS2_FOUND) +# Recent versions of poppler-data install a .pc file. +# Use it to determine the encoding data path, if available. +# Default to the same prefix otherwise. +pkg_check_modules(POPPLER_DATA poppler-data) +if(POPPLER_DATA_FOUND) + execute_process(COMMAND "${PKG_CONFIG_EXECUTABLE}" --variable=poppler_datadir poppler-data + RESULT_VARIABLE _result_var + OUTPUT_VARIABLE _output_var OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") + set(POPPLER_DATADIR "${_output_var}") + endif(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") +endif(POPPLER_DATA_FOUND) +if(NOT DEFINED POPPLER_DATADIR) + set(POPPLER_DATADIR "${CMAKE_INSTALL_PREFIX}/share/poppler") +endif(NOT DEFINED POPPLER_DATADIR) + if(DEFINED COMPILE_WARNINGS) else(DEFINED COMPILE_WARNINGS) set(COMPILE_WARNINGS "yes") diff --git a/config.h.cmake b/config.h.cmake index b707ba7..8ed1c92 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -169,7 +169,7 @@ #define PACKAGE_VERSION "${POPPLER_VERSION}" /* Poppler data dir */ -#define POPPLER_DATADIR "${CMAKE_INSTALL_PREFIX}/share/poppler" +#define POPPLER_DATADIR "${POPPLER_DATADIR}" /* Support for curl based doc builder is compiled in. */ #cmakedefine POPPLER_HAS_CURL_SUPPORT 1 diff --git a/configure.ac b/configure.ac index 9436fdd..ea6b045 100644 --- a/configure.ac +++ b/configure.ac @@ -105,7 +105,12 @@ if test x$enable_relocatable = xyes; then fi fi -AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir]) +dnl ##### Check for installed poppler-data. Use the same datarootdir as default otherwise. +PKG_CHECK_EXISTS(poppler-data, + [POPPLER_DATADIR=`$PKG_CONFIG --variable=poppler_datadir poppler-data` + AC_DEFINE_DIR(POPPLER_DATADIR, "{POPPLER_DATADIR}", [Poppler data dir])], + [AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])] + ) dnl ##### Checks for header files. AC_PATH_XTRA -- 1.8.1.2