-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCMakeLists.txt
148 lines (124 loc) · 3.28 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
cmake_minimum_required(VERSION 3.15)
set(VERSION "1.0.0" CACHE STRING "PDF rendering library based on PDFium")
project(deepin-pdfium
VERSION ${VERSION}
DESCRIPTION "PDF rendering library based on PDFium"
LANGUAGES CXX C
)
# 设置C++标准
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
-D_FORTITY_SOURCE=1
-z noexecstack
-pie
-fPIC
-Wno-unused-parameter
)
# 添加链接选项
add_link_options(
-z lazy
)
# 获取系统页大小
execute_process(
COMMAND getconf PAGESIZE
OUTPUT_VARIABLE SYSTEM_PAGE_SIZE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions(-DSYSTEMPAGESIZE=${SYSTEM_PAGE_SIZE})
# 查找Qt6依赖包
find_package(Qt6 COMPONENTS Core Gui REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(DEPS REQUIRED
chardet
lcms2
freetype2
libopenjp2
)
# PDFium 第三方库
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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/deepin-pdfium>
PRIVATE
${DEPS_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
pdfium
Qt6::Core
Qt6::Gui
${DEPS_LIBRARIES}
z
jpeg
icuuc
)
# 安装
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES
include/dpdfglobal.h
include/dpdfdoc.h
include/dpdfpage.h
include/dpdfannot.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/deepin-pdfium
)
# pkg-config
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/deepin-pdfium.pc.in
${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfium.pc
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfium.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
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
)