Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ cmake_minimum_required(VERSION 3.15)

set(VERSION "1.0.0" CACHE STRING "PDF rendering library based on PDFium")

# Normalize VERSION format to handle irregular inputs
if(DEFINED VERSION)
# Extract major.minor.patch from VERSION string (e.g., from "1.5.8+u001" to "1.5.8")
if(VERSION MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)")
set(VERSION "${CMAKE_MATCH_1}")
else()
# If no valid semver found, default to "1.0.0"
set(VERSION "1.0.0")
message(WARNING "VERSION does not match semver format, defaulted to ${VERSION}")
endif()
endif()

project(deepin-pdfium
VERSION ${VERSION}
DESCRIPTION "PDF rendering library based on PDFium"
Expand Down Expand Up @@ -39,13 +51,13 @@ execute_process(
)
add_definitions(-DSYSTEMPAGESIZE=${SYSTEM_PAGE_SIZE})

# Qt6必须放前面,否则高版本cmake存在问题
find_package(Qt6 COMPONENTS Core Gui QUIET)
find_package(Qt5 COMPONENTS Core Gui QUIET)
# Auto-detect Qt version (tries Qt6 first, falls back to Qt5)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
message(STATUS "Found Qt version: ${QT_VERSION_MAJOR}")

# Find Qt with the detected version
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)

if(NOT Qt5_FOUND AND NOT Qt6_FOUND)
message(FATAL_ERROR "Neither Qt5 nor Qt6 found - please install at least one")
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(DEPS REQUIRED
chardet
Expand Down Expand Up @@ -79,11 +91,5 @@ include(CMakePackageConfigHelpers)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/deepin-pdfium)
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})

if(Qt6_FOUND)
set(QT_DESIRED_VERSION 6)
else()
set(QT_DESIRED_VERSION 5)
endif()

set(TARGET_NAME ${PROJECT_NAME})
include(target.cmake)
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Priority: optional
Maintainer: deepin <packages@deepin.com>
Build-Depends: debhelper (>= 11),
cmake,
qt6-base-dev | qtbase5-dev,
qt6-tools-dev-tools | qttools5-dev-tools,
qt6-base-dev,
qt6-tools-dev-tools,
pkg-config,
libjpeg-dev,
libicu-dev,
Expand Down
31 changes: 31 additions & 0 deletions debian/control.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Source: deepin-pdfium
Section: libdevel
Priority: optional
Maintainer: deepin <packages@deepin.com>
Build-Depends: debhelper (>= 11),
cmake,
qtbase5-dev,
qttools5-dev-tools,
pkg-config,
libjpeg-dev,
libicu-dev,
libpng-dev,
zlib1g-dev,
liblcms2-dev,
libopenjp2-7-dev,
libfreetype6-dev,
libgtest-dev,
libchardet-dev
Standards-Version: 4.3.0

Package: libdeepin-pdfium
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: A libaray about PDF.
A library for parsing and editing and displaying PDF.

Package: libdeepin-pdfium-dev
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libdeepin-pdfium
Description: A libaray about PDF dev.
A libaray that provides for parsing and editing and displaying PDF interface dev.
5 changes: 3 additions & 2 deletions deepin-pdfium.pc.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
libdir=@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@TARGET_NAME@

Name: @TARGET_NAME@
Description: @PROJECT_DESCRIPTION@ (Qt@QT_DESIRED_VERSION@ version)
Description: @PROJECT_DESCRIPTION@ (Qt@QT_VERSION_MAJOR@ version)
Version: @PROJECT_VERSION@
Libs: -L${libdir} -l@TARGET_NAME@
Cflags: -I${includedir}
Requires: Qt@QT_VERSION_MAJOR@Core Qt@QT_VERSION_MAJOR@Gui
8 changes: 4 additions & 4 deletions target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ target_include_directories(${TARGET_NAME}
target_link_libraries(${TARGET_NAME}
PRIVATE
pdfium
Qt${QT_DESIRED_VERSION}::Core
Qt${QT_DESIRED_VERSION}::Gui
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
${DEPS_LIBRARIES}
z
jpeg
icuuc
)

# 安装Qt6版本
# Install library
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
Expand All @@ -39,7 +39,7 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET_NAME}
)

# 生成Qt6版本的pkg-config文件
# Generate pkg-config file
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/deepin-pdfium.pc.in
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.pc
Expand Down