Debian Codegraph @

libs/xpdf/xpdf-src/cmake-config.txt

raw
1 #========================================================================
2 #
3 # cmake-config.txt
4 #
5 # CMake script to do misc cmake config and platform-specific config.
6 #
7 # Copyright 2021 Glyph & Cog, LLC
8 #
9 #========================================================================
10
11 if (POLICY CMP0074)
12 cmake_policy(SET CMP0074 NEW)
13 endif ()
14
15 if (APPLE)
16 set(CMAKE_MACOSX_RPATH 1)
17 endif ()
18
19 include(CheckFunctionExists)
20 include(CheckCXXSourceCompiles)
21 include(GNUInstallDirs)
22
23 enable_language(CXX)
24 set(CMAKE_CXX_STANDARD 11)
25
26 #--- add a 'Profiling' build mode
27 if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
28 set(CMAKE_C_FLAGS_PROFILING "-g -pg -O -Wall"
29 CACHE STRING "C compiler flags for profiling mode"
30 FORCE)
31 set(CMAKE_CXX_FLAGS_PROFILING "-g -pg -O -Wall"
32 CACHE STRING "C++ compiler flags for profiling mode"
33 FORCE)
34 set(CMAKE_EXE_LINKER_FLAGS_PROFILING "-g -pg -O -Wall"
35 CACHE STRING "linker flags for profiling mode"
36 FORCE)
37 set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-g -pg -O -Wall"
38 CACHE STRING "shared linker flags for profiling mode"
39 FORCE)
40 mark_as_advanced(
41 CMAKE_C_FLAGS_PROFILING
42 CMAKE_CXX_FLAGS_PROFILING
43 CMAKE_EXE_LINKER_FLAGS_PROFILING
44 CMAKE_SHARED_LINKER_FLAGS_PROFILING)
45 set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
46 "Choose build mode - options are: None Debug Release RelWithDebInfo MinSizeRel Profiling"
47 FORCE)
48 endif ()
49
50 #--- set default C/C++ compiler flags for Windows
51 if (MSVC)
52 option(USE_MT_IN_DEBUG "use /MT instead of /MTd in debug builds" OFF)
53 foreach (var CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
54 CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
55 CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
56 CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
57 # note: this converts /MD to /MT and /MDd to /MTd
58 string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
59 endforeach ()
60 if (USE_MT_IN_DEBUG)
61 string(REPLACE "/MTd" "/MT" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
62 string(REPLACE "/MTd" "/MT" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
63 else ()
64 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
65 set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
66 endif ()
67 foreach (var CMAKE_C_FLAGS_DEBUG
68 CMAKE_C_FLAGS_RELEASE
69 CMAKE_C_FLAGS_MINSIZEREL
70 CMAKE_C_FLAGS_RELWITHDEBINFO)
71 set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996")
72 endforeach ()
73 foreach (var CMAKE_CXX_FLAGS_DEBUG
74 CMAKE_CXX_FLAGS_RELEASE
75 CMAKE_CXX_FLAGS_MINSIZEREL
76 CMAKE_CXX_FLAGS_RELWITHDEBINFO)
77 set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996 /EHsc")
78 endforeach ()
79 endif ()
80
81 #--- don't set an rpath
82 set(CMAKE_SKIP_RPATH FALSE)
83
84 #--- miscellaneous options
85 option(A4_PAPER "use A4 (instead of Letter) paper size by default for PostScript output" OFF)
86 option(NO_TEXT_SELECT "do not allow text selection" OFF)
87 option(OPI_SUPPORT "include support for OPI comments" OFF)
88 option(MULTITHREADED "include support for multithreading" ON)
89 option(USE_EXCEPTIONS "use C++ exceptions" ON)
90 option(USE_FIXEDPOINT "use fixed point (instead of floating point) arithmetic" OFF)
91 option(SPLASH_CMYK "include support for CMYK rasterization" OFF)
92 option(NO_FONTCONFIG "disable support for libfontconfig" OFF)
93 if (WIN32)
94 option(XPDFWIDGET_PRINTING "include printing support in XpdfWidget" OFF)
95 else ()
96 option(XPDFWIDGET_PRINTING "include printing support in XpdfWidget" ON)
97 endif ()
98 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
99 option(USE_XDG "use XDG paths for config and state files" ON)
100 else ()
101 option(USE_XDG "use XDG paths for config and state files" OFF)
102 endif ()
103
104 #--- paths
105 set(SYSTEM_XPDFRC "${SYSTEM_XPDFRC}" CACHE FILEPATH "full path for system-wide xpdfrc file")
106 set(XPDFRC_DATADIR "${XPDFRC_DATADIR}" CACHE PATH "directory to use for the DATADIR xpdfrc variable")
107 set(BASE14_FONT_DIR "${BASE14_FONT_DIR}" CACHE PATH "directory where the Base14 fonts are installed")
108
109 #--- check for various library functions
110 check_function_exists(mkstemp HAVE_MKSTEMP)
111 check_function_exists(mkstemps HAVE_MKSTEMPS)
112 check_function_exists(popen HAVE_POPEN)
113 check_cxx_source_compiles(
114 "#include <algorithm>
115 bool cmp(const int &x, const int &y) { return x < y; }
116 int a[100];
117 int main() { std::sort(a, a+100, &cmp); }"
118 HAVE_STD_SORT)
119
120 #--- set up 64-bit file seeks
121 check_function_exists(fseeko HAVE_FSEEKO)
122 check_function_exists(fseek64 HAVE_FSEEK64)
123 check_function_exists(_fseeki64 HAVE_FSEEKI64)
124
125 #--- look for FreeType
126 # This could use cmake's FindFreetype, except that it would require
127 # a newer version of cmake -- because FreeType changed their include
128 # paths around. Older versions of FreeType require two separate
129 # -I switches (typically ..../include and ..../include/freetype2);
130 # while newer versions require just one (typically ..../include/freetype2)
131 find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
132 HINTS
133 ${FREETYPE_DIR}
134 PATHS
135 /usr/local/include
136 /usr/local/X11R6/include
137 /usr/local/X11/include
138 /usr/freeware/include
139 PATH_SUFFIXES freetype2 include/freetype2 include
140 )
141 find_path(FREETYPE_INCLUDE_DIR_freetype freetype.h
142 HINTS
143 ${FREETYPE_DIR}
144 PATHS
145 /usr/local/include
146 /usr/local/X11R6/include
147 /usr/local/X11/include
148 /usr/freeware/include
149 PATH_SUFFIXES freetype2 include/freetype2 include
150 )
151 find_path(FREETYPE_INCLUDE_DIR_freetype_freetype freetype/freetype.h
152 HINTS
153 ${FREETYPE_DIR}
154 PATHS
155 /usr/local/include
156 /usr/local/X11R6/include
157 /usr/local/X11/include
158 /usr/freeware/include
159 PATH_SUFFIXES freetype2 include/freetype2 include
160 )
161 find_library(FREETYPE_LIBRARY
162 NAMES freetype libfreetype freetype2 freetype219
163 HINTS
164 ${FREETYPE_DIR}
165 PATH_SUFFIXES lib64 lib
166 PATHS
167 /usr/local
168 /usr/local/X11R6
169 /usr/local/X11
170 /usr/freeware
171 )
172 if (FREETYPE_INCLUDE_DIR_ft2build
173 AND FREETYPE_INCLUDE_DIR_freetype
174 AND (FREETYPE_INCLUDE_DIR_ft2build STREQUAL FREETYPE_INCLUDE_DIR_freetype)
175 AND FREETYPE_LIBRARY)
176 set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build}")
177 set(HAVE_FREETYPE_H TRUE)
178 message(STATUS "Found FreeType (new-style includes): ${FREETYPE_LIBRARY}")
179 elseif (FREETYPE_INCLUDE_DIR_ft2build
180 AND FREETYPE_INCLUDE_DIR_freetype_freetype
181 AND FREETYPE_LIBRARY)
182 set(FREETYPE_INCLUDE_DIRS
183 "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype_freetype}")
184 set(HAVE_FREETYPE_H TRUE)
185 message(STATUS "Found FreeType (old-style includes): ${FREETYPE_LIBRARY}")
186 else ()
187 message(STATUS "FreeType not found")
188 endif ()
189 if (HAVE_FREETYPE_H)
190 set(HAVE_SPLASH TRUE)
191 endif ()
192
193
194 #--- look for zlib
195 find_package(ZLIB)
196
197 #--- look for libpng
198 find_package(PNG)
199
200
201
202
203 #--- look for Qt
204 find_package(Qt6Widgets QUIET)
205 if (Qt6Widgets_FOUND)
206 find_package(Qt6Network)
207 find_package(Qt6Concurrent)
208 find_package(Qt6PrintSupport)
209 else ()
210 find_package(Qt5Widgets QUIET)
211 if (Qt5Widgets_FOUND)
212 find_package(Qt5Network)
213 find_package(Qt5Concurrent)
214 find_package(Qt5PrintSupport)
215 endif ()
216 endif ()
217 if (Qt5Widgets_FOUND)
218 message(STATUS "Qt5 found")
219 if (XPDFWIDGET_PRINTING)
220 set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Concurrent_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS}")
221 set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Concurrent_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS}")
222 set(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::PrintSupport)
223 else ()
224 set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Concurrent_INCLUDE_DIRS}")
225 set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Concurrent_DEFINITIONS}")
226 set(QT_LIBRARIES Qt5::Widgets Qt5::Network)
227 endif ()
228 if (XPDFWIDGET_PRINTING)
229 if (APPLE)
230 set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
231 elseif (UNIX)
232 find_package(Cups)
233 if (CUPS_FOUND)
234 set(EXTRA_QT_LIBRARIES ${CUPS_LIBRARIES})
235 else ()
236 set (XPDFWIDGET_PRINTING OFF)
237 endif ()
238 else ()
239 set(EXTRA_QT_LIBRARIES "")
240 endif ()
241 endif ()
242 # remove "-fPIE" here because we added "-fPIC" above
243 string(REPLACE "-fPIE" "" QT_CFLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
244 elseif (Qt6Widgets_FOUND)
245 message(STATUS "Qt6 found")
246 if (XPDFWIDGET_PRINTING)
247 set(QT_INCLUDES ${Qt6Widgets_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS} ${Qt6Concurrent_INCLUDE_DIRS} ${Qt6PrintSupport_INCLUDE_DIRS})
248 set(QT_DEFINITIONS "${Qt6Widgets_DEFINITIONS} ${Qt6Network_DEFINITIONS} ${Qt6Concurrent_DEFINITIONS} ${Qt6PrintSupport_DEFINITIONS}")
249 set(QT_LIBRARIES Qt6::Widgets Qt6::Network Qt6::Concurrent Qt6::PrintSupport)
250 else ()
251 set(QT_INCLUDES ${Qt6Widgets_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS} ${Qt6Concurrent_INCLUDE_DIRS})
252 set(QT_DEFINITIONS "${Qt6Widgets_DEFINITIONS} ${Qt6Network_DEFINITIONS} ${Qt6Concurrent_DEFINITIONS}")
253 set(QT_LIBRARIES Qt6::Widgets Qt6::Network Qt6::Concurrent)
254 endif ()
255 if (XPDFWIDGET_PRINTING)
256 if (APPLE)
257 set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
258 elseif (UNIX)
259 find_package(Cups)
260 if (CUPS_FOUND)
261 set(EXTRA_QT_LIBRARIES ${CUPS_LIBRARIES})
262 else ()
263 set (XPDFWIDGET_PRINTING OFF)
264 endif ()
265 else ()
266 set(EXTRA_QT_LIBRARIES "")
267 endif ()
268 endif ()
269 # remove "-fPIE" here because we added "-fPIC" above
270 string(REPLACE "-fPIE" "" QT_CFLAGS "${Qt6Widgets_EXECUTABLE_COMPILE_FLAGS}")
271 else ()
272 message(STATUS "No Qt library found")
273 endif ()
274
275 #--- look for libpaper
276 find_library(PAPER_LIBRARY
277 NAMES paper libpaper
278 PATH_SUFFIXES lib64 lib
279 )
280 if (PAPER_LIBRARY)
281 set(HAVE_PAPER_H TRUE)
282 else ()
283 set(HAVE_PAPER_H FALSE)
284 set(PAPER_LIBRARY "")
285 endif ()
286
287 #--- look for fontconfig
288 if (NOT NO_FONTCONFIG)
289 find_library(FONTCONFIG_LIBRARY
290 NAMES fontconfig libfontconfig
291 PATH_SUFFIXES lib64 lib
292 )
293 if (FONTCONFIG_LIBRARY)
294 set(HAVE_FONTCONFIG TRUE)
295 message(STATUS "Found fontconfig")
296 else ()
297 set(HAVE_FONTCONFIG FALSE)
298 set(FONTCONFIG_LIBRARY "")
299 endif ()
300 else ()
301 set(HAVE_FONTCONFIG FALSE)
302 set(FONTCONFIG_LIBRARY "")
303 endif ()
304
305 #--- look for pthreads
306 if (MULTITHREADED)
307 find_package(Threads)
308 else ()
309 set(CMAKE_THREAD_LIBS_INIT "")
310 endif ()
311
312 #--- create aconf.h
313 configure_file("aconf.h.in" "aconf.h")