diff --git a/.reuse/dep5 b/.reuse/dep5 index 1da60ae..a00fce4 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -19,7 +19,7 @@ Copyright: None License: CC0-1.0 # Project file -Files: *CMakeLists.txt *pc.in +Files: *CMakeLists.txt *pc.in *.cmake.in Copyright: None License: CC0-1.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index f39d7b8..5a41c1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.15) +set(VERSION "1.0.0" CACHE STRING "PDF rendering library based on PDFium") + project(deepin-pdfium - VERSION 1.0.0 + VERSION ${VERSION} DESCRIPTION "PDF rendering library based on PDFium" LANGUAGES CXX C ) @@ -10,6 +12,10 @@ project(deepin-pdfium set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + # 编译选项 add_compile_options( -fstack-protector-strong @@ -33,9 +39,6 @@ execute_process( ) add_definitions(-DSYSTEMPAGESIZE=${SYSTEM_PAGE_SIZE}) -# 定义构建宏 -add_definitions(-DBUILD_DEEPDF_LIB) - # 查找Qt6依赖包 find_package(Qt6 COMPONENTS Core Gui REQUIRED) find_package(PkgConfig REQUIRED) @@ -51,15 +54,26 @@ add_subdirectory(src/3rdparty/pdfium) # 主库目标 add_library(${PROJECT_NAME} SHARED + include/dpdfglobal.h + include/dpdfdoc.h + include/dpdfpage.h + include/dpdfannot.h src/dpdfglobal.cpp src/dpdfdoc.cpp src/dpdfpage.cpp src/dpdfannot.cpp ) +# 设置库的版本信息和 SOVERSION +set_target_properties(${PROJECT_NAME} PROPERTIES + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" +) + target_include_directories(${PROJECT_NAME} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include + $ + $ PRIVATE ${DEPS_INCLUDE_DIRS} ) @@ -100,4 +114,35 @@ configure_file( install( FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfium.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig -) \ No newline at end of file +) + +include(CMakePackageConfigHelpers) + +set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/deepin-pdfium) +set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) + +configure_package_config_file( + misc/deepin-pdfiumConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfiumConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deepin-pdfium + PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR +) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfiumConfig.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deepin-pdfium +) + +install(TARGETS deepin-pdfium + EXPORT deepin-pdfiumTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +install(EXPORT deepin-pdfiumTargets + FILE deepin-pdfiumTargets.cmake + NAMESPACE deepin-pdfium:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deepin-pdfium +) diff --git a/README.md b/README.md index 9c7d224..5f49f48 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,18 @@ development library for pdf on Deepin. ### Build dependencies -- qtbase5-dev -- chardet -- lcms2 -- freetype2 -- libopenjp2 +- cmake, +- qt6-base-dev, +- pkg-config, +- libjpeg-dev, +- libicu-dev, +- libpng-dev, +- zlib1g-dev, +- liblcms2-dev, +- libopenjp2-7-dev, +- libfreetype6-dev, +- libgtest-dev, +- libchardet-dev ### Build from source code diff --git a/README.zh_CN.md b/README.zh_CN.md index ec600ae..5de3f62 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -4,11 +4,18 @@ Deepin上的pdf开发库。 ### 编译依赖 -- qtbase5-dev -- chardet -- lcms2 -- freetype2 -- libopenjp2 +- cmake, +- qt6-base-dev, +- pkg-config, +- libjpeg-dev, +- libicu-dev, +- libpng-dev, +- zlib1g-dev, +- liblcms2-dev, +- libopenjp2-7-dev, +- libfreetype6-dev, +- libgtest-dev, +- libchardet-dev ## 安装 diff --git a/debian/changelog b/debian/changelog index df4fe92..785fa3d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +deepin-pdfium (1.5.1) unstable; urgency=medium + + * adapt to Qt6 + + -- Zhang Sheng Fri, 03 Jan 2025 16:49:00 +0800 + deepin-pdfium (1.5.0) unstable; urgency=medium * adapt to Qt6 diff --git a/debian/libdeepin-pdfium-dev.install b/debian/libdeepin-pdfium-dev.install index 0e379f0..396a9b8 100644 --- a/debian/libdeepin-pdfium-dev.install +++ b/debian/libdeepin-pdfium-dev.install @@ -1,2 +1,3 @@ /usr/include/deepin-pdfium/* /usr/lib/*/pkgconfig/deepin-pdfium.pc +/usr/lib/*/cmake/deepin-pdfium/* diff --git a/deepin-pdfium.pc.in b/deepin-pdfium.pc.in index 89d1e77..35696b3 100644 --- a/deepin-pdfium.pc.in +++ b/deepin-pdfium.pc.in @@ -6,6 +6,6 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/deepin-pdfium Name: @PROJECT_NAME@ Description: @PROJECT_DESCRIPTION@ Version: @PROJECT_VERSION@ -Requires: Qt5Core Qt5Gui -Libs: -L${libdir} -ldeepinpdfium -Cflags: -I${includedir} \ No newline at end of file +Requires: Qt6Core Qt6Gui +Libs: -L${libdir} -ldeepin-pdfium +Cflags: -I${includedir} diff --git a/include/dpdfannot.h b/include/dpdfannot.h index f55c2ce..e56cf1e 100644 --- a/include/dpdfannot.h +++ b/include/dpdfannot.h @@ -12,7 +12,7 @@ #include #include -class DEEPDF_EXPORT DPdfAnnot +class DPdfAnnot { public: enum AnnotType { @@ -52,7 +52,7 @@ class DEEPDF_EXPORT DPdfAnnot QString m_text; }; -class DEEPDF_EXPORT DPdfTextAnnot : public DPdfAnnot +class DPdfTextAnnot : public DPdfAnnot { friend class DPdfPage; friend class DPdfPagePrivate; @@ -69,7 +69,7 @@ class DEEPDF_EXPORT DPdfTextAnnot : public DPdfAnnot QRectF m_rect; }; -class DEEPDF_EXPORT DPdfSquareAnnot : public DPdfAnnot +class DPdfSquareAnnot : public DPdfAnnot { public: DPdfSquareAnnot(); @@ -84,7 +84,7 @@ class DEEPDF_EXPORT DPdfSquareAnnot : public DPdfAnnot QRectF m_rect; }; -class DEEPDF_EXPORT DPdfCIRCLEAnnot : public DPdfAnnot +class DPdfCIRCLEAnnot : public DPdfAnnot { friend class DPdfPage; friend class DPdfPagePrivate; @@ -104,7 +104,7 @@ class DEEPDF_EXPORT DPdfCIRCLEAnnot : public DPdfAnnot QRectF m_rect; }; -class DEEPDF_EXPORT DPdfHightLightAnnot : public DPdfAnnot +class DPdfHightLightAnnot : public DPdfAnnot { friend class DPdfPage; friend class DPdfPagePrivate; @@ -126,7 +126,7 @@ class DEEPDF_EXPORT DPdfHightLightAnnot : public DPdfAnnot QColor m_color; }; -class DEEPDF_EXPORT DPdfLinkAnnot : public DPdfAnnot +class DPdfLinkAnnot : public DPdfAnnot { public: DPdfLinkAnnot(); @@ -175,7 +175,7 @@ class DEEPDF_EXPORT DPdfLinkAnnot : public DPdfAnnot float m_top = 0; }; -class DEEPDF_EXPORT DPdfWidgetAnnot : public DPdfAnnot +class DPdfWidgetAnnot : public DPdfAnnot { public: DPdfWidgetAnnot(); @@ -186,7 +186,7 @@ class DEEPDF_EXPORT DPdfWidgetAnnot : public DPdfAnnot }; -class DEEPDF_EXPORT DPdfUnknownAnnot : public DPdfAnnot +class DPdfUnknownAnnot : public DPdfAnnot { public: DPdfUnknownAnnot(); @@ -197,7 +197,7 @@ class DEEPDF_EXPORT DPdfUnknownAnnot : public DPdfAnnot }; -class DEEPDF_EXPORT DPdfUnderlineAnnot : public DPdfAnnot +class DPdfUnderlineAnnot : public DPdfAnnot { public: DPdfUnderlineAnnot(); diff --git a/include/dpdfdoc.h b/include/dpdfdoc.h index 2896d15..2aeae04 100755 --- a/include/dpdfdoc.h +++ b/include/dpdfdoc.h @@ -17,7 +17,7 @@ class DPdfPage; class DPdfDocHandler; class DPdfDocPrivate; -class DEEPDF_EXPORT DPdfDoc : public QObject +class DPdfDoc : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(DPdfDoc) diff --git a/include/dpdfglobal.h b/include/dpdfglobal.h index f33074c..929d118 100755 --- a/include/dpdfglobal.h +++ b/include/dpdfglobal.h @@ -12,16 +12,6 @@ #include #include -#ifndef BUILD_DEEPDF_STATIC -# if defined(BUILD_DEEPDF_LIB) -# define DEEPDF_EXPORT Q_DECL_EXPORT -# else -# define DEEPDF_EXPORT Q_DECL_IMPORT -# endif -#else -# define DEEPDF_EXPORT -#endif - class DPdfGlobal { public: @@ -50,7 +40,7 @@ class DPdfGlobal }; //pdfium即使不同文档之间loadpage和renderpage也不是线程安全,需要加锁 -class DEEPDF_EXPORT DPdfMutexLocker : public QMutexLocker +class DPdfMutexLocker : public QMutexLocker { public: DPdfMutexLocker(const QString &tmpLog); diff --git a/include/dpdfpage.h b/include/dpdfpage.h index 5a846ba..93f3cf9 100755 --- a/include/dpdfpage.h +++ b/include/dpdfpage.h @@ -14,14 +14,14 @@ class DPdfAnnot; class DPdfPagePrivate; class DPdfDocHandler; -class DEEPDF_EXPORT DPdfPage : public QObject +class DPdfPage : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(DPdfPage) friend class DPdfDoc; public: - ~DPdfPage(); + virtual ~DPdfPage(); /** * @brief 是否有效 @@ -182,19 +182,19 @@ class DEEPDF_EXPORT DPdfPage : public QObject * @brief 添加注释时触发 ,在需要的时候可以重新获取annotations() * @param annot 新增加的annot */ - void annotAdded(DPdfAnnot *dAnnot); + void annotAdded(DPdfAnnot *annot); /** * @brief 注释被更新时触发 ,在需要的时候可以重新获取annotations() * @param annot 被更新的annot */ - void annotUpdated(DPdfAnnot *dAnnot); + void annotUpdated(DPdfAnnot *annot); /** * @brief 注释被删除时触发 ,在需要的时候可以重新获取annotations() * @param annot 被移除的annot 注意这个已经是个将要被析构后的地址 只用于做匹配移除 */ - void annotRemoved(DPdfAnnot *dAnnot); + void annotRemoved(DPdfAnnot *annot); private: DPdfPage(DPdfDocHandler *handler, int pageIndex, qreal xRes = 72, qreal yRes = 72); diff --git a/misc/deepin-pdfiumConfig.cmake.in b/misc/deepin-pdfiumConfig.cmake.in new file mode 100644 index 0000000..0eba154 --- /dev/null +++ b/misc/deepin-pdfiumConfig.cmake.in @@ -0,0 +1,23 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# 设置路径 +set_and_check(DEEPIN_PDFIUM_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(DEEPIN_PDFIUM_LIBRARY_DIR "@PACKAGE_LIB_INSTALL_DIR@") + +# 检查依赖 +find_dependency(PkgConfig) +pkg_check_modules(PDFIUM_DEPS REQUIRED + libopenjp2 + lcms2 + freetype2 + zlib + libpng + libjpeg +) + +# 包含导出的目标 +include("${CMAKE_CURRENT_LIST_DIR}/deepin-pdfiumTargets.cmake") + +check_required_components(deepin-pdfium) \ No newline at end of file