summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/cmake-config.txt
blob: f9339b9fc81cd180578288ff286d91fd0556d7fc (plain)
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
#========================================================================
#
# cmake-config.txt
#
# CMake script to do misc cmake config and platform-specific config.
#
# Copyright 2021 Glyph & Cog, LLC
#
#========================================================================

if (POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif ()

if (APPLE)
  if (POLICY CMP0042)
    cmake_policy(SET CMP0042 NEW)
  endif ()
  set(CMAKE_MACOSX_RPATH 1)
endif ()

include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(GNUInstallDirs)

enable_language(CXX)

#--- add a 'Profiling' build mode
if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
  set(CMAKE_C_FLAGS_PROFILING "-g -pg -O -Wall"
      CACHE STRING "C compiler flags for profiling mode"
      FORCE)
  set(CMAKE_CXX_FLAGS_PROFILING "-g -pg -O -Wall"
      CACHE STRING "C++ compiler flags for profiling mode"
      FORCE)
  set(CMAKE_EXE_LINKER_FLAGS_PROFILING "-g -pg -O -Wall"
      CACHE STRING "linker flags for profiling mode"
      FORCE)
  set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-g -pg -O -Wall"
      CACHE STRING "shared linker flags for profiling mode"
      FORCE)
  mark_as_advanced(
    CMAKE_C_FLAGS_PROFILING
    CMAKE_CXX_FLAGS_PROFILING
    CMAKE_EXE_LINKER_FLAGS_PROFILING
    CMAKE_SHARED_LINKER_FLAGS_PROFILING)
  set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
      "Choose build mode - options are: None Debug Release RelWithDebInfo MinSizeRel Profiling"
      FORCE)
endif ()

#--- set default C/C++ compiler flags for Windows
if (MSVC)
  option(USE_MT_IN_DEBUG "use /MT instead of /MTd in debug builds" OFF)
  foreach (var CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
               CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
               CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
               CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
    # note: this converts /MD to /MT and /MDd to /MTd
    string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
  endforeach ()
  if (USE_MT_IN_DEBUG)
    string(REPLACE "/MTd" "/MT" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
    string(REPLACE "/MTd" "/MT" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
  else ()
    set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
    set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/NODEFAULTLIB:libcmt ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
  endif ()
  foreach (var CMAKE_C_FLAGS_DEBUG
               CMAKE_C_FLAGS_RELEASE
               CMAKE_C_FLAGS_MINSIZEREL
               CMAKE_C_FLAGS_RELWITHDEBINFO)
    set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996")
  endforeach ()
  foreach (var CMAKE_CXX_FLAGS_DEBUG
               CMAKE_CXX_FLAGS_RELEASE
               CMAKE_CXX_FLAGS_MINSIZEREL
               CMAKE_CXX_FLAGS_RELWITHDEBINFO)
    set(${var} "${${var}} /D_CRT_SECURE_NO_WARNINGS /wd4290 /wd4996 /EHsc")
  endforeach ()
endif ()

#--- don't set an rpath
set(CMAKE_SKIP_RPATH FALSE)

#--- miscellaneous options
option(A4_PAPER "use A4 (instead of Letter) paper size by default for PostScript output" OFF)
option(NO_TEXT_SELECT "do not allow text selection" OFF)
option(OPI_SUPPORT "include support for OPI comments" OFF)
option(MULTITHREADED "include support for multithreading" ON)
option(USE_EXCEPTIONS "use C++ exceptions" ON)
option(USE_FIXEDPOINT "use fixed point (instead of floating point) arithmetic" OFF)
option(SPLASH_CMYK "include support for CMYK rasterization" OFF)
option(NO_FONTCONFIG "disable support for libfontconfig" OFF)
option(SYSTEM_XPDFRC "full path for system-wide xpdfrc file" "")
if (SYSTEM_XPDFRC)
  set(SYSTEM_XPDFRC_DEFINE "#define SYSTEM_XPDFRC \"${SYSTEM_XPDFRC}\"")
else ()
  set(SYSTEM_XPDFRC_DEFINE "/* #undef SYSTEM_XPDFRC */")
endif ()
option(XPDFRC_DATADIR "directory to use for the DATADIR xpdfrc variable" "")
if (XPDFRC_DATADIR)
  set(XPDFRC_DATADIR_DEFINE "#define XPDFRC_DATADIR \"${XPDFRC_DATADIR}\"")
else ()
  set(XPDFRC_DATADIR_DEFINE "/* #undef XPDFRC_DATADIR */")
endif ()
if (WIN32)
  option(XPDFWIDGET_PRINTING "include printing support in XpdfWidget" OFF)
else ()
  option(XPDFWIDGET_PRINTING "include printing support in XpdfWidget" ON)
endif ()

#--- check for various library functions
check_function_exists(mkstemp HAVE_MKSTEMP)
check_function_exists(mkstemps HAVE_MKSTEMPS)
check_function_exists(popen HAVE_POPEN)
check_cxx_source_compiles(
    "#include <algorithm>
    bool cmp(const int &x, const int &y) { return x < y; }
    int a[100];
    int main() { std::sort(a, a+100, &cmp); }"
  HAVE_STD_SORT)

#--- set up 64-bit file seeks
check_function_exists(fseeko HAVE_FSEEKO)
check_function_exists(fseek64 HAVE_FSEEK64)
check_function_exists(_fseeki64 HAVE_FSEEKI64)

#--- look for FreeType
# This could use cmake's FindFreetype, except that it would require
# a newer version of cmake -- because FreeType changed their include
# paths around.  Older versions of FreeType require two separate
# -I switches (typically ..../include and ..../include/freetype2);
# while newer versions require just one (typically ..../include/freetype2)
find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
  HINTS
  ${FREETYPE_DIR}
  PATHS
  /usr/local/include
  /usr/local/X11R6/include
  /usr/local/X11/include
  /usr/freeware/include
  PATH_SUFFIXES freetype2 include/freetype2 include
)
find_path(FREETYPE_INCLUDE_DIR_freetype freetype.h
  HINTS
  ${FREETYPE_DIR}
  PATHS
  /usr/local/include
  /usr/local/X11R6/include
  /usr/local/X11/include
  /usr/freeware/include
  PATH_SUFFIXES freetype2 include/freetype2 include
)
find_path(FREETYPE_INCLUDE_DIR_freetype_freetype freetype/freetype.h
  HINTS
  ${FREETYPE_DIR}
  PATHS
  /usr/local/include
  /usr/local/X11R6/include
  /usr/local/X11/include
  /usr/freeware/include
  PATH_SUFFIXES freetype2 include/freetype2 include
)
find_library(FREETYPE_LIBRARY
  NAMES freetype libfreetype freetype2 freetype219
  HINTS
  ${FREETYPE_DIR}
  PATH_SUFFIXES lib64 lib
  PATHS
  /usr/local
  /usr/local/X11R6
  /usr/local/X11
  /usr/freeware
)
if (FREETYPE_INCLUDE_DIR_ft2build
    AND FREETYPE_INCLUDE_DIR_freetype
    AND (FREETYPE_INCLUDE_DIR_ft2build STREQUAL FREETYPE_INCLUDE_DIR_freetype)
    AND FREETYPE_LIBRARY)
  set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build}")
  set(HAVE_FREETYPE_H TRUE)
  message(STATUS "Found FreeType (new-style includes): ${FREETYPE_LIBRARY}")
elseif (FREETYPE_INCLUDE_DIR_ft2build
        AND FREETYPE_INCLUDE_DIR_freetype_freetype
        AND FREETYPE_LIBRARY)
  set(FREETYPE_INCLUDE_DIRS
      "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype_freetype}")
  set(HAVE_FREETYPE_H TRUE)
  message(STATUS "Found FreeType (old-style includes): ${FREETYPE_LIBRARY}")
else ()
  message(STATUS "FreeType not found")
endif ()
if (HAVE_FREETYPE_H)
  set(HAVE_SPLASH TRUE)
endif ()


#--- look for zlib
find_package(ZLIB)

#--- look for libpng
find_package(PNG)




#--- look for Qt
find_package(Qt6Widgets QUIET)
if (Qt6Widgets_FOUND)
  find_package(Qt6Network)
  find_package(Qt6PrintSupport)
else ()
  find_package(Qt5Widgets QUIET)
  if (Qt5Widgets_FOUND)
    find_package(Qt5Network)
    find_package(Qt5PrintSupport)
  else ()
    find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork)
  endif ()
endif ()
if (Qt5Widgets_FOUND)
  message(STATUS "Qt5 found")
  if (XPDFWIDGET_PRINTING)
    set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS}")
    set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS}")
    set(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::PrintSupport)
  else ()
    set(QT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}")
    set(QT_DEFINITIONS "${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}")
    set(QT_LIBRARIES Qt5::Widgets Qt5::Network)
  endif ()
  if (XPDFWIDGET_PRINTING)
    if (APPLE)
      set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
    elseif (UNIX)
      find_package(Cups)
      if (CUPS_FOUND)
        set(EXTRA_QT_LIBRARIES ${CUPS_LIBRARIES})
      else ()
        set (XPDFWIDGET_PRINTING OFF)
      endif ()
    else ()
      set(EXTRA_QT_LIBRARIES "")
    endif ()
  endif ()
  # remove "-fPIE" here because we added "-fPIC" above
  string(REPLACE "-fPIE" "" QT_CFLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
elseif (Qt6Widgets_FOUND)
  message(STATUS "Qt6 found")
  if (XPDFWIDGET_PRINTING)
    set(QT_INCLUDES "${Qt6Widgets_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS} ${Qt6PrintSupport_INCLUDE_DIRS}")
    set(QT_DEFINITIONS "${Qt6Widgets_DEFINITIONS} ${Qt6Network_DEFINITIONS} ${Qt6PrintSupport_DEFINITIONS}")
    set(QT_LIBRARIES Qt6::Widgets Qt6::Network Qt6::PrintSupport)
  else ()
    set(QT_INCLUDES "${Qt6Widgets_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS}")
    set(QT_DEFINITIONS "${Qt6Widgets_DEFINITIONS} ${Qt6Network_DEFINITIONS}")
    set(QT_LIBRARIES Qt6::Widgets Qt6::Network)
  endif ()
  if (XPDFWIDGET_PRINTING)
    if (APPLE)
      set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
    elseif (UNIX)
      find_package(Cups)
      if (CUPS_FOUND)
        set(EXTRA_QT_LIBRARIES ${CUPS_LIBRARIES})
      else ()
        set (XPDFWIDGET_PRINTING OFF)
      endif ()
    else ()
      set(EXTRA_QT_LIBRARIES "")
    endif ()
  endif ()
  # remove "-fPIE" here because we added "-fPIC" above
  string(REPLACE "-fPIE" "" QT_CFLAGS "${Qt6Widgets_EXECUTABLE_COMPILE_FLAGS}")
elseif (QT4_FOUND)
  message(STATUS "Qt4 found")
  if (XPDFWIDGET_PRINTING)
    if (APPLE)
      set(EXTRA_QT_LIBRARIES "-framework ApplicationServices")
    elseif (UNIX)
      find_package(Cups)
      if (CUPS_FOUND)
        set(EXTRA_QT_LIBRARIES ${CUPS_LIBRARIES})
      else ()
        set (XPDFWIDGET_PRINTING OFF)
      endif ()
    else ()
      set(EXTRA_QT_LIBRARIES "")
    endif ()
  endif ()
else ()
  message(STATUS "No Qt library found")
endif ()

#--- look for libpaper
find_library(PAPER_LIBRARY
             NAMES paper libpaper
             PATH_SUFFIXES lib64 lib
)
if (PAPER_LIBRARY)
  set(HAVE_PAPER_H TRUE)
else ()
  set(HAVE_PAPER_H FALSE)
  set(PAPER_LIBRARY "")
endif ()

#--- look for fontconfig
if (NOT NO_FONTCONFIG)
  find_library(FONTCONFIG_LIBRARY
               NAMES fontconfig libfontconfig
               PATH_SUFFIXES lib64 lib
  )
  if (FONTCONFIG_LIBRARY)
    set(HAVE_FONTCONFIG TRUE)
    message(STATUS "Found fontconfig")
  else ()
    set(HAVE_FONTCONFIG FALSE)
    set(FONTCONFIG_LIBRARY "")
  endif ()
else ()
  set(HAVE_FONTCONFIG FALSE)
  set(FONTCONFIG_LIBRARY "")
endif ()

#--- look for pthreads
if (MULTITHREADED)
  find_package(Threads)
else ()
  set(CMAKE_THREAD_LIBS_INIT "")
endif ()

#--- create aconf.h
configure_file("aconf.h.in" "aconf.h")