[poppler] 3 commits - CMakeLists.txt cmake/modules
CMakeLists.txt| 15 +- cmake/modules/PopplerMacros.cmake | 87 ++ 2 files changed, 65 insertions(+), 37 deletions(-) New commits: commit f8bcfde24f52e66dd98b8ae62057742bd3add35e Author: Alex Richardson Date: Tue Jul 13 15:16:31 2021 +0100 cmake: correctly forward user-provided flags to try_compile() Poppler overrides the user-provided CMAKE_{C,CXX}_FLAGS and appends them to the per-configuration variables instead. This behaviour currently causes cross-compilation checks to fail since a CMake issue means these these per-configuration flags are no passed to try_compile() commands. In my case the flags specified in the toolchain file (as part of CMAKE_{C,CXX}_FLAGS_INIT) are absolutely required to compile successfully since a missing `-mabi=/-march=` flag will result in a linker error due to trying to link incompatible libraries. If CMAKE_TRY_COMPILE_CONFIGURATION is empty CMake will no propagate the per-configuration flags to try_compile() so we have to to set the value explicitly. This is an upstream CMake issue: See https://gitlab.kitware.com/cmake/cmake/-/issues/22414 and https://gitlab.kitware.com/cmake/cmake/-/issues/19512. diff --git a/CMakeLists.txt b/CMakeLists.txt index edf63819..f1785286 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,21 @@ cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR) project(poppler) - set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) include(PopplerDefaults) include(PopplerMacros) +# Ensure that the user-provided C_FLAGS are used for try_compile() calls. +# This is needed since PopplerMacros.cmake clears CMAKE_C_FLAGS and if +# CMAKE_TRY_COMPILE_CONFIGURATION is empty CMake only uses the flags +# specified in CMAKE_C_FLAGS (https://gitlab.kitware.com/cmake/cmake/-/issues/22414 +# and https://gitlab.kitware.com/cmake/cmake/-/issues/19512). +# We therefore have to explicitly set CMAKE_TRY_COMPILE_CONFIGURATION until we +# depend on a CMake release that includes a fix for those issues. +# This is set after including PopplerMacros since that sets the default +# CMAKE_BUILD_TYPE and also sets _CMAKE_BUILD_TYPE_UPPER. +set(CMAKE_TRY_COMPILE_CONFIGURATION "${_CMAKE_BUILD_TYPE_UPPER}") + include(MacroOptionalFindPackage) find_package(PkgConfig) if (WIN32) commit 53ecbfc9af7a490ad49353b1e2b5011a66c0f100 Author: Alex Richardson Date: Tue Jul 13 15:04:36 2021 +0100 Always append to CMAKE_{C,CXX}_FLAGS_${CMAKE_BUILD_TYPE} Currently the user/toolchain-provided CMAKE_{C,CXX}_FLAGS can be lost if the user selects a CMAKE_BUILD_TYPE that is not handled by PopplerMacros.cmake. To avoid this problem use a foreach() loop over all known build types plus the current CMAKE_BUILD_TYPE that appends to the per-configuration flags. diff --git a/cmake/modules/PopplerMacros.cmake b/cmake/modules/PopplerMacros.cmake index fe1182da..2aed0284 100644 --- a/cmake/modules/PopplerMacros.cmake +++ b/cmake/modules/PopplerMacros.cmake @@ -79,6 +79,20 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE RelWithDebInfo) endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) +string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE_UPPER) +set(_known_build_types RELWITHDEBINFO;RELEASE;DEBUG;DEBUGFULL;PROFILE) +# We override CMAKE_CXX_FLAGS_${_CMAKE_BUILD_TYPE_UPPER} below. If the user +# selects a CMAKE_BUILD_TYPE that is not handled by the logic below, we will +# end up dropping the previous flags (e.g. those set in a cross-compilation +# CMake toolchain file). To avoid surprising compilation errors, we emit an +# error in that case, so that the user can handle the passed CMAKE_BUILD_TYPE +# in the compiler flags logic below. +if (NOT "${_CMAKE_BUILD_TYPE_UPPER}" IN_LIST _known_build_types) + message(FATAL_ERROR "Unsupported CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +endif() +set(_save_cflags "${CMAKE_C_FLAGS}") +set(_save_cxxflags "${CMAKE_CXX_FLAGS}") + if(CMAKE_COMPILER_IS_GNUCXX) # set the default compile warnings set(_warn "-Wall -Wextra -Wpedantic") @@ -103,20 +117,18 @@ if(CMAKE_COMPILER_IS_GNUCXX) set(DEFAULT_COMPILE_WARNINGS "${_warn}") set(DEFAULT_COMPILE_WARNINGS_EXTRA "${_warn} ${_warnx}") - set(_save_cxxflags "${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS"-fno-exceptions -fno-check-new -fno-common -fno-operator-names -D_DEFAULT_SOURCE") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${_save_cxxflags}") - set(CMAKE_CXX_FLAGS_RELEASE"-O2 -DNDEBUG ${_save_cxxflags}") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline ${_save_cxxflags}") - set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline ${_save_cxxflags}") - set(CMAKE_CXX_FLAGS_PROFILE"-g3 -fno-inline -ftest-coverage -fprofile-arcs ${_save_cxxflags}") - set(_save_cflags "${CMAKE_C_FLAGS}") +
[poppler] 3 commits - CMakeLists.txt cmake/modules glib/poppler-document.cc poppler/Annot.cc poppler/Annot.h poppler/CachedFile.cc poppler/CachedFile.h poppler/CairoOutputDev.cc poppler/JBIG2Stream.cc
CMakeLists.txt|1 + cmake/modules/PopplerMacros.cmake |1 + glib/poppler-document.cc |4 poppler/Annot.cc |4 poppler/Annot.h |3 ++- poppler/CachedFile.cc |4 +++- poppler/CachedFile.h |4 ++-- poppler/CairoOutputDev.cc |5 - poppler/JBIG2Stream.cc|6 -- poppler/Link.cc |2 ++ poppler/Link.h|1 + poppler/PDFDocBuilder.cc | 13 + poppler/PDFDocBuilder.h |4 ++-- poppler/SplashOutputDev.cc|4 +++- poppler/Stream.cc | 10 ++ poppler/Stream.h |4 ++-- poppler/TextOutputDev.cc |4 +++- poppler/XRef.cc |2 ++ poppler/XRef.h|2 +- qt5/src/poppler-annotation.cc | 14 -- qt5/src/poppler-link-private.h|6 -- qt5/src/poppler-link.cc | 24 +++- qt5/src/poppler-page.cc |7 +++ qt5/src/poppler-pdf-converter.cc |5 - qt5/src/poppler-ps-converter.cc |5 - qt6/src/poppler-annotation.cc | 18 ++ qt6/src/poppler-link-private.h|6 -- qt6/src/poppler-link.cc | 29 - qt6/src/poppler-page.cc |7 +++ qt6/src/poppler-pdf-converter.cc |5 - qt6/src/poppler-ps-converter.cc |5 - qt6/tests/stress-threads-qt6.cpp |7 +++ splash/SplashPattern.cc |7 +++ splash/SplashPattern.h|2 ++ utils/pdftohtml.cc|7 +-- 35 files changed, 188 insertions(+), 44 deletions(-) New commits: commit 148e5424e6f0deb7680fdc9b25736888089b6b41 Author: Albert Astals Cid Date: Thu Oct 29 13:47:13 2020 +0100 clang: Warn about weak-vtables diff --git a/CMakeLists.txt b/CMakeLists.txt index 7487875a..d0361f34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -405,6 +405,7 @@ set(poppler_SRCS poppler/PageTransition.cc poppler/Parser.cc poppler/PDFDoc.cc + poppler/PDFDocBuilder.cc poppler/PDFDocEncoding.cc poppler/PDFDocFactory.cc poppler/ProfileData.cc diff --git a/cmake/modules/PopplerMacros.cmake b/cmake/modules/PopplerMacros.cmake index a9d20948..6e5f0050 100644 --- a/cmake/modules/PopplerMacros.cmake +++ b/cmake/modules/PopplerMacros.cmake @@ -159,6 +159,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(_warn "${_warn} -Wundef") set(_warn "${_warn} -Wzero-as-null-pointer-constant") set(_warn "${_warn} -Wshadow") + set(_warn "${_warn} -Wweak-vtables") # set extra warnings set(_warnx "${_warnx} -Wconversion") diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index e91fe342..d7e650be 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -5,6 +5,7 @@ * Copyright (C) 2018-2019 Marek Kasik * Copyright (C) 2019 Masamichi Hosoda * Copyright (C) 2019, Oliver Sander + * Copyright (C) 2020 Albert Astals Cid * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -251,8 +252,11 @@ class BytesStream : public MemStream public: BytesStream(GBytes *bytes, Object &) : MemStream(static_cast(g_bytes_get_data(bytes, nullptr)), 0, g_bytes_get_size(bytes), std::move(dictA)), m_bytes { g_bytes_ref(bytes), _bytes_unref } { } +~BytesStream() override; }; +BytesStream::~BytesStream() = default; + /** * poppler_document_new_from_bytes: * @bytes: a #GBytes diff --git a/poppler/Annot.cc b/poppler/Annot.cc index 11231d91..b6e4d32b 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -344,12 +344,16 @@ void AnnotPath::parsePathArray(Array *array) AnnotCalloutLine::AnnotCalloutLine(double x1, double y1, double x2, double y2) : coord1(x1, y1), coord2(x2, y2) { } +AnnotCalloutLine::~AnnotCalloutLine() = default; + // // AnnotCalloutMultiLine // AnnotCalloutMultiLine::AnnotCalloutMultiLine(double x1, double y1, double x2, double y2, double x3, double y3) : AnnotCalloutLine(x1, y1, x2, y2), coord3(x3, y3) { } +AnnotCalloutMultiLine::~AnnotCalloutMultiLine() = default; + // // AnnotQuadrilateral // diff --git a/poppler/Annot.h b/poppler/Annot.h index efa3a658..0d7bf174 100644 --- a/poppler/Annot.h +++ b/poppler/Annot.h @@ -140,7 +140,7 @@ class AnnotCalloutLine { public: AnnotCalloutLine(double x1, double y1, double x2, double y2); -virtual ~AnnotCalloutLine() { } +virtual ~AnnotCalloutLine(); AnnotCalloutLine(const
[poppler] 3 commits - CMakeLists.txt cmake/modules glib/CMakeLists.txt glib/demo glib/tests
CMakeLists.txt |2 ++ cmake/modules/FindGTK.cmake |6 +- glib/CMakeLists.txt | 14 +++--- glib/demo/CMakeLists.txt|7 ++- glib/tests/CMakeLists.txt | 11 +-- 5 files changed, 25 insertions(+), 15 deletions(-) New commits: commit 2fd2acd7f0e5710b8e7b1138b519549e7f3d6750 Author: Kyle Auble Date: Fri Oct 16 17:18:42 2020 -0400 cmake: Deduplicate _list_prefix macro The macro is only used after an identical version (_gir_list_prefix) is included with GObjectIntrospectionMacros. diff --git a/glib/CMakeLists.txt b/glib/CMakeLists.txt index fd76b150..f0aaf990 100644 --- a/glib/CMakeLists.txt +++ b/glib/CMakeLists.txt @@ -115,14 +115,6 @@ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c" ) - -macro(_list_prefix _outvar _listvar _prefix) - set(${_outvar}) - foreach(_item IN LISTS ${_listvar}) -list(APPEND ${_outvar} ${_prefix}${_item}) - endforeach() -endmacro(_list_prefix) - # GObject Introspection if (HAVE_INTROSPECTION AND BUILD_SHARED_LIBS) include(GObjectIntrospectionMacros) @@ -141,7 +133,7 @@ if (HAVE_INTROSPECTION AND BUILD_SHARED_LIBS) # Format list of include directories as compiler flags get_directory_property(_tmp_includes INCLUDE_DIRECTORIES) - _list_prefix(_includes _tmp_includes "-I") + _gir_list_prefix(_includes _tmp_includes "-I") # And set flags for gir compiler and scanner set(Poppler_0_18_gir_CFLAGS ${_includes} -L${CMAKE_BINARY_DIR} -L${CMAKE_CURRENT_BINARY_DIR}) set(Poppler_0_18_gir_SCANNERFLAGS "--c-include=poppler.h") @@ -150,8 +142,8 @@ if (HAVE_INTROSPECTION AND BUILD_SHARED_LIBS) set(orig_introspect_srcs ${poppler_glib_SRCS} ${poppler_glib_public_headers}) set(gen_introspect_srcs "poppler-enums.c" "poppler-enums.h" "poppler-features.h") # Prefix the files with their correct directories for full paths - _list_prefix(_orig_introspect_paths orig_introspect_srcs "${CMAKE_CURRENT_SOURCE_DIR}/") - _list_prefix(_gen_introspect_paths gen_introspect_srcs "${CMAKE_CURRENT_BINARY_DIR}/") + _gir_list_prefix(_orig_introspect_paths orig_introspect_srcs "${CMAKE_CURRENT_SOURCE_DIR}/") + _gir_list_prefix(_gen_introspect_paths gen_introspect_srcs "${CMAKE_CURRENT_BINARY_DIR}/") # Now load them to the final file list set(Poppler_0_18_gir_FILES ${_orig_introspect_paths} ${_gen_introspect_paths}) commit 8b7dec2843999f8c3d77d921bd58688fbf4ff313 Author: Kyle Auble Date: Sat Oct 10 16:51:12 2020 -0400 cmake: Finish making FindGTK more robust * Add CMake guards to fix #831 and close !605 * Move pkg-config calls to FindGTK & parameterize GTK versions diff --git a/CMakeLists.txt b/CMakeLists.txt index 3da3fb3b..7487875a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,8 @@ set(TEXTOUT_WORD_LIST ON) # setting the minimum required versions for some components set(CAIRO_VERSION "1.10.0") set(GLIB_REQUIRED "2.41") +set(GTK_REQUIRED "3.8") +set(GDK_PIXBUF_REQUIRED "2.8") macro_bool_to_01(ENABLE_SPLASH HAVE_SPLASH) find_package(Freetype REQUIRED) diff --git a/cmake/modules/FindGTK.cmake b/cmake/modules/FindGTK.cmake index 3cc78438..5f793aac 100644 --- a/cmake/modules/FindGTK.cmake +++ b/cmake/modules/FindGTK.cmake @@ -16,6 +16,10 @@ include(FindPackageHandleStandardArgs) find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK3 "gtk+-3.0>=3.8" "gdk-pixbuf-2.0>=2.8") +if(${CMAKE_VERSION} VERSION_LESS "3.6.0") +pkg_check_modules(GTK3 "gtk+-3.0>=${GTK_REQUIRED}" "gdk-pixbuf-2.0>=${GDK_PIXBUF_REQUIRED}") +else() +pkg_check_modules(GTK3 IMPORTED_TARGET "gtk+-3.0>=${GTK_REQUIRED}" "gdk-pixbuf-2.0>=${GDK_PIXBUF_REQUIRED}") +endif() find_package_handle_standard_args(GTK DEFAULT_MSG GTK3_LIBRARIES GTK3_CFLAGS) diff --git a/glib/demo/CMakeLists.txt b/glib/demo/CMakeLists.txt index c3c7e166..5add9ca8 100644 --- a/glib/demo/CMakeLists.txt +++ b/glib/demo/CMakeLists.txt @@ -27,6 +27,9 @@ set(poppler_glib_demo_SRCS taggedstruct.c ) poppler_add_test(poppler-glib-demo BUILD_GTK_TESTS ${poppler_glib_demo_SRCS}) -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK3 REQUIRED IMPORTED_TARGET gtk+-3.0) -target_link_libraries(poppler-glib-demo ${CAIRO_LIBRARIES} poppler-glib PkgConfig::GTK3) + +if(${CMAKE_VERSION} VERSION_LESS "3.6.0") +target_link_libraries(poppler-glib-demo ${CAIRO_LIBRARIES} poppler-glib ${GTK3_LIBRARIES}) +else() +target_link_libraries(poppler-glib-demo ${CAIRO_LIBRARIES} poppler-glib PkgConfig::GTK3) +endif() diff --git a/glib/tests/CMakeLists.txt b/glib/tests/CMakeLists.txt index 096de1b8..acac077d 100644 --- a/glib/tests/CMakeLists.txt +++ b/glib/tests/CMakeLists.txt @@ -13,15 +13,19 @@ set(poppler_check_text_SRCS check_text.c ) poppler_add_unittest(poppler-check-text BUILD_GTK_TESTS ${poppler_check_text_SRCS}) -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK3
[poppler] 3 commits - CMakeLists.txt cmake/modules cpp/CMakeLists.txt qt4/tests qt5/CMakeLists.txt qt5/demos qt5/src qt5/tests
CMakeLists.txt |4 -- cmake/modules/FindLIBOPENJPEG.cmake | 37 -- cpp/CMakeLists.txt |3 -- qt4/tests/CMakeLists.txt| 44 +++ qt5/CMakeLists.txt |2 + qt5/demos/CMakeLists.txt|2 - qt5/src/CMakeLists.txt |2 - qt5/tests/CMakeLists.txt| 50 +--- 8 files changed, 73 insertions(+), 71 deletions(-) New commits: commit e3b09727ad96a03ba1250f49486948899b4df793 Author: Adam ReicholdDate: Fri Dec 25 14:10:03 2015 +0100 Make detection of version one of OpenJPEG prefer a pkg-config manifest if it exists. diff --git a/CMakeLists.txt b/CMakeLists.txt index 8558564..4e8bcfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -442,7 +442,6 @@ elseif (LIBOPENJPEG2_FOUND) poppler/JPEG2000Stream.cc ) add_definitions(-DUSE_OPENJPEG2) -MESSAGE(${LIBOPENJPEG2_LIBRARIES}) set(poppler_LIBS ${poppler_LIBS} ${LIBOPENJPEG2_LIBRARIES}) else () set(poppler_SRCS ${poppler_SRCS} diff --git a/cmake/modules/FindLIBOPENJPEG.cmake b/cmake/modules/FindLIBOPENJPEG.cmake index d9c1369..8a49193 100644 --- a/cmake/modules/FindLIBOPENJPEG.cmake +++ b/cmake/modules/FindLIBOPENJPEG.cmake @@ -23,31 +23,40 @@ else (LIBOPENJPEG_LIBRARIES AND LIBOPENJPEG_INCLUDE_DIR) set(LIBOPENJPEG_LIBRARIES) set(LIBOPENJPEG_INCLUDE_DIR) - find_path (LIBOPENJPEG_INCLUDE_DIR openjpeg.h PATH_SUFFIXES openjpeg) - find_library(LIBOPENJPEG_LIBRARIES openjpeg) - if(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES) + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBOPENJPEG libopenjpeg) - set(CMAKE_REQUIRED_INCLUDES ${LIBOPENJPEG_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${LIBOPENJPEG_LIBRARIES}) + if(LIBOPENJPEG_FOUND) +add_definitions(-DUSE_OPENJPEG1) +set(LIBOPENJPEG_INCLUDE_DIR ${LIBOPENJPEG_INCLUDE_DIRS}) + else(LIBOPENJPEG_FOUND) -check_cxx_source_compiles(" +find_path (LIBOPENJPEG_INCLUDE_DIR openjpeg.h PATH_SUFFIXES openjpeg) +find_library(LIBOPENJPEG_LIBRARIES openjpeg) +if(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES) + + set(CMAKE_REQUIRED_INCLUDES ${LIBOPENJPEG_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${LIBOPENJPEG_LIBRARIES}) + + check_cxx_source_compiles(" #include int main() { int foo = OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; return 0; -} -" WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG) +}" +WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG) - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_LIBRARIES) -set(LIBOPENJPEG_FOUND TRUE) - endif(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES) + set(LIBOPENJPEG_FOUND TRUE) +endif(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(LibOpenJPEG DEFAULT_MSG LIBOPENJPEG_LIBRARIES LIBOPENJPEG_INCLUDE_DIR) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibOpenJPEG DEFAULT_MSG LIBOPENJPEG_LIBRARIES LIBOPENJPEG_INCLUDE_DIR) + endif (LIBOPENJPEG_FOUND) endif (LIBOPENJPEG_LIBRARIES AND LIBOPENJPEG_INCLUDE_DIR) set(LIBOPENJPEG_INCLUDE_DIRS ${LIBOPENJPEG_INCLUDE_DIR}) commit 7c880daecfcddac2f8181d5f3d506dd409812dbe Author: Adam Reichold Date: Fri Dec 25 14:10:03 2015 +0100 Make use of LINK_PRIVATE flag to fix warning on CMake policy 0022. diff --git a/CMakeLists.txt b/CMakeLists.txt index a1412d8..8558564 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -479,8 +479,7 @@ else(MSVC) add_library(poppler SHARED ${poppler_SRCS}) endif(MSVC) set_target_properties(poppler PROPERTIES VERSION 58.0.0 SOVERSION 58) -target_link_libraries(poppler ${poppler_LIBS}) -target_link_libraries(poppler LINK_INTERFACE_LIBRARIES "") +target_link_libraries(poppler LINK_PRIVATE ${poppler_LIBS}) install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) if(ENABLE_XPDF_HEADERS) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 5a94219..1128016 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -26,9 +26,8 @@ add_library(poppler-cpp SHARED ${poppler_cpp_SRCS}) set_target_properties(poppler-cpp PROPERTIES VERSION 0.2.1 SOVERSION 0) target_link_libraries(poppler-cpp poppler ${ICONV_LIBRARIES}) if(MSVC) -target_link_libraries(poppler-cpp ${poppler_LIBS}) +target_link_libraries(poppler-cpp LINK_PRIVATE ${poppler_LIBS}) endif(MSVC) -target_link_libraries(poppler-cpp LINK_INTERFACE_LIBRARIES "") install(TARGETS poppler-cpp RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) install(FILES commit 4a413b9b95d5c6815c91adb815254cce97dd5b4b Author: Adam Reichold Date: Fri Dec 25
[poppler] 3 commits - CMakeLists.txt cmake/modules configure.ac poppler/JPEG2000Stream.cc poppler/JPEG2000Stream.h
CMakeLists.txt | 56 - cmake/modules/FindLIBOPENJPEG2.cmake | 30 ++ configure.ac | 80 +-- poppler/JPEG2000Stream.cc| 366 +-- poppler/JPEG2000Stream.h | 41 +-- 5 files changed, 453 insertions(+), 120 deletions(-) New commits: commit e499fdab2e96cb3069db7ac8ffa0df20ddc9 Author: Thomas Freitag thomas.frei...@alfa.de Date: Sun Jan 4 20:23:39 2015 +0100 extended openjpeg2 support diff --git a/poppler/JPEG2000Stream.cc b/poppler/JPEG2000Stream.cc index 77a153b..2d48899 100644 --- a/poppler/JPEG2000Stream.cc +++ b/poppler/JPEG2000Stream.cc @@ -6,6 +6,7 @@ // // Copyright 2008-2010, 2012 Albert Astals Cid aa...@kde.org // Copyright 2011 Daniel Glöckner daniel...@gmx.net +// Copyright 2014 Thomas Freitag thomas.frei...@alfa.de // Copyright 2013,2014 Adrian Johnson ajohn...@redneon.com // // Licensed under GPLv2 or later @@ -44,7 +45,7 @@ struct JPXStreamPrivate { void init2(unsigned char *buf, int bufLen, OPJ_CODEC_FORMAT format); #endif #ifdef USE_OPENJPEG2 - void init2(opj_stream_t *stream, OPJ_CODEC_FORMAT format); + void init2(OPJ_CODEC_FORMAT format, unsigned char *data, int length); #endif }; @@ -140,6 +141,8 @@ void JPXStream::getImageParams(int *bitsPerComponent, StreamColorSpaceMode *csMo *bitsPerComponent = 8; if (priv-image priv-image-numcomps == 3) *csMode = streamCSDeviceRGB; + else if (priv-image priv-image-numcomps == 4) +*csMode = streamCSDeviceCMYK; else *csMode = streamCSDeviceGray; } @@ -225,7 +228,6 @@ void JPXStreamPrivate::init2(unsigned char *buf, int bufLen, OPJ_CODEC_FORMAT fo /* Get the decoder handle of the format */ dinfo = opj_create_decompress(format); if (dinfo == NULL) goto error; - /* Catch events using our callbacks */ opj_set_event_mgr((opj_common_ptr)dinfo, event_mgr, NULL); @@ -260,35 +262,64 @@ error: #ifdef USE_OPENJPEG2 -static OPJ_SIZE_T readStream_callback(void *buffer, OPJ_SIZE_T nBytes, void *userData) +typedef struct JPXData_s +{ + unsigned char *data; + int size; + int pos; +} JPXData; + +#define BUFFER_INITIAL_SIZE 4096 + +static OPJ_SIZE_T jpxRead_callback(void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) { + JPXData *jpxData = (JPXData *)p_user_data; int len; - JPXStream *p = (JPXStream *)userData; - len = p-readStream(nBytes, (Guchar*)buffer); + len = jpxData-size - jpxData-pos; + if (len 0) +len = 0; if (len == 0) -return (OPJ_SIZE_T)-1; - else -return len; +return (OPJ_SIZE_T)-1; /* End of file! */ + if ((OPJ_SIZE_T)len p_nb_bytes) +len = p_nb_bytes; + memcpy(p_buffer, jpxData-data + jpxData-pos, len); + jpxData-pos += len; + return len; } -void JPXStream::init() +static OPJ_OFF_T jpxSkip_callback(OPJ_OFF_T skip, void * p_user_data) { - opj_stream_t *stream; + JPXData *jpxData = (JPXData *)p_user_data; - str-reset(); - stream = opj_stream_default_create(OPJ_TRUE); + jpxData-pos += (skip jpxData-size - jpxData-pos) ? jpxData-size - jpxData-pos : skip; + /* Always return input value to avoid Problem with skipping JPEG2000 box, stream error */ + return skip; +} -#if OPENJPEG_VERSION = OPENJPEG_VERSION_ENCODE(2, 1, 0) - opj_stream_set_user_data (stream, this, NULL); -#else - opj_stream_set_user_data (stream, this); -#endif +static OPJ_BOOL jpxSeek_callback(OPJ_OFF_T seek_pos, void * p_user_data) +{ + JPXData *jpxData = (JPXData *)p_user_data; - opj_stream_set_read_function(stream, readStream_callback); - priv-init2(stream, OPJ_CODEC_JP2); + if (seek_pos jpxData-size) +return OPJ_FALSE; + jpxData-pos = seek_pos; + return OPJ_TRUE; +} - opj_stream_destroy(stream); +void JPXStream::init() +{ + Object oLen; + if (getDict()) getDict()-lookup(Length, oLen); + + int bufSize = BUFFER_INITIAL_SIZE; + if (oLen.isInt()) bufSize = oLen.getInt(); + oLen.free(); + + int length = 0; + unsigned char *buf = str-toUnsignedChars(length, bufSize); + priv-init2(OPJ_CODEC_JP2, buf, length); + gfree(buf); if (priv-image) { priv-npixels = priv-image-comps[0].w * priv-image-comps[0].h; @@ -325,8 +356,30 @@ void JPXStream::init() priv-inited = gTrue; } -void JPXStreamPrivate::init2(opj_stream_t *stream, OPJ_CODEC_FORMAT format) +void JPXStreamPrivate::init2(OPJ_CODEC_FORMAT format, unsigned char *buf, int length) { + JPXData jpxData; + + jpxData.data = buf; + jpxData.pos = 0; + jpxData.size = length; + + opj_stream_t *stream; + + stream = opj_stream_default_create(OPJ_TRUE); + +#if OPENJPEG_VERSION = OPENJPEG_VERSION_ENCODE(2, 1, 0) + opj_stream_set_user_data (stream, jpxData, NULL); +#else + opj_stream_set_user_data (stream, jpxData); +#endif + + opj_stream_set_read_function(stream, jpxRead_callback); + opj_stream_set_skip_function(stream, jpxSkip_callback); + opj_stream_set_seek_function(stream, jpxSeek_callback); + /* Set the length to avoid an assert */ +