Fix development database user creation
[ryzomcore.git] / CMakeModules / FindHelpers.cmake
blob71e13b0b01db5d8c8c039c0fcffebaa2b5b7d95b
1 MACRO(CONVERT_NUMBER_VERSION _VERSION_NUMBER _BASE _OUT)\r
2   SET(${_OUT})\r
3   SET(_NUMBER ${_VERSION_NUMBER})\r
4   WHILE(_NUMBER GREATER 0)\r
5     MATH(EXPR _TEMP "${_NUMBER} % ${_BASE}")\r
6     LIST(APPEND ${_OUT} ${_TEMP})\r
7     MATH(EXPR _NUMBER "${_NUMBER} / ${_BASE}")\r
8   ENDWHILE()\r
9 ENDMACRO(CONVERT_NUMBER_VERSION)\r
11 FUNCTION(JOIN VALUES GLUE OUTPUT)\r
12   STRING(REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}")\r
13   STRING(REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping\r
14   SET(${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)\r
15 ENDFUNCTION()\r
17 MACRO(PARSE_VERSION_OTHER FILENAME)\r
18   IF(EXISTS ${FILENAME})\r
19     SET(_FILTER_ARRAY ${ARGN})\r
20     JOIN("${_FILTER_ARRAY}" "|" _FILTER_REGEX)\r
21     FILE(STRINGS ${FILENAME} _FILE REGEX "(${_FILTER_REGEX})[: \t=\(\)\"]+([0-9.]+)")\r
23     IF(_FILE)\r
24       FOREACH(_LINE ${_FILE})\r
25         FOREACH(_VAR ${_FILTER_ARRAY})\r
26           IF("${${_VAR}}" STREQUAL "")\r
27             STRING(REGEX REPLACE "^.*${_VAR}[: \t=\(\)\"]+([0-9.]+).*$" "\\1" ${_VAR} "${_LINE}")\r
28             IF(${_VAR} STREQUAL "${_LINE}")\r
29               SET(${_VAR})\r
30             ENDIF()\r
31             IF(NOT ${_VAR} AND NOT STREQUAL "0")\r
32               SET(${_VAR} 0)\r
33             ENDIF()\r
34           ENDIF()\r
35         ENDFOREACH()\r
36       ENDFOREACH()\r
37     ENDIF()\r
38   ENDIF()\r
39 ENDMACRO()\r
41 # macro to define FIND_PACKAGE options with a different package name\r
42 MACRO(FIX_PACKAGE_OPTIONS OLDNAME NEWNAME)\r
43   # append other options if needed\r
44   SET(_OPTIONS COMPONENTS REQUIRED QUIETLY)\r
46   # process each options\r
47   FOREACH(_OPTION ${_OPTIONS})\r
48     SET(OLD_OPTION ${OLDNAME}_FIND_${_OPTION})\r
49     IF(DEFINED )\r
50       SET(NEW_OPTION ${NEWNAME}_FIND_${_OPTION})\r
51       SET(${NEW_OPTION} ${OLD_OPTION})\r
52     ENDIF()\r
53   ENDFOREACH()\r
54 ENDMACRO()\r
56 MACRO(FIND_PACKAGE_HELPER NAME INCLUDE)\r
57   # Looks for a directory containing NAME.\r
58   #\r
59   # NAME is the name of the library, lowercase and uppercase can be mixed\r
60   # It should be EXACTLY (same case) the same part as XXXX in FindXXXX.cmake\r
61   #\r
62   # INCLUDE is the file to check for includes\r
63   #\r
64   # Following parameters are optional variables and must be prefixed by:\r
65   #\r
66   # RELEASE is the list of libraries to check in release mode\r
67   # DEBUG is the list of libraries to check in debug mode\r
68   # SUFFIXES is the PATH_SUFFIXES to check for include file\r
69   # QUIET don't display anything\r
70   # VERBOSE display more details if not found\r
71   # REQUIRED throw an error if not found\r
72   # DIR is the base directory where to look for\r
73   #\r
74   # The first match will be used in the specified order and next matches will be ignored\r
75   #\r
76   # The following values are defined\r
77   # NAME_INCLUDE_DIR - where to find NAME\r
78   # NAME_LIBRARIES   - link against these to use NAME\r
79   # NAME_FOUND       - True if NAME is available.\r
81   SET(_PARAMS ${ARGN})\r
83   SET(_RELEASE_LIBRARIES)\r
84   SET(_DEBUG_LIBRARIES)\r
85   SET(_SUFFIXES)\r
86   SET(_BASE_DIRECTORIES)\r
88   SET(_IS_RELEASE OFF)\r
89   SET(_IS_DEBUG OFF)\r
90   SET(_IS_SUFFIXES OFF)\r
91   SET(_IS_VERBOSE OFF)\r
92   SET(_IS_DIR OFF)\r
94   IF(_PARAMS)\r
95     FOREACH(_PARAM ${_PARAMS})\r
96       IF(_PARAM STREQUAL "RELEASE")\r
97         SET(_IS_RELEASE ON)\r
98         SET(_IS_DEBUG OFF)\r
99         SET(_IS_SUFFIXES OFF)\r
100         SET(_IS_DIR OFF)\r
101       ELSEIF(_PARAM STREQUAL "DEBUG")\r
102         SET(_IS_RELEASE OFF)\r
103         SET(_IS_DEBUG ON)\r
104         SET(_IS_SUFFIXES OFF)\r
105         SET(_IS_DIR OFF)\r
106       ELSEIF(_PARAM STREQUAL "SUFFIXES")\r
107         SET(_IS_RELEASE OFF)\r
108         SET(_IS_DEBUG OFF)\r
109         SET(_IS_DIR OFF)\r
110         SET(_IS_SUFFIXES ON)\r
111       ELSEIF(_PARAM STREQUAL "QUIET")\r
112         SET(_IS_RELEASE OFF)\r
113         SET(_IS_DEBUG OFF)\r
114         SET(_IS_SUFFIXES OFF)\r
115         SET(_IS_DIR OFF)\r
116         SET(${NAME}_FIND_QUIETLY ON)\r
117       ELSEIF(_PARAM STREQUAL "VERBOSE")\r
118         SET(_IS_RELEASE OFF)\r
119         SET(_IS_DEBUG OFF)\r
120         SET(_IS_SUFFIXES OFF)\r
121         SET(_IS_DIR OFF)\r
122         SET(_IS_VERBOSE ON)\r
123       ELSEIF(_PARAM STREQUAL "REQUIRED")\r
124         SET(_IS_RELEASE OFF)\r
125         SET(_IS_DEBUG OFF)\r
126         SET(_IS_SUFFIXES OFF)\r
127         SET(_IS_DIR OFF)\r
128         SET(${NAME}_FIND_REQUIRED ON)\r
129       ELSEIF(_PARAM STREQUAL "DIR")\r
130         SET(_IS_RELEASE OFF)\r
131         SET(_IS_DEBUG OFF)\r
132         SET(_IS_SUFFIXES OFF)\r
133         SET(_IS_DIR ON)\r
134       ELSE()\r
135         IF(_IS_RELEASE)\r
136           LIST(APPEND _RELEASE_LIBRARIES ${_PARAM})\r
137         ELSEIF(_IS_DEBUG)\r
138           LIST(APPEND _DEBUG_LIBRARIES ${_PARAM})\r
139         ELSEIF(_IS_SUFFIXES)\r
140           LIST(APPEND _SUFFIXES ${_PARAM})\r
141         ELSEIF(_IS_DIR)\r
142           LIST(APPEND _BASE_DIRECTORIES ${_PARAM})\r
143         ELSE()\r
144           MESSAGE(STATUS "parameter ${_PARAM} with no prefix")\r
145         ENDIF()\r
146       ENDIF()\r
147     ENDFOREACH()\r
148   ENDIF()\r
150   # Fixes names if invalid characters are found\r
151   IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$")\r
152     SET(_NAME_FIXED ${NAME})\r
153   ELSE()\r
154     # if invalid characters are detected, replace them by valid ones\r
155     STRING(REPLACE "+" "p" _NAME_FIXED ${NAME})\r
156   ENDIF()\r
158   # Create uppercase and lowercase versions of NAME\r
159   STRING(TOUPPER ${NAME} _UPNAME)\r
160   STRING(TOLOWER ${NAME} _LOWNAME)\r
162   STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED)\r
163   STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED)\r
165   SET(_SUFFIXES ${_SUFFIXES} ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME})\r
167 # Don't use pkg-config\r
168 #  IF(NOT WIN32 AND NOT IOS)\r
169 #    FIND_PACKAGE(PkgConfig QUIET)\r
170 #    SET(_MODULES ${_LOWNAME} ${_RELEASE_LIBRARIES})\r
171 #    LIST(REMOVE_DUPLICATES _MODULES)\r
172 #    IF(PKG_CONFIG_EXECUTABLE)\r
173 #      PKG_SEARCH_MODULE(PKG_${_NAME_FIXED} QUIET ${_MODULES})\r
174 #    ENDIF()\r
175 #  ENDIF()\r
177   SET(_INCLUDE_PATHS)\r
178   SET(_LIBRARY_PATHS)\r
179   # Check for root directories passed to CMake with -DXXX_ROOT=...\r
180   IF(DEFINED ENV{${_UPNAME_FIXED}_ROOT})\r
181     SET(_TMP ${${_UPNAME_FIXED}_ROOT})\r
182     GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE)\r
183     LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP})\r
184     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
186     IF(_IS_VERBOSE)\r
187       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_ROOT as root directory ${_TMP}")\r
188     ENDIF()\r
189   ENDIF()\r
191   # Check for root directories passed to CMake with -DXXX_DIR=...\r
192   IF(DEFINED ${_UPNAME_FIXED}_DIR)\r
193     SET(_TMP ${${_UPNAME_FIXED}_DIR})\r
194     GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE)\r
195     LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP})\r
196     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
198     IF(_IS_VERBOSE)\r
199       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
200     ENDIF()\r
201   ENDIF()\r
203   IF(DEFINED ${_UPNAME}_DIR)\r
204     SET(_TMP ${${_UPNAME}_DIR})\r
205     LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP})\r
206     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
208     IF(_IS_VERBOSE)\r
209       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
210     ENDIF()\r
211   ENDIF()\r
213   IF(_BASE_DIRECTORIES)\r
214     FOREACH(_DIR ${_BASE_DIRECTORIES})\r
215       IF(_DIR)\r
216         LIST(APPEND _INCLUDE_PATHS ${_DIR}/include ${_DIR})\r
217         LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})\r
219         IF(_IS_VERBOSE)\r
220           MESSAGE(STATUS "Using ${_DIR} as root directory")\r
221         ENDIF()\r
222       ENDIF()\r
223     ENDFOREACH()\r
224   ENDIF()\r
226   IF(UNIX AND NOT DEFINED ENV{${_UPNAME_FIXED}_ROOT})\r
227     # Append UNIX standard include paths\r
228     SET(_UNIX_INCLUDE_PATHS)\r
230     # Append multiarch include paths\r
231     IF(CMAKE_LIBRARY_ARCHITECTURE)\r
232       LIST(APPEND _UNIX_INCLUDE_PATHS\r
233         /usr/local/include/${CMAKE_LIBRARY_ARCHITECTURE}\r
234         /usr/include/${CMAKE_LIBRARY_ARCHITECTURE})\r
235     ENDIF()\r
237     LIST(APPEND _UNIX_INCLUDE_PATHS\r
238       /usr/local/include\r
239       /usr/include\r
240       /sw/include\r
241       /opt/local/include\r
242       /opt/csw/include\r
243       /opt/include)\r
244   ENDIF()\r
246   IF(_IS_VERBOSE)\r
247     MESSAGE(STATUS "Searching header ${INCLUDE} in: ${_INCLUDE_PATHS} with suffixes ${_SUFFIXES}")\r
248   ENDIF()\r
250   # Search for include directory\r
251   FIND_PATH(${_UPNAME_FIXED}_INCLUDE_DIR\r
252     NAMES ${INCLUDE}\r
253     HINTS\r
254       ${PKG_${_NAME_FIXED}_INCLUDE_DIRS}\r
255       ${_INCLUDE_PATHS}\r
256       $ENV{${_UPNAME}_DIR}/include\r
257       $ENV{${_UPNAME_FIXED}_DIR}/include\r
258       $ENV{${_UPNAME}_DIR}\r
259       $ENV{${_UPNAME_FIXED}_DIR}\r
260     PATHS\r
261     ${_UNIX_INCLUDE_PATHS}\r
262     PATH_SUFFIXES\r
263     ${_SUFFIXES}\r
264     DOC "Include path for ${NAME}"\r
265   )\r
267   IF(_IS_VERBOSE)\r
268     IF(${_UPNAME_FIXED}_INCLUDE_DIR)\r
269       MESSAGE(STATUS "${INCLUDE} found in ${${_UPNAME_FIXED}_INCLUDE_DIR}")\r
270     ELSE()\r
271       MESSAGE(STATUS "${INCLUDE} not found")\r
272     ENDIF()\r
273   ENDIF()\r
275   # Append environment variables XXX_DIR\r
276   IF(DEFINED ENV{${_UPNAME}_DIR})\r
277     LIST(APPEND _LIBRARY_PATHS\r
278       $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX})\r
279   ENDIF()\r
280   IF(DEFINED ENV{${_UPNAME_FIXED}_DIR})\r
281     LIST(APPEND _LIBRARY_PATHS\r
282       $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX})\r
283   ENDIF()\r
285   IF(UNIX AND NOT DEFINED ENV{${_UPNAME_FIXED}_ROOT})\r
286     SET(_UNIX_LIBRARY_PATHS)\r
288     # Append multiarch libraries paths\r
289     IF(CMAKE_LIBRARY_ARCHITECTURE)\r
290       LIST(APPEND _UNIX_LIBRARY_PATHS\r
291         /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
292         /lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
293         /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})\r
294     ENDIF()\r
296     # Append UNIX standard libraries paths\r
297     LIST(APPEND _UNIX_LIBRARY_PATHS\r
298       /usr/local/lib\r
299       /usr/lib\r
300       /lib\r
301       /usr/local/X11R6/lib\r
302       /usr/X11R6/lib\r
303       /sw/lib\r
304       /opt/local/lib\r
305       /opt/csw/lib\r
306       /opt/lib\r
307       /usr/freeware/lib${LIB_SUFFIX})\r
308   ENDIF()\r
310   LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED})\r
311   LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d)\r
313   # Under Windows, some libs may need the lib prefix\r
314   IF(WIN32)\r
315     SET(_LIBS ${_RELEASE_LIBRARIES})\r
316     FOREACH(_LIB ${_LIBS})\r
317       LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})\r
318     ENDFOREACH()\r
320     SET(_LIBS ${_DEBUG_LIBRARIES})\r
321     FOREACH(_LIB ${_LIBS})\r
322       LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})\r
323     ENDFOREACH()\r
324   ENDIF()\r
326   LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES)\r
327   LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES)\r
329   # Search for release library\r
330   IF(DEFINED ENV{${_UPNAME_FIXED}_ROOT} AND NOT WIN32)\r
331     FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE\r
332       NAMES\r
333       ${_RELEASE_LIBRARIES}\r
334       HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
335       PATHS\r
336       ${_LIBRARY_PATHS}\r
337       ${_UNIX_LIBRARY_PATHS}\r
338       NO_CMAKE_PATH \r
339       NO_CMAKE_SYSTEM_PATH\r
340       NO_CMAKE_ENVIRONMENT_PATH\r
341       NO_SYSTEM_ENVIRONMENT_PATH\r
342     )\r
343   ELSE()\r
344     FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE\r
345       NAMES\r
346       ${_RELEASE_LIBRARIES}\r
347       HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
348       PATHS\r
349       ${_LIBRARY_PATHS}\r
350       ${_UNIX_LIBRARY_PATHS}\r
351       NO_CMAKE_SYSTEM_PATH\r
352     )\r
353   ENDIF()\r
355   IF(_IS_VERBOSE)\r
356     IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
357       MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")\r
358     ELSE()\r
359       MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")\r
360     ENDIF()\r
361   ENDIF()\r
363   # Search for debug library\r
364   IF(DEFINED ENV{${_UPNAME_FIXED}_ROOT} AND NOT WIN32)\r
365     FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG\r
366       NAMES\r
367       ${_DEBUG_LIBRARIES}\r
368       HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
369       PATHS\r
370       ${_LIBRARY_PATHS}\r
371       ${_UNIX_LIBRARY_PATHS}\r
372       NO_CMAKE_PATH \r
373       NO_CMAKE_SYSTEM_PATH\r
374       NO_CMAKE_ENVIRONMENT_PATH\r
375       NO_SYSTEM_ENVIRONMENT_PATH\r
376     )\r
377   ELSE()\r
378     FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG\r
379       NAMES\r
380       ${_DEBUG_LIBRARIES}\r
381       HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
382       PATHS\r
383       ${_LIBRARY_PATHS}\r
384       ${_UNIX_LIBRARY_PATHS}\r
385       NO_CMAKE_SYSTEM_PATH\r
386     )\r
387   ENDIF()\r
389   IF(_IS_VERBOSE)\r
390     IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
391       MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")\r
392     ELSE()\r
393       MESSAGE(STATUS "${NAME} debug library not found")\r
394     ENDIF()\r
395   ENDIF()\r
397   SET(${_UPNAME_FIXED}_FOUND OFF)\r
399   IF(${_UPNAME_FIXED}_INCLUDE_DIR)\r
400     # Set also _INCLUDE_DIRS\r
401     SET(${_UPNAME_FIXED}_INCLUDE_DIRS ${${_UPNAME_FIXED}_INCLUDE_DIR})\r
402   ENDIF()\r
404   # Library has been found if at least only one library and include are found\r
405   IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
406     # Release and debug libraries found\r
407     SET(${_UPNAME_FIXED}_FOUND ON)\r
408     SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
409     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
410   ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
411     # Release library found\r
412     SET(${_UPNAME_FIXED}_FOUND ON)\r
413     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
414     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
415   ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
416     # Debug library found\r
417     SET(${_UPNAME_FIXED}_FOUND ON)\r
418     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
419     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
420   ENDIF()\r
422   IF(${_UPNAME_FIXED}_FOUND)\r
423     IF(NOT ${NAME}_FIND_QUIETLY)\r
424       MESSAGE(STATUS "Found ${NAME}: ${${_UPNAME_FIXED}_LIBRARIES}")\r
425     ENDIF()\r
426   ELSE()\r
427     IF(${NAME}_FIND_REQUIRED)\r
428       MESSAGE(FATAL_ERROR "Error: Unable to find ${NAME}!")\r
429     ENDIF()\r
430     IF(NOT ${NAME}_FIND_QUIETLY)\r
431       MESSAGE(STATUS "Warning: Unable to find ${NAME}!")\r
432     ENDIF()\r
433   ENDIF()\r
435   MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
436 ENDMACRO()\r
438 MACRO(MESSAGE_VERSION_PACKAGE_HELPER NAME VERSION)\r
439   MESSAGE(STATUS "Found ${NAME} ${VERSION}: ${ARGN}")\r
440 ENDMACRO()\r
442 MACRO(FIND_LIBRARY_HELPER NAME)\r
443   # Looks for libraries.\r
444   #\r
445   # NAME is the name of the library, lowercase and uppercase can be mixed\r
446   #\r
447   # Following parameters are optional variables and must be prefixed by:\r
448   #\r
449   # RELEASE is the list of libraries to check in release mode\r
450   # DEBUG is the list of libraries to check in debug mode\r
451   # VERBOSE display more details if not found\r
452   # REQUIRED throw an error if not found\r
453   # DIR is the base directory where to look for\r
454   #\r
455   # The first match will be used in the specified order and next matches will be ignored\r
456   #\r
457   # The following values are defined\r
458   # NAME_LIBRARIES   - link against these to use NAME\r
460   SET(_PARAMS ${ARGN})\r
462   SET(_RELEASE_LIBRARIES)\r
463   SET(_DEBUG_LIBRARIES)\r
464   SET(_BASE_DIRECTORIES)\r
466   SET(_IS_RELEASE OFF)\r
467   SET(_IS_DEBUG OFF)\r
468   SET(_IS_VERBOSE OFF)\r
469   SET(_IS_DIR OFF)\r
471   IF(_PARAMS)\r
472     FOREACH(_PARAM ${_PARAMS})\r
473       IF(_PARAM STREQUAL "RELEASE")\r
474         SET(_IS_RELEASE ON)\r
475         SET(_IS_DEBUG OFF)\r
476         SET(_IS_DIR OFF)\r
477       ELSEIF(_PARAM STREQUAL "DEBUG")\r
478         SET(_IS_RELEASE OFF)\r
479         SET(_IS_DEBUG ON)\r
480         SET(_IS_DIR OFF)\r
481       ELSEIF(_PARAM STREQUAL "VERBOSE")\r
482         SET(_IS_RELEASE OFF)\r
483         SET(_IS_DEBUG OFF)\r
484         SET(_IS_DIR OFF)\r
485         SET(_IS_VERBOSE ON)\r
486       ELSEIF(_PARAM STREQUAL "REQUIRED")\r
487         SET(_IS_RELEASE OFF)\r
488         SET(_IS_DEBUG OFF)\r
489         SET(_IS_DIR OFF)\r
490         SET(${NAME}_FIND_REQUIRED ON)\r
491       ELSEIF(_PARAM STREQUAL "DIR")\r
492         SET(_IS_RELEASE OFF)\r
493         SET(_IS_DEBUG OFF)\r
494         SET(_IS_DIR ON)\r
495       ELSE()\r
496         IF(_IS_RELEASE)\r
497           LIST(APPEND _RELEASE_LIBRARIES ${_PARAM})\r
498         ELSEIF(_IS_DEBUG)\r
499           LIST(APPEND _DEBUG_LIBRARIES ${_PARAM})\r
500         ELSEIF(_IS_DIR)\r
501           LIST(APPEND _BASE_DIRECTORIES ${_PARAM})\r
502         ELSE()\r
503           MESSAGE(STATUS "parameter ${_PARAM} with no prefix")\r
504         ENDIF()\r
505       ENDIF()\r
506     ENDFOREACH()\r
507   ENDIF()\r
509   # Fixes names if invalid characters are found\r
510   IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$")\r
511     SET(_NAME_FIXED ${NAME})\r
512   ELSE()\r
513     # if invalid characters are detected, replace them by valid ones\r
514     STRING(REPLACE "+" "p" _NAME_FIXED ${NAME})\r
515   ENDIF()\r
517   # Create uppercase and lowercase versions of NAME\r
518   STRING(TOUPPER ${NAME} _UPNAME)\r
519   STRING(TOLOWER ${NAME} _LOWNAME)\r
521   STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED)\r
522   STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED)\r
524   SET(_LIBRARY_PATHS)\r
526   # Check for root directories passed to CMake with -DXXX_DIR=...\r
527   IF(DEFINED ${_UPNAME_FIXED}_DIR)\r
528     SET(_TMP ${${_UPNAME_FIXED}_DIR})\r
529     GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE)\r
530     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
532     IF(_IS_VERBOSE)\r
533       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
534     ENDIF()\r
535   ENDIF()\r
537   IF(DEFINED ${_UPNAME}_DIR)\r
538     SET(_TMP ${${_UPNAME}_DIR})\r
539     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
541     IF(_IS_VERBOSE)\r
542       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
543     ENDIF()\r
544   ENDIF()\r
546   IF(_BASE_DIRECTORIES)\r
547     FOREACH(_DIR ${_BASE_DIRECTORIES})\r
548       IF(_DIR)\r
549         LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})\r
551         IF(_IS_VERBOSE)\r
552           MESSAGE(STATUS "Using ${_DIR} as root directory")\r
553         ENDIF()\r
554       ENDIF()\r
555     ENDFOREACH()\r
556   ENDIF()\r
558   # Append environment variables XXX_DIR\r
559   LIST(APPEND _LIBRARY_PATHS\r
560     $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX}\r
561     $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX})\r
563   IF(UNIX)\r
564     SET(_UNIX_LIBRARY_PATHS)\r
566     # Append multiarch libraries paths\r
567     IF(CMAKE_LIBRARY_ARCHITECTURE)\r
568       LIST(APPEND _UNIX_LIBRARY_PATHS\r
569         /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
570         /lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
571         /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})\r
572     ENDIF()\r
574     # Append UNIX standard libraries paths\r
575     LIST(APPEND _UNIX_LIBRARY_PATHS\r
576       /usr/local/lib\r
577       /usr/lib\r
578       /lib\r
579       /usr/local/X11R6/lib\r
580       /usr/X11R6/lib\r
581       /sw/lib\r
582       /opt/local/lib\r
583       /opt/csw/lib\r
584       /opt/lib\r
585       /usr/freeware/lib${LIB_SUFFIX})\r
586   ENDIF()\r
588   LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED})\r
589   LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d)\r
591   # Under Windows, some libs may need the lib prefix\r
592   IF(WIN32)\r
593     SET(_LIBS ${_RELEASE_LIBRARIES})\r
594     FOREACH(_LIB ${_LIBS})\r
595       LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})\r
596     ENDFOREACH()\r
598     SET(_LIBS ${_DEBUG_LIBRARIES})\r
599     FOREACH(_LIB ${_LIBS})\r
600       LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})\r
601     ENDFOREACH()\r
602   ENDIF()\r
604   LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES)\r
605   LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES)\r
607   # Search for release library\r
608   FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE\r
609     NAMES\r
610     ${_RELEASE_LIBRARIES}\r
611     HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
612     PATHS\r
613     ${_LIBRARY_PATHS}\r
614     ${_UNIX_LIBRARY_PATHS}\r
615     NO_CMAKE_SYSTEM_PATH\r
616   )\r
618   IF(_IS_VERBOSE)\r
619     IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
620       MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")\r
621     ELSE()\r
622       MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")\r
623     ENDIF()\r
624   ENDIF()\r
626   # Search for debug library\r
627   FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG\r
628     NAMES\r
629     ${_DEBUG_LIBRARIES}\r
630     HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
631     PATHS\r
632     ${_LIBRARY_PATHS}\r
633     ${_UNIX_LIBRARY_PATHS}\r
634     NO_CMAKE_SYSTEM_PATH\r
635   )\r
637   IF(_IS_VERBOSE)\r
638     IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
639       MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")\r
640     ELSE()\r
641       MESSAGE(STATUS "${NAME} debug library not found")\r
642     ENDIF()\r
643   ENDIF()\r
645   # Library has been found if at least only one library and include are found\r
646   IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
647     # Release and debug libraries found\r
648     SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
649     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
650   ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
651     # Release library found\r
652     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
653     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
654   ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
655     # Debug library found\r
656     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
657     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
658   ENDIF()\r
660   MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
661 ENDMACRO()\r
663 MACRO(FIND_LIBCURL)\r
664   IF(NOT CURL_FOUND)\r
665     FIND_PACKAGE(CURL REQUIRED)\r
667     IF(WIN32 OR CURL_LIBRARY MATCHES "\\.a" OR WITH_STATIC_CURL)\r
668       SET(CURL_STATIC ON)\r
669     ELSE()\r
670       SET(CURL_STATIC OFF)\r
671     ENDIF()\r
673     IF(CURL_STATIC)\r
674       SET(CURL_DEFINITIONS -DCURL_STATICLIB)\r
676       IF(UNIX)\r
677         # CURL can depend on libidn\r
678         FIND_LIBRARY(IDN_LIBRARY idn)\r
679         IF(IDN_LIBRARY)\r
680           LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY})\r
681         ENDIF()\r
683         # CURL Macports version can depend on libidn, libintl and libiconv too\r
684         IF(APPLE)\r
685           FIND_LIBRARY(INTL_LIBRARY intl)\r
686           IF(INTL_LIBRARY)\r
687             LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY})\r
688           ENDIF()\r
689         ELSE()\r
690           # Only used by libcurl under Linux\r
691           FIND_PACKAGE(OpenSSL REQUIRED)\r
693           #IF(WIN32)\r
694           #  SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib)\r
695           #ENDIF()\r
697           # Only Linux version of libcurl depends on OpenSSL\r
698           LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})\r
699           LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})\r
700         ENDIF()\r
701       ENDIF()\r
702     ENDIF()\r
703   ENDIF()\r
704 ENDMACRO()\r
706 MACRO(FIND_LIBXML2)\r
707   IF(NOT LIBXML2_FOUND)\r
708     FIND_PACKAGE(LibXml2 REQUIRED)\r
710     IF(WIN32 OR WITH_STATIC_LIBXML2)\r
711       LIST(APPEND LIBXML2_DEFINITIONS -DLIBXML_STATIC)\r
712     ENDIF()\r
714     FIND_PACKAGE(Iconv QUIET)\r
715     IF(ICONV_FOUND)\r
716 #      LIST(APPEND CURL_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})\r
717       LIST(APPEND LIBXML2_LIBRARIES ${ICONV_LIBRARIES})\r
718     ENDIF()\r
720     IF(WITH_STATIC)\r
721       # libxml2 could need winsock2 library\r
722       IF(WIN32)\r
723         FIND_LIBRARY(WINSOCK2_LIB ws2_32)\r
724       \r
725         IF(WINSOCK2_LIB)\r
726           LIST(APPEND LIBXML2_LIBRARIES ${WINSOCK2_LIB})\r
727         ENDIF()\r
729         FIND_LIBRARY(CRYPT32_LIB Crypt32)\r
731         IF(CRYPT32_LIB)\r
732           LIST(APPEND LIBXML2_LIBRARIES ${CRYPT32_LIB})\r
733         ENDIF()\r
734       ELSEIF(NOT HUNTER_ENABLED)\r
735         # under Linux and OS X, recent libxml2 versions are linked against liblzma\r
736         FIND_PACKAGE(LibLZMA)\r
738         IF(LIBLZMA_LIBRARIES)\r
739           LIST(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES})\r
740         ENDIF()\r
741       ENDIF()\r
742     ENDIF()\r
743   ENDIF()\r
744 ENDMACRO()\r
746 MACRO(ADD_QT_LIBRARY _NAME)\r
747   IF(WIN32)\r
748     SET(_PREFIX "Qt5")\r
749     SET(_EXT "lib")\r
750   ELSE()\r
751     SET(_PREFIX "libQt5")\r
752     SET(_EXT "a")\r
753   ENDIF()\r
754   SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}")\r
755   IF(EXISTS ${_LIB})\r
756     LIST(APPEND QT_LIBRARIES optimized ${_LIB})\r
757   ENDIF()\r
758   SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}")\r
759   IF(EXISTS ${_LIB})\r
760     LIST(APPEND QT_LIBRARIES debug ${_LIB})\r
761   ENDIF()\r
762 ENDMACRO()\r
764 MACRO(ADD_QT_PLUGIN _TYPE _NAME)\r
765   IF(WIN32)\r
766     SET(_PREFIX "")\r
767     SET(_EXT "lib")\r
768   ELSE()\r
769     SET(_PREFIX "lib")\r
770     SET(_EXT "a")\r
771   ENDIF()\r
772   SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}")\r
773   IF(EXISTS ${_LIB})\r
774     LIST(APPEND QT_LIBRARIES optimized ${_LIB})\r
775   ENDIF()\r
776   SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}")\r
777   IF(EXISTS ${_LIB})\r
778     LIST(APPEND QT_LIBRARIES debug ${_LIB})\r
779   ENDIF()\r
780 ENDMACRO()\r
782 MACRO(ADD_QT_SYSTEM_LIBRARY _NAME)\r
783   # Save default suffixes\r
784   SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})\r
786   # Define specific suffixes\r
787   SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})\r
789   # Find the library with specified suffixes\r
790   FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME})\r
792   # Restore default suffixes\r
793   SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES})\r
795   IF(${_NAME}_LIBRARY)\r
796     MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}")\r
798     LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY})\r
799   ELSE()\r
800     MESSAGE(STATUS "Didn't find ${_NAME}")\r
801   ENDIF()\r
802 ENDMACRO()\r
804 MACRO(FIND_QT5)\r
805   CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR)\r
807   SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})\r
809   FIND_PACKAGE(Qt5Core QUIET)\r
811   IF(Qt5Core_FOUND)\r
812     # Check if we are using Qt static or shared libraries\r
813     GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE)\r
815     SET(QT_VERSION "${Qt5Core_VERSION_STRING}")\r
816     SET(_VERSION "${QT_VERSION}")\r
818     IF(_FILE MATCHES "\\.(lib|a)$")\r
819       SET(QT_STATIC ON)\r
820       SET(_VERSION "${_VERSION} static version")\r
821     ELSE()\r
822       SET(QT_STATIC OFF)\r
823       SET(_VERSION "${_VERSION} shared version")\r
824     ENDIF()\r
826     MESSAGE(STATUS "Found Qt ${_VERSION}")\r
828     # These variables are not defined with Qt5 CMake modules\r
829     SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin")\r
830     SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib")\r
831     SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins")\r
832     SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations")\r
834     # Fix wrong include directories with Qt 5 under Mac OS X\r
835     INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include")\r
837     FIND_PACKAGE(Qt5Gui)\r
838     FIND_PACKAGE(Qt5Widgets)\r
839     FIND_PACKAGE(Qt5OpenGL)\r
840     FIND_PACKAGE(Qt5Xml)\r
841     FIND_PACKAGE(Qt5LinguistTools)\r
842     FIND_PACKAGE(Qt5Network)\r
844     IF(QT_STATIC)\r
845       FIND_PACKAGE(PNG REQUIRED)\r
846       FIND_PACKAGE(Jpeg REQUIRED)\r
848       ADD_DEFINITIONS(-DQT_STATICPLUGIN)\r
850       SET(QT_LIBRARIES Qt5::Widgets)\r
852       # Gui\r
853       LIST(APPEND QT_LIBRARIES Qt5::Gui Qt5::OpenGL)\r
855       ADD_QT_LIBRARY(PrintSupport)\r
857       IF(WIN32)\r
858         LIST(APPEND QT_LIBRARIES\r
859           ${WINSDK_LIBRARY_DIR}/Imm32.lib\r
860           ${WINSDK_LIBRARY_DIR}/OpenGL32.lib\r
861           ${WINSDK_LIBRARY_DIR}/WinMM.Lib)\r
862         ADD_QT_PLUGIN(platforms qwindows)\r
863         ADD_QT_LIBRARY(PlatformSupport)\r
864       ELSEIF(APPLE)\r
865         # Cups needs .dylib\r
866         SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})\r
867         SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)\r
868         FIND_LIBRARY(CUPS_LIBRARY cups)\r
869         SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})\r
871         FIND_LIBRARY(IOKIT_FRAMEWORK IOKit)\r
872         FIND_LIBRARY(COCOA_FRAMEWORK Cocoa)\r
873         FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration)\r
874         FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL)\r
876         LIST(APPEND QT_LIBRARIES\r
877           ${CUPS_LIBRARY}\r
878           ${COCOA_FRAMEWORK}\r
879           ${SYSTEMCONFIGURATION_FRAMEWORK}\r
880           ${IOKIT_FRAMEWORK}\r
881           ${OPENGL_FRAMEWORK})\r
883         ADD_QT_PLUGIN(printsupport cocoaprintersupport)\r
884         ADD_QT_PLUGIN(platforms qcocoa)\r
885         ADD_QT_LIBRARY(PlatformSupport)\r
886       ELSE()\r
887         # order is very important there\r
888         ADD_QT_PLUGIN(platforms qxcb)\r
889         ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration)\r
891         ADD_QT_LIBRARY(XcbQpa)\r
892         ADD_QT_LIBRARY(GlxSupport)\r
893         ADD_QT_LIBRARY(ServiceSupport)\r
894         ADD_QT_LIBRARY(EdidSupport)\r
895         ADD_QT_LIBRARY(FontDatabaseSupport)\r
896         ADD_QT_LIBRARY(ThemeSupport)\r
897         ADD_QT_LIBRARY(EventDispatcherSupport)\r
898         ADD_QT_LIBRARY(PlatformSupport)\r
900         ADD_QT_LIBRARY(DBus)\r
902         IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a")\r
903           LIST(APPEND QT_LIBRARIES "${QT_LIBRARY_DIR}/libxcb-static.a")\r
904         ENDIF()\r
906         # always link these in dynamic, API never changes\r
907         ADD_QT_SYSTEM_LIBRARY(X11)\r
908         ADD_QT_SYSTEM_LIBRARY(Xmu)\r
909         ADD_QT_SYSTEM_LIBRARY(X11-xcb)\r
910         ADD_QT_SYSTEM_LIBRARY(Xi)\r
911         ADD_QT_SYSTEM_LIBRARY(SM)\r
912         ADD_QT_SYSTEM_LIBRARY(ICE)\r
913         ADD_QT_SYSTEM_LIBRARY(xcb)\r
914         ADD_QT_SYSTEM_LIBRARY(GL)\r
915         ADD_QT_SYSTEM_LIBRARY(xcb-glx)\r
916         ADD_QT_SYSTEM_LIBRARY(fontconfig)\r
917         ADD_QT_SYSTEM_LIBRARY(Xrender)\r
918       ENDIF()\r
920       ADD_QT_PLUGIN(imageformats qgif)\r
921       ADD_QT_PLUGIN(imageformats qicns)\r
922       ADD_QT_PLUGIN(imageformats qico)\r
923       ADD_QT_PLUGIN(imageformats qjpeg)\r
925       # harfbuzz is needed since Qt 5.3\r
926       IF(UNIX)\r
927         SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a")\r
928         IF(NOT EXISTS ${HB_LIB})\r
929           SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a")\r
930         ENDIF()\r
931       ELSEIF(WIN32)\r
932         SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib")\r
933       ENDIF()\r
934       IF(EXISTS ${HB_LIB})\r
935         LIST(APPEND QT_LIBRARIES ${HB_LIB})\r
936       ENDIF()\r
938       # freetype is needed since Qt 5.5\r
939       FIND_PACKAGE(Freetype)\r
941       IF(FREETYPE_FOUND)\r
942         LIST(APPEND QT_LIBRARIES ${FREETYPE_LIBRARIES})\r
943       ELSE()\r
944         IF(UNIX)\r
945           SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a")\r
946         ELSEIF(WIN32)\r
947           SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib")\r
948         ENDIF()\r
949         IF(EXISTS ${FREETYPE_LIB})\r
950           LIST(APPEND QT_LIBRARIES ${FREETYPE_LIB})\r
951         ENDIF()\r
952       ENDIF()\r
954       ADD_QT_PLUGIN(accessible qtaccessiblewidgets)\r
956       LIST(APPEND QT_LIBRARIES ${PNG_LIBRARIES} ${JPEG_LIBRARY})\r
958       # Network\r
959       LIST(APPEND QT_LIBRARIES Qt5::Network Qt5::Xml)\r
960       LIST(APPEND QT_LIBRARIES ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})\r
962       IF(WIN32)\r
963         LIST(APPEND QT_LIBRARIES\r
964           ${WINSDK_LIBRARY_DIR}/Crypt32.lib\r
965           ${WINSDK_LIBRARY_DIR}/WS2_32.Lib\r
966           ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib)\r
967       ENDIF()\r
969       # Core\r
970       LIST(APPEND QT_LIBRARIES Qt5::Core)\r
972       # pcre is needed since Qt 5.5\r
973       IF(UNIX)\r
974         SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a")\r
975         IF(NOT EXISTS ${PCRE_LIB})\r
976           SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a")\r
977         ENDIF()\r
978       ELSEIF(WIN32)\r
979         SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib")\r
980       ENDIF()\r
981       IF(EXISTS ${PCRE_LIB})\r
982         LIST(APPEND QT_LIBRARIES ${PCRE_LIB})\r
983       ENDIF()\r
985       IF(APPLE)\r
986         FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre)\r
988         FIND_LIBRARY(SECURITY_FRAMEWORK Security)\r
990         LIST(APPEND QT_LIBRARIES\r
991           ${PCRE_LIBRARY}\r
992           ${FOUNDATION_FRAMEWORK}\r
993           ${CARBON_FRAMEWORK}\r
994           ${SECURITY_FRAMEWORK})\r
995       ELSEIF(UNIX)\r
996         FIND_PACKAGE(Threads)\r
997         LIST(APPEND QT_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} -lrt)\r
998       ENDIF()\r
999     ELSE()\r
1000       SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)\r
1001     ENDIF()\r
1002   ELSE()\r
1003     MESSAGE(WARNING "Unable to find Qt 5")\r
1004   ENDIF()\r
1005 ENDMACRO()\r