1##############################################################################################################
2########## Find Dependencies                                                                        ##########
3
4#<< Qt
5#Qt less than 6
6set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake")
7set(CMAKE_INCLUDE_CURRENT_DIR ON)
8
9if (NOT WANT_QT6)
10	message(STATUS "Qt5 Requested")
11	set(QT_MIN_VERSION "5.14.0")
12	add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050E00)
13	find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED)
14	if(NOT Qt5Core_FOUND)
15		message(FATAL_ERROR "ERROR: No QT 5 found")
16	endif()
17	find_package(Qt5Widgets ${QT_MIN_VERSION} REQUIRED)
18	if(NOT Qt5Widgets_FOUND)
19		message(FATAL_ERROR "ERROR: No QT Widgets found")
20	endif()
21	find_package(Qt5Gui ${QT_MIN_VERSION} REQUIRED)
22	if(NOT Qt5Gui_FOUND)
23		message(FATAL_ERROR "ERROR: No Qt5Gui found")
24	endif()
25	find_package(Qt5Xml ${QT_MIN_VERSION} REQUIRED)
26	if(NOT Qt5Xml_FOUND)
27		message(FATAL_ERROR "ERROR: No QT 5 XML found")
28	endif()
29	find_package(Qt5Network ${QT_MIN_VERSION} REQUIRED)
30	if(NOT Qt5Network_FOUND)
31		message(FATAL_ERROR "ERROR: No Qt5Network found")
32	endif()
33	find_package(Qt5OpenGL ${QT_MIN_VERSION} REQUIRED)
34	if(NOT Qt5OpenGL_FOUND)
35		message(FATAL_ERROR "ERROR: No Qt5OpenGL found")
36	endif()
37	find_package(Qt5LinguistTools ${QT_MIN_VERSION} REQUIRED)
38	if(NOT Qt5LinguistTools_FOUND)
39		message(FATAL_ERROR "ERROR: No Qt5LinguistTools found")
40	endif()
41	#find_package(Qt5Quick ${QT_MIN_VERSION} REQUIRED)
42	#if(Qt5Quick_FOUND)
43	#    message(STATUS "----- USE Qt5Quick -----")
44	#else()
45	#    message(FATAL_ERROR "ERROR: No Qt5Quick found")
46	#endif()
47	find_package(Qt5PrintSupport ${QT_MIN_VERSION} REQUIRED)
48	if(NOT Qt5PrintSupport_FOUND)
49		message(FATAL_ERROR "ERROR: No Qt5PrintSupport found")
50	endif()
51	include_directories(${Qt5Core_INCLUDE_DIRS})
52	add_definitions(${Qt5Core_DEFINITIONS})
53	include_directories(${Qt5Widgets_INCLUDE_DIRS})
54	add_definitions(${Qt5Widgets_DEFINITIONS})
55	include_directories(${Qt5Gui_INCLUDE_DIRS})
56	add_definitions(${Qt5Gui_DEFINITIONS})
57	include_directories(${Qt5Xml_INCLUDE_DIRS})
58	add_definitions(${Qt5Xml_DEFINITIONS})
59	include_directories(${Qt5Network_INCLUDE_DIRS})
60	add_definitions(${Qt5Network_DEFINITIONS})
61	include_directories(${Qt5OpenGL_INCLUDE_DIRS})
62	add_definitions(${Qt5OpenGL_DEFINITIONS})
63	include_directories(${Qt5PrintSupport_INCLUDE_DIRS})
64	add_definitions(${Qt5PrintSupport_DEFINITIONS})
65
66	message(STATUS "Qt Version Found: ${Qt5Widgets_VERSION}")
67else()
68#WANT QT6
69    message(STATUS "Qt6 Requested")
70	find_package(Qt6 COMPONENTS Core REQUIRED)
71	find_package(Qt6 COMPONENTS Core5Compat REQUIRED)
72	find_package(Qt6 COMPONENTS Gui REQUIRED)
73	find_package(Qt6 COMPONENTS Widgets REQUIRED)
74	include_directories(${Qt6Core_INCLUDE_DIRS})
75	add_definitions(${Qt6Core_DEFINITIONS})
76	include_directories(${Qt6Core5Compat_INCLUDE_DIRS})
77	add_definitions(${Qt6Core5Compat_DEFINITIONS})
78	include_directories(${Qt6Widgets_INCLUDE_DIRS})
79	add_definitions(${Qt6Widgets_DEFINITIONS})
80	include_directories(${Qt6Gui_INCLUDE_DIRS})
81	add_definitions(${Qt6Gui_DEFINITIONS})
82#	include_directories(${Qt5Xml_INCLUDE_DIRS})
83#	add_definitions(${Qt5Xml_DEFINITIONS})
84#	include_directories(${Qt5Network_INCLUDE_DIRS})
85#	add_definitions(${Qt5Network_DEFINITIONS})
86#	include_directories(${Qt5OpenGL_INCLUDE_DIRS})
87#	add_definitions(${Qt5OpenGL_DEFINITIONS})
88#	include_directories(${Qt5PrintSupport_INCLUDE_DIRS})
89#	add_definitions(${Qt5PrintSupport_DEFINITIONS})
90	message(STATUS "Qt Version Found: ${Qt6Widgets_VERSION}")
91endif()
92
93
94
95
96#<< ZLIB, PNG
97if (WIN32)
98	# On win32 we can use Qt's zlib and libpng, so we use some
99	# custom cmake includes. This permits us to honour the
100	# USE_QT_ZLIB_PNGLIB flag if passed.
101	set(PNG_DIR ${CMAKE_MODULE_PATH})
102	set(ZLIB_DIR ${CMAKE_MODULE_PATH})
103endif()
104find_package(ZLIB REQUIRED)
105if (ZLIB_FOUND)
106	message("ZLIB Library Found OK")
107	set(HAVE_LIBZ ON)
108endif()
109#find_package(PNG REQUIRED)
110#if (PNG_FOUND)
111#	message("PNG Library Found OK")
112#endif()
113#>> ZLIB, PNG
114
115if (WANT_NOOSG)
116	message("Building without 3D Extension")
117else()
118	find_package(OSG)
119	if(OSG_FOUND)
120		message("OSG found OK")
121		set(HAVE_OSG ON)
122		find_package(OpenGL)
123		include(CheckFunctionExists)
124		CHECK_FUNCTION_EXISTS(memrchr HAVE_MEMRCHR)
125	else()
126		message("No OSG found, building without 3D Extension")
127	endif()
128endif()
129
130#<< JPEG, PNG, TIFF
131find_package(JPEG REQUIRED)
132if (JPEG_FOUND)
133	message("JPEG Library Found OK")
134endif()
135
136find_package(PNG 1.6 REQUIRED)
137if (PNG_FOUND)
138	message("PNG Library Found OK")
139endif()
140
141find_package(TIFF REQUIRED)
142if (TIFF_FOUND)
143	message("TIFF Library Found OK")
144	set(HAVE_TIFF ON)
145else()
146	message(FATAL_ERROR "Could not find the TIFF Library")
147endif()
148#<< JPEG, TIFF
149
150#<< PYTHON
151if (NOT WANT_PYTHON_2X)
152	message("Python 3.x Selected")
153	find_package (Python3 REQUIRED COMPONENTS Interpreter Development)
154	if (Python3_Development_FOUND)
155		message("Python 3.x Library Found OK (Version ${Python3_VERSION})")
156		message("Interpreter: ${Python3_EXECUTABLE}")
157		message("Include directories: ${Python3_INCLUDE_DIRS}")
158		message("Library directories: ${Python3_LIBRARY_DIRS}")
159		message("Runtime library directories: ${Python3_RUNTIME_LIBRARY_DIRS}")
160		set(HAVE_PYTHON ON)
161	endif()
162else()
163	message("Python 2.x Requested")
164	find_package (Python2 REQUIRED COMPONENTS Interpreter Development)
165	if (Python2_Development_FOUND)
166		message("Python 2.x Library Found OK (Version ${Python2_VERSION})")
167		message("Interpreter: ${Python2_EXECUTABLE}")
168		message("Include directories: ${Python2_INCLUDE_DIRS}")
169		message("Library directories: ${Python2_LIBRARY_DIRS}")
170		message("Runtime library directories: ${Python2_RUNTIME_LIBRARY_DIRS}")
171		set(HAVE_PYTHON ON)
172	endif()
173endif()
174#>> PYTHON
175
176#<< FreeType2
177find_package(Freetype REQUIRED)
178if (FREETYPE_FOUND)
179	message(STATUS "FreeType2 Library Found OK")
180else()
181	message(FATAL_ERROR "No Freetype Found")
182endif()
183#>> FreeType2
184
185set(cairo_DIR ${CMAKE_MODULE_PATH})
186find_package(cairo REQUIRED)
187if(cairo_FOUND)
188	set(HAVE_CAIRO ON)
189	message("cairo Library found OK")
190else()
191	message(FATAL_ERROR "No cairo library found")
192endif()
193#>>Render Library
194
195#<<CUPS
196if(NOT WIN32 AND NOT HAIKU)
197	find_package(Cups REQUIRED)
198	if(CUPS_FOUND)
199		set(HAVE_CUPS ON)
200		message("CUPS Library Found OK")
201	endif()
202else()
203	# Windows doesn't use CUPS
204	set(CUPS_INCLUDE_DIR)
205endif()
206#>>CUPS
207
208#<<LibXML2
209find_package(LibXml2 REQUIRED)
210if(LIBXML2_FOUND)
211	set(HAVE_XML ON)
212	message("LIBXML2 Library Found OK")
213endif()
214#>>LibXML2
215
216#<<LittleCMS
217set(LCMS_DIR ${CMAKE_MODULE_PATH})
218find_package(LCMS2 REQUIRED)
219if(LCMS2_FOUND)
220	set(HAVE_LCMS2 ON)
221	message("LittleCMS-2 Library Found OK")
222else()
223	message(FATAL_ERROR "Could not find the LittleCMS 2 Library")
224endif()
225#>>LittleCMS
226
227#<<FontConfig
228if(NOT WIN32)
229	find_package(Fontconfig REQUIRED)
230	if(Fontconfig_FOUND)
231		message("FontConfig Found OK")
232		set(HAVE_FONTCONFIG ON)
233	endif()
234endif()
235#>>FontConfig
236
237#<<HUNSPELL for Spelling support
238option(WANT_HUNSPELL "Enable support for spell checking with hunspell" ON)
239if (WANT_HUNSPELL)
240	find_package(hunspell)
241	if (hunspell_FOUND)
242		message("hunspell Found OK")
243		set(HAVE_HUNSPELL ON)
244	else()
245		message("hunspell or its developer libraries NOT found - Disabling support for spell checking")
246	endif()
247endif()
248#>>HUNSPELL for Spelling support
249
250#<<PoDoFo for AI PDF import
251option(WITH_PODOFO "Enable support for PDF embedded in AI" ON)
252if (WITH_PODOFO)
253	find_package(LIBPODOFO)
254	if (LIBPODOFO_FOUND)
255		message("PoDoFo found OK")
256		set(HAVE_PODOFO ON)
257	else()
258		message("PoDoFo NOT found - Disabling support for PDF embedded in AI")
259	endif()
260endif()
261#>>PoDoFo for AI PDF import
262
263#<<Boost for 2Geom Tools
264option(WITH_BOOST "Enable support for Boost based enhancements" ON)
265if (WITH_BOOST)
266	find_package(Boost)
267	if (Boost_FOUND)
268		message("Boost Library Found OK")
269		set(HAVE_BOOST ON)
270	else()
271		message("Boost: NOT FOUND, not building 2geomtools")
272	endif()
273endif()
274#>>Boost for 2Geom Tools
275
276#<< GraphicsMagick for image import
277if (WANT_GRAPHICSMAGICK)
278	set(GMAGICK_DIR ${CMAKE_MODULE_PATH})
279	pkg_check_modules(GMAGICK GraphicsMagick)
280	# find_package(GMAGICK)
281	if(GMAGICK_FOUND)
282		message(" GraphicsMagick Found OK")
283	else()
284		message(" GraphicsMagick NOT found! Building without additional image format support!")
285	endif()
286else()
287	message("Building without  GraphicsMagick (use -DWANT_GRAPHICSMAGICK=1 to enable)")
288endif()
289#>> GraphicsMagick for image import
290
291#<<Poppler for PDF import
292find_package(poppler REQUIRED)
293if (poppler_FOUND)
294	set(HAVE_POPPLER ON)
295	message(STATUS "Found poppler")
296	message(STATUS "Found poppler libs: ${poppler_LIBRARY}")
297	message(STATUS "Found poppler includes: ${poppler_INCLUDE_DIR}")
298else()
299	message(FATAL_ERROR "Could not find poppler library")
300endif()
301#>>Poppler for PDF import
302
303# librevenge for MsPub import
304pkg_check_modules(LIBREVENGE librevenge-0.0)
305if (LIBREVENGE_FOUND)
306	pkg_check_modules(LIBREVENGE_STREAM librevenge-stream-0.0)
307	if (LIBREVENGE_STREAM_FOUND)
308		pkg_check_modules(LIBREVENGE_GENERATORS librevenge-generators-0.0)
309		if (LIBREVENGE_GENERATORS_FOUND)
310			set(HAVE_REVENGE ON)
311		endif()
312	endif()
313endif()
314
315# CTL support
316pkg_check_modules(HARFBUZZ REQUIRED harfbuzz>=0.9.42 harfbuzz-icu)
317if (HARFBUZZ_FOUND)
318	message("Harfbuzz library Found OK")
319endif()
320pkg_check_modules(ICU REQUIRED icu-uc)
321
322# OpenType subsetting support
323pkg_check_modules(HARFBUZZ_SUBSET harfbuzz-subset>=2.4.0)
324if (HARFBUZZ_SUBSET_FOUND)
325	message("Harfbuzz subset library Found OK")
326	set (HAVE_HARFBUZZ_SUBSET ON)
327endif()
328