-
Notifications
You must be signed in to change notification settings - Fork 45
/
CMakeLists.txt
344 lines (306 loc) · 11.3 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
PROJECT(cr3)
cmake_minimum_required(VERSION 2.6)
#INCLUDE(CPack)
if( ${CMAKE_SYSTEM} MATCHES "Darwin" )
message("MAC OSX build")
SET(MAC 1)
endif( ${CMAKE_SYSTEM} MATCHES "Darwin" )
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
IF(${CMAKE_BUILD_TYPE} STREQUAL Debug)
ADD_DEFINITIONS( -D_DEBUG=1 -DDEBUG=1 )
ELSE()
ADD_DEFINITIONS( -DNDEBUG=1 )
ENDIF(${CMAKE_BUILD_TYPE} STREQUAL Debug)
if(MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic -std=c++11 -fPIC -Wno-misleading-indentation")
endif()
if (NOT DEFINED GUI)
SET(GUI QT)
message("GUI type is not specified!")
message("Using ${GUI} as default")
message("Add cmake parameter -D GUI={QT|WX|CRGUI_XCB|CRGUI_NANOX|CRGUI_PB|CRGUI_QT|CRGUI_JINKE_PLUGIN|CRGUI_WIN32|FB2PROPS} to use another GUI frontend")
else ()
message("Using GUI frontend ${GUI}")
endif (NOT DEFINED GUI)
# Determines whether to use external app EDICT for dictionary
if (NOT DEFINED USE_EXTERNAL_EDICT_DICTIONARY)
SET(USE_EXTERNAL_EDICT_DICTIONARY 0)
else()
SET(USE_EXTERNAL_EDICT_DICTIONARY ${USE_EXTERNAL_EDICT_DICTIONARY})
endif (NOT DEFINED USE_EXTERNAL_EDICT_DICTIONARY)
message("using USE_EXTERNAL_EDICT_DICTIONARY=${USE_EXTERNAL_EDICT_DICTIONARY}")
ADD_DEFINITIONS( -DUSE_EXTERNAL_EDICT_DICTIONARY=${USE_EXTERNAL_EDICT_DICTIONARY} )
# Document buffer cache / compression settings
#whether to compress data
if (NOT DEFINED DOC_DATA_COMPRESSION_LEVEL)
message("-D DOC_DATA_COMPRESSION_LEVEL=0|1|2|3|4|5 parameter is not defined: will use default value")
SET(DOC_DATA_COMPRESSION_LEVEL 1)
else()
SET(DOC_DATA_COMPRESSION_LEVEL ${DOC_DATA_COMPRESSION_LEVEL})
endif (NOT DEFINED DOC_DATA_COMPRESSION_LEVEL)
message("using TEXT_COMPRESSION_LEVEL=${DOC_DATA_COMPRESSION_LEVEL}")
ADD_DEFINITIONS( -DDOC_DATA_COMPRESSION_LEVEL=${DOC_DATA_COMPRESSION_LEVEL} )
# Total RAM buffers size for document
if (NOT DEFINED DOC_BUFFER_SIZE)
message("-D DOC_BUFFER_SIZE=N parameter is not defined: will use default value")
SET(DOC_BUFFER_SIZE 0x400000)
else()
SET(DOC_BUFFER_SIZE ${DOC_BUFFER_SIZE})
endif (NOT DEFINED DOC_BUFFER_SIZE)
message("using DOC_BUFFER_SIZE=${DOC_BUFFER_SIZE}")
ADD_DEFINITIONS( -DDOC_BUFFER_SIZE=${DOC_BUFFER_SIZE} )
# big page margins support
if (NOT DEFINED BIG_PAGE_MARGINS)
SET(BIG_PAGE_MARGINS 0)
else()
SET(BIG_PAGE_MARGINS ${BIG_PAGE_MARGINS})
endif (NOT DEFINED BIG_PAGE_MARGINS)
ADD_DEFINITIONS( -DBIG_PAGE_MARGINS=${BIG_PAGE_MARGINS} )
# big page margins support
if (NOT DEFINED MAX_IMAGE_SCALE_MUL)
SET(MAX_IMAGE_SCALE_MUL 0)
else()
SET(MAX_IMAGE_SCALE_MUL ${MAX_IMAGE_SCALE_MUL})
endif (NOT DEFINED MAX_IMAGE_SCALE_MUL)
ADD_DEFINITIONS( -DMAX_IMAGE_SCALE_MUL=${MAX_IMAGE_SCALE_MUL} )
message("using MAX_IMAGE_SCALE_MUL=${MAX_IMAGE_SCALE_MUL}")
if(MAC)
ADD_DEFINITIONS( -DMAC=1 -DLINUX=1 -D_LINUX=1 -DCR_EMULATE_GETTEXT=1 )
elseif ( WIN32 )
ADD_DEFINITIONS( -DWIN32=1 -D_WIN32=1 -DCR_EMULATE_GETTEXT=1 )
else()
ADD_DEFINITIONS( -DLINUX=1 -D_LINUX=1 )
endif(MAC)
# Large files support
ADD_DEFINITIONS( -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLVLONG_FILE_SUPPORT=1 )
if (NOT DEFINED GRAY_BACKBUFFER_BITS)
SET(GRAY_BACKBUFFER_BITS 2)
endif (NOT DEFINED GRAY_BACKBUFFER_BITS)
if (NOT DEFINED ENABLE_DBUS_VIEWER_EVENTS)
SET(ENABLE_DBUS_VIEWER_EVENTS 0)
endif (NOT DEFINED ENABLE_DBUS_VIEWER_EVENTS)
SET (CRGUI_DEFS -DCOLOR_BACKBUFFER=0 -DLDOM_USE_OWN_MEM_MAN=0 -DGRAY_BACKBUFFER_BITS=${GRAY_BACKBUFFER_BITS}
-DENABLE_DBUS_VIEWER_EVENTS=${ENABLE_DBUS_VIEWER_EVENTS})
SET (DESKTOP_DEFS -DCOLOR_BACKBUFFER=1 -DLDOM_USE_OWN_MEM_MAN=1 -DUSE_FREETYPE=1 )
if( ${GUI} STREQUAL QT )
FIND_PACKAGE( Qt4 REQUIRED )
INCLUDE(${QT_USE_FILE})
SET(QT_3RDPARTY_DIR ${QT_INCLUDE_DIR}/../src/3rdparty)
endif( ${GUI} STREQUAL QT )
#UNRAR support
if(DEFINED USE_UNRAR)
message("Will build static UNRAR library")
SET(USE_UNRAR 1)
SET(UNRAR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/unrar)
SET(UNRAR_LIBRARIES unrar)
ADD_DEFINITIONS(-DUSE_UNRAR=1)
INCLUDE_DIRECTORIES(${UNRAR_INCLUDE_DIR})
ADD_SUBDIRECTORY(thirdparty/unrar)
else()
message("NO_UNRAR parameter specified: Will not support UNRAR")
SET(UNRAR_INCLUDE_DIR)
SET(UNRAR_LIBRARIES)
ADD_DEFINITIONS(-DUSE_UNRAR=0)
SET(USE_UNRAR 0)
endif(DEFINED USE_UNRAR)
if (MAC)
message("will use zlib, libpng, libjpeg, freetype from Qt static library")
SET(ZLIB_INCLUDE_DIR ${QT_3RDPARTY_DIR}/zlib)
SET(ZLIB_LIBRARIES )
SET(PNG_INCLUDE_DIR ${QT_3RDPARTY_DIR}/libpng)
SET(PNG_LIBRARIES )
SET(FREETYPE_INCLUDE_DIRS ${QT_3RDPARTY_DIR}/freetype/include)
SET(FREETYPE_LIBRARIES )
SET(JPEG_INCLUDE_DIR ${QT_3RDPARTY_DIR}/libjpeg)
SET(JPEG_LIBRARIES )
endif(MAC)
if (NOT MAC)
if (DEFINED USE_QT_ZLIB)
SET(ZLIB_INCLUDE_DIR ${QT_INCLUDE_DIR}/../src/3rdparty/zlib)
message("Using QT ZLIB ${USE_QT_ZLIB} include dir: ${ZLIB_INCLUDE_DIR}")
# SET(ZLIB_LIBRARIES "")
else()
if (NOT WIN32 AND NOT DEFINED USE_STATIC_ZLIB)
FIND_PACKAGE(ZLIB)
endif (NOT WIN32 AND NOT DEFINED USE_STATIC_ZLIB)
if (NOT ZLIB_FOUND)
message("System ZLIB not found, will build local one")
#to disable #include <qconfig.h>
ADD_DEFINITIONS(-DCR3_PATCH=1)
ADD_SUBDIRECTORY(thirdparty/zlib)
SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib)
SET(ZLIB_LIBRARIES z)
endif (NOT ZLIB_FOUND)
endif(DEFINED USE_QT_ZLIB)
endif(NOT MAC)
if ( NOT ${GUI} STREQUAL FB2PROPS )
if (NOT MAC)
if (NOT WIN32 AND NOT CR3_PNG)
FIND_PACKAGE(PNG)
endif (NOT WIN32 AND NOT CR3_PNG)
if (NOT PNG_FOUND)
message("System LIBPNG not found, will build local one")
#to disable #include <qconfig.h>
ADD_DEFINITIONS(-DCR3_PATCH=1)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ADD_SUBDIRECTORY(thirdparty/libpng)
SET(PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpng)
SET(PNG_LIBRARIES png)
endif (NOT PNG_FOUND)
if (NOT WIN32 AND NOT CR3_JPEG)
FIND_PACKAGE(JPEG)
endif (NOT WIN32 AND NOT CR3_JPEG)
if (NOT JPEG_FOUND)
message("System LIBJPEG not found, will build local one")
ADD_SUBDIRECTORY(thirdparty/libjpeg)
SET(JPEG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libjpeg)
SET(JPEG_LIBRARIES jpeg)
endif (NOT JPEG_FOUND)
if (NOT WIN32 AND NOT CR3_FREETYPE)
FIND_PACKAGE(Freetype)
endif (NOT WIN32 AND NOT CR3_FREETYPE)
if (NOT FREETYPE_FOUND)
message("System FREETYPE not found, will build local one")
ADD_SUBDIRECTORY(thirdparty/freetype)
SET(FREETYPE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/freetype/include)
SET(FREETYPE_LIBRARIES freetype)
endif (NOT FREETYPE_FOUND)
endif (NOT MAC)
#if (ENABLE_CHM)
message("Will build patched LIBCHM library")
ADD_SUBDIRECTORY(thirdparty/chmlib)
SET(CHM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/chmlib/src)
SET(CHM_LIBRARIES chmlib)
ADD_DEFINITIONS(-DCHM_SUPPORT_ENABLED=1)
#else()
#ADD_DEFINITIONS(-DCHM_SUPPORT_ENABLED=0)
#endif(ENABLE_CHM)
message("Will build patched ANTIWORD library")
ADD_DEFINITIONS(-DCR3_ANTIWORD_PATCH=1)
ADD_SUBDIRECTORY(thirdparty/antiword)
SET(ANTIWORD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/antiword)
SET(ANTIWORD_LIBRARIES antiword)
ADD_DEFINITIONS(-DENABLE_ANTIWORD=1)
INCLUDE_DIRECTORIES( ${ANTIWORD_INCLUDE_DIR} )
endif ( NOT ${GUI} STREQUAL FB2PROPS )
INCLUDE_DIRECTORIES(
${PNG_INCLUDE_DIR}
${JPEG_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIRS}
${HARFBUZZ_INCLUDE_DIRS}
${ANTIWORD_INCLUDE_DIR}
${CHM_INCLUDE_DIR}
)
if ( ${GUI} STREQUAL FB2PROPS )
SET(STD_LIBS
${ZLIB_LIBRARIES}
)
else()
SET(STD_LIBS
${JPEG_LIBRARIES}
${FREETYPE_LIBRARIES}
${HARFBUZZ_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${CHM_LIBRARIES}
${ANTIWORD_LIBRARIES}
)
include_directories(${FT_INCLUDE_PATH})
endif ( ${GUI} STREQUAL FB2PROPS )
include_directories(crengine/include)
if ( NOT ${GUI} STREQUAL FB2PROPS )
include_directories(tinydict)
message("Will make tinydict library - .dict format support")
ADD_SUBDIRECTORY(tinydict)
endif ( NOT ${GUI} STREQUAL FB2PROPS )
include(FindPkgConfig)
if ( ${GUI} STREQUAL CRGUI_XCB )
message("Will make CR3GUI for XCB")
ADD_DEFINITIONS( -DCR_USE_XCB=1 ${CRGUI_DEFS} )
ADD_DEFINITIONS( -DCR_INTERNAL_PAGE_ORIENTATION=0 ${CRGUI_DEFS} )
message("Freetype include dir: ${FREETYPE_INCLUDE_DIRS}")
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3gui)
elseif ( ${GUI} STREQUAL CRGUI_NANOX )
message("Will make CR3GUI for NanoX")
if (ENABLE_DBUS_VIEWER_EVENTS)
message("Will handle DBUS messages")
pkg_check_modules( DBUS REQUIRED dbus-1 )
message("dbus include dir: ${DBUS_INCLUDE_DIRS} path ${DBUS_INCLUDE_PATH}")
include_directories(${DBUS_INCLUDE_DIRS})
endif (ENABLE_DBUS_VIEWER_EVENTS)
ADD_DEFINITIONS( -DLBOOK=1 -DWITH_JINKE=1 -DCR_USE_JINKE=1
-DJINKE_VIEWER ${CRGUI_DEFS} -DENABLE_UPDATE_MODE_SETTING=1 )
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3gui)
elseif ( ${GUI} STREQUAL CRGUI_JINKE_PLUGIN )
message("Will make CR3GUI plugin for Jinke Viewer")
ADD_DEFINITIONS( -DLBOOK=1 -DWITH_JINKE=1 -DWITH_JINKE_APP=1
-DCR_USE_JINKE=1 ${CRGUI_DEFS}
-DENABLE_UPDATE_MODE_SETTING=1 )
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3gui)
elseif ( ${GUI} STREQUAL FB2PROPS )
message("Will make LIBFB2PROPS plugin for Jinke Bookshelf")
ADD_DEFINITIONS( -DLBOOK=1 -DWITH_JINKE=1 -DCR_USE_JINKE=1 -DBUILD_LITE=1 ${CRGUI_DEFS} )
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(fb2props)
elseif ( ${GUI} STREQUAL CRGUI_WIN32 )
message("Will make CR3GUI for Win32")
ADD_DEFINITIONS( ${CRGUI_DEFS} )
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3gui)
elseif ( ${GUI} STREQUAL QT )
message("Will make CR3/QT")
ADD_DEFINITIONS( ${DESKTOP_DEFS} )
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3qt)
elseif ( ${GUI} STREQUAL WX )
message("Will make CR3/WX")
ADD_DEFINITIONS( ${DESKTOP_DEFS} -DCR_WX_SUPPORT=1 )
SET(wxWidgets_USE_LIBS base core )
FIND_PACKAGE(wxWidgets)
IF (wxWidgets_FOUND)
INCLUDE(${wxWidgets_USE_FILE})
include_directories( ${wxWidgets_INCLUDE_DIRS} )
message( "WX include: ${wxWidgets_INCLUDE_DIRS}" )
ELSE (wxWidgets_FOUND)
message("wxWidgets library not found!")
ENDIF (wxWidgets_FOUND)
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3wx)
elseif ( ${GUI} STREQUAL CRGUI_PB )
message("Will make CR3GUI for PocketBook")
ADD_DEFINITIONS( -DLBOOK=1 -DCR_POCKETBOOK=1
${CRGUI_DEFS} -DCR_USE_INVERT_FOR_SELECTION_MARKS=1 -DENABLE_UPDATE_MODE_SETTING=1)
ADD_DEFINITIONS( -DCR_INTERNAL_PAGE_ORIENTATION=0 )
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3gui)
FIND_PATH (INKVIEW_INCLUDE_DIR inkview.h)
IF (INKVIEW_INCLUDE_DIR)
include_directories(${INKVIEW_INCLUDE_DIR})
ELSE (INKVIEW_INCLUDE_DIR)
message("inkview.h not found")
ENDIF (INKVIEW_INCLUDE_DIR)
elseif ( ${GUI} STREQUAL CRGUI_QT )
message("Will make CR3GUI with Qt backend")
ADD_DEFINITIONS( -DCR_USE_QT=1 -DCRGUI_QT=1 -DCR_USE_INVERT_FOR_SELECTION_MARKS=1)
ADD_DEFINITIONS( -DCR_INTERNAL_PAGE_ORIENTATION=0 ${CRGUI_DEFS} )
ADD_SUBDIRECTORY(crengine)
ADD_SUBDIRECTORY(cr3gui)
else ( ${GUI} STREQUAL CRGUI_XCB )
message("Unknown GUI type ${GUI}")
endif ( ${GUI} STREQUAL CRGUI_XCB )