-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
144 lines (117 loc) · 3.46 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
project(k2pdfopt C)
cmake_minimum_required(VERSION 2.6)
#
# Last modified by Q.P. Hou 8 June 2019
#
# ---- Test for packages
include(FindPkgConfig)
set(K2PDFOPT_LIB "-lm")
# cmake -DCMAKE_BUILD_TYPE=Debug <path>
# TODO: configure flavour with opions
##
## option (USE_MUPDF
## "Use muPDF libraries" OFF)
## option (USE_GHOSTSCRIPT
## "Use Ghostscript executable" ON)
## option (USE_DJVU
## "" OFF)
## eoption (USE_GOCR
## "" OFF)
## option (USE_LEPTONICA
## "" OFF)
## option (USE_TESSERACT
## "" OFF)
## option (USE_JASPER
## "" OFF)
## option (USE_GSL
## "" OFF)
# HAVE_K2GUI
include(FindZLIB)
if(ZLIB_FOUND)
set(HAVE_Z_LIB 1)
# include_directories(${ZLIB_INCLUDE_DIRS})
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${ZLIB_LIBRARY})
endif(ZLIB_FOUND)
include(FindPNG)
if(PNG_FOUND)
set(HAVE_PNG_LIB 1)
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${PNG_LIBRARY_RELEASE})
else(PNG_FOUND)
message( FATAL_ERROR "Missing required dependency libpng." )
endif(PNG_FOUND)
include(FindJPEG)
if(JPEG_FOUND)
set(HAVE_JPEG_LIB 1)
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${JPEG_LIBRARY})
endif(JPEG_FOUND)
include(FindJasper)
if(JASPER_FOUND)
set(HAVE_JASPER_LIB 1)
endif(JASPER_FOUND)
# paths from willuslib/wgs.c
find_program(GHOSTSCRIPT_EXECUTABLE gs
# PATHS /usr/bin /usr/share/gs /usr/local/gs /opt/gs
# /usr/share/gs* /usr/local/gs* /opt/gs*
)
if(GHOSTSCRIPT_EXECUTABLE)
set(HAVE_GHOSTSCRIPT 1)
message(STATUS "Found ghostscript executable")
else()
message(STATUS "Could NOT find ghostscript executable")
endif(GHOSTSCRIPT_EXECUTABLE)
# willus.h
# HAVE_GSL_LIB
# libfreetype6 (>= 2.3.9), libjbig2dec0, libjpeg8 (>= 8c), libx11-6, libxext6, zlib1g (>= 1:1.2.0)
# MUPDF_STATIC_LDFLAGS misses mupdf-js-none, and doubles libs ...
pkg_check_modules(MUPDF mupdf)
if(MUPDF_FOUND)
set(HAVE_MUPDF_LIB 1)
# (includes jbig2dec, openjpeg, freetype)
include_directories(SYSTEM ${MUPDF_INCLUDEDIR})
message(STATUS "mupdf libraries: ${MUPDF_LDFLAGS}")
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${MUPDF_LDFLAGS}
-lmupdf-js-none -lopenjpeg -ljbig2dec -ljpeg -lfreetype -llcms -lgumbo
)
endif(MUPDF_FOUND)
pkg_check_modules(DJVU ddjvuapi)
if(DJVU_FOUND)
set(HAVE_DJVU_LIB 1)
include_directories(SYSTEM ${DJVU_INCLUDEDIR})
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${DJVU_LDFLAGS})
endif(DJVU_FOUND)
# HAVE_GOCR_LIB
pkg_check_modules(LEPT lept)
if(LEPT_FOUND)
set(HAVE_LEPTONICA_LIB 1)
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${LEPT_LDFLAGS})
include_directories(SYSTEM ${LEPT_INCLUDEDIR})
endif(LEPT_FOUND)
pkg_check_modules(TESSERACT tesseract)
if(TESSERACT_FOUND)
set(HAVE_TESSERACT_LIB 1)
set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${TESSERACT_LDFLAGS})
include_directories(SYSTEM ${TESSERACT_INCLUDEDIR})
endif(TESSERACT_FOUND)
# ---- Describe project
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CMAKE -Wall")
include_directories(. "${PROJECT_BINARY_DIR}" willuslib k2pdfoptlib)
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
add_subdirectory(willuslib)
add_subdirectory(k2pdfoptlib)
# ms
add_executable(k2pdfopt k2pdfopt.c)
target_link_libraries (k2pdfopt k2pdfoptlib willuslib ${K2PDFOPT_LIB} pthread)
message("")
message("-- Summary --")
message("")
message("General:")
message(" C-flags: '${CMAKE_C_FLAGS}' (-DCMAKE_C_FLAGS=\"...\")")
message(" Build type: ${CMAKE_BUILD_TYPE} (-DCMAKE_BUILD_TYPE=\"...\")")
message("")
message("Install:")
message(" Prefix: '${CMAKE_INSTALL_PREFIX}' (-DCMAKE_INSTALL_PREFIX=...)")
message(" Doc path: '${DOC_PATH}' (-DDOC_PATH=...)")
message("")