Fix fames bug
[ryzomcore.git] / CMakeModules / FindHelpers.cmake
blobbc38354f408751c6770d0f921b976f57c71250c6
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
180   # Check for root directories passed to CMake with -DXXX_DIR=...\r
181   IF(DEFINED ${_UPNAME_FIXED}_DIR)\r
182     SET(_TMP ${${_UPNAME_FIXED}_DIR})\r
183     GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE)\r
184     LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP})\r
185     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
187     IF(_IS_VERBOSE)\r
188       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
189     ENDIF()\r
190   ENDIF()\r
192   IF(DEFINED ${_UPNAME}_DIR)\r
193     SET(_TMP ${${_UPNAME}_DIR})\r
194     LIST(APPEND _INCLUDE_PATHS ${_TMP}/include ${_TMP})\r
195     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
197     IF(_IS_VERBOSE)\r
198       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
199     ENDIF()\r
200   ENDIF()\r
202   IF(_BASE_DIRECTORIES)\r
203     FOREACH(_DIR ${_BASE_DIRECTORIES})\r
204       IF(_DIR)\r
205         LIST(APPEND _INCLUDE_PATHS ${_DIR}/include ${_DIR})\r
206         LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})\r
208         IF(_IS_VERBOSE)\r
209           MESSAGE(STATUS "Using ${_DIR} as root directory")\r
210         ENDIF()\r
211       ENDIF()\r
212     ENDFOREACH()\r
213   ENDIF()\r
215   IF(UNIX)\r
216     # Append UNIX standard include paths\r
217     SET(_UNIX_INCLUDE_PATHS)\r
219     # Append multiarch include paths\r
220     IF(CMAKE_LIBRARY_ARCHITECTURE)\r
221       LIST(APPEND _UNIX_INCLUDE_PATHS\r
222         /usr/local/include/${CMAKE_LIBRARY_ARCHITECTURE}\r
223         /usr/include/${CMAKE_LIBRARY_ARCHITECTURE})\r
224     ENDIF()\r
226     LIST(APPEND _UNIX_INCLUDE_PATHS\r
227       /usr/local/include\r
228       /usr/include\r
229       /sw/include\r
230       /opt/local/include\r
231       /opt/csw/include\r
232       /opt/include)\r
233   ENDIF()\r
235   IF(_IS_VERBOSE)\r
236     MESSAGE(STATUS "Searching header ${INCLUDE} in: ${_INCLUDE_PATHS} with suffixes ${_SUFFIXES}")\r
237   ENDIF()\r
239   # Search for include directory\r
240   FIND_PATH(${_UPNAME_FIXED}_INCLUDE_DIR\r
241     NAMES ${INCLUDE}\r
242     HINTS\r
243       ${PKG_${_NAME_FIXED}_INCLUDE_DIRS}\r
244       ${_INCLUDE_PATHS}\r
245       $ENV{${_UPNAME}_DIR}/include\r
246       $ENV{${_UPNAME_FIXED}_DIR}/include\r
247       $ENV{${_UPNAME}_DIR}\r
248       $ENV{${_UPNAME_FIXED}_DIR}\r
249     PATHS\r
250     ${_UNIX_INCLUDE_PATHS}\r
251     PATH_SUFFIXES\r
252     ${_SUFFIXES}\r
253     DOC "Include path for ${NAME}"\r
254   )\r
256   IF(_IS_VERBOSE)\r
257     IF(${_UPNAME_FIXED}_INCLUDE_DIR)\r
258       MESSAGE(STATUS "${INCLUDE} found in ${${_UPNAME_FIXED}_INCLUDE_DIR}")\r
259     ELSE()\r
260       MESSAGE(STATUS "${INCLUDE} not found")\r
261     ENDIF()\r
262   ENDIF()\r
264   # Append environment variables XXX_DIR\r
265   LIST(APPEND _LIBRARY_PATHS\r
266     $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX}\r
267     $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX})\r
269   IF(UNIX)\r
270     SET(_UNIX_LIBRARY_PATHS)\r
272     # Append multiarch libraries paths\r
273     IF(CMAKE_LIBRARY_ARCHITECTURE)\r
274       LIST(APPEND _UNIX_LIBRARY_PATHS\r
275         /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
276         /lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
277         /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})\r
278     ENDIF()\r
280     # Append UNIX standard libraries paths\r
281     LIST(APPEND _UNIX_LIBRARY_PATHS\r
282       /usr/local/lib\r
283       /usr/lib\r
284       /lib\r
285       /usr/local/X11R6/lib\r
286       /usr/X11R6/lib\r
287       /sw/lib\r
288       /opt/local/lib\r
289       /opt/csw/lib\r
290       /opt/lib\r
291       /usr/freeware/lib${LIB_SUFFIX})\r
292   ENDIF()\r
294   LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED})\r
295   LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d)\r
297   # Under Windows, some libs may need the lib prefix\r
298   IF(WIN32)\r
299     SET(_LIBS ${_RELEASE_LIBRARIES})\r
300     FOREACH(_LIB ${_LIBS})\r
301       LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})\r
302     ENDFOREACH()\r
304     SET(_LIBS ${_DEBUG_LIBRARIES})\r
305     FOREACH(_LIB ${_LIBS})\r
306       LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})\r
307     ENDFOREACH()\r
308   ENDIF()\r
310   LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES)\r
311   LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES)\r
313   # Search for release library\r
314   FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE\r
315     NAMES\r
316     ${_RELEASE_LIBRARIES}\r
317     HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
318     PATHS\r
319     ${_LIBRARY_PATHS}\r
320     ${_UNIX_LIBRARY_PATHS}\r
321     NO_CMAKE_SYSTEM_PATH\r
322   )\r
324   IF(_IS_VERBOSE)\r
325     IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
326       MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")\r
327     ELSE()\r
328       MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")\r
329     ENDIF()\r
330   ENDIF()\r
332   # Search for debug library\r
333   FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG\r
334     NAMES\r
335     ${_DEBUG_LIBRARIES}\r
336     HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
337     PATHS\r
338     ${_LIBRARY_PATHS}\r
339     ${_UNIX_LIBRARY_PATHS}\r
340     NO_CMAKE_SYSTEM_PATH\r
341   )\r
343   IF(_IS_VERBOSE)\r
344     IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
345       MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")\r
346     ELSE()\r
347       MESSAGE(STATUS "${NAME} debug library not found")\r
348     ENDIF()\r
349   ENDIF()\r
351   SET(${_UPNAME_FIXED}_FOUND OFF)\r
353   IF(${_UPNAME_FIXED}_INCLUDE_DIR)\r
354     # Set also _INCLUDE_DIRS\r
355     SET(${_UPNAME_FIXED}_INCLUDE_DIRS ${${_UPNAME_FIXED}_INCLUDE_DIR})\r
356   ENDIF()\r
358   # Library has been found if at least only one library and include are found\r
359   IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
360     # Release and debug libraries found\r
361     SET(${_UPNAME_FIXED}_FOUND ON)\r
362     SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
363     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
364   ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
365     # Release library found\r
366     SET(${_UPNAME_FIXED}_FOUND ON)\r
367     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
368     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
369   ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
370     # Debug library found\r
371     SET(${_UPNAME_FIXED}_FOUND ON)\r
372     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
373     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
374   ENDIF()\r
376   IF(${_UPNAME_FIXED}_FOUND)\r
377     IF(NOT ${NAME}_FIND_QUIETLY)\r
378       MESSAGE(STATUS "Found ${NAME}: ${${_UPNAME_FIXED}_LIBRARIES}")\r
379     ENDIF()\r
380   ELSE()\r
381     IF(${NAME}_FIND_REQUIRED)\r
382       MESSAGE(FATAL_ERROR "Error: Unable to find ${NAME}!")\r
383     ENDIF()\r
384     IF(NOT ${NAME}_FIND_QUIETLY)\r
385       MESSAGE(STATUS "Warning: Unable to find ${NAME}!")\r
386     ENDIF()\r
387   ENDIF()\r
389   MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
390 ENDMACRO()\r
392 MACRO(MESSAGE_VERSION_PACKAGE_HELPER NAME VERSION)\r
393   MESSAGE(STATUS "Found ${NAME} ${VERSION}: ${ARGN}")\r
394 ENDMACRO()\r
396 MACRO(FIND_LIBRARY_HELPER NAME)\r
397   # Looks for libraries.\r
398   #\r
399   # NAME is the name of the library, lowercase and uppercase can be mixed\r
400   #\r
401   # Following parameters are optional variables and must be prefixed by:\r
402   #\r
403   # RELEASE is the list of libraries to check in release mode\r
404   # DEBUG is the list of libraries to check in debug mode\r
405   # VERBOSE display more details if not found\r
406   # REQUIRED throw an error if not found\r
407   # DIR is the base directory where to look for\r
408   #\r
409   # The first match will be used in the specified order and next matches will be ignored\r
410   #\r
411   # The following values are defined\r
412   # NAME_LIBRARIES   - link against these to use NAME\r
414   SET(_PARAMS ${ARGN})\r
416   SET(_RELEASE_LIBRARIES)\r
417   SET(_DEBUG_LIBRARIES)\r
418   SET(_BASE_DIRECTORIES)\r
420   SET(_IS_RELEASE OFF)\r
421   SET(_IS_DEBUG OFF)\r
422   SET(_IS_VERBOSE OFF)\r
423   SET(_IS_DIR OFF)\r
425   IF(_PARAMS)\r
426     FOREACH(_PARAM ${_PARAMS})\r
427       IF(_PARAM STREQUAL "RELEASE")\r
428         SET(_IS_RELEASE ON)\r
429         SET(_IS_DEBUG OFF)\r
430         SET(_IS_DIR OFF)\r
431       ELSEIF(_PARAM STREQUAL "DEBUG")\r
432         SET(_IS_RELEASE OFF)\r
433         SET(_IS_DEBUG ON)\r
434         SET(_IS_DIR OFF)\r
435       ELSEIF(_PARAM STREQUAL "VERBOSE")\r
436         SET(_IS_RELEASE OFF)\r
437         SET(_IS_DEBUG OFF)\r
438         SET(_IS_DIR OFF)\r
439         SET(_IS_VERBOSE ON)\r
440       ELSEIF(_PARAM STREQUAL "REQUIRED")\r
441         SET(_IS_RELEASE OFF)\r
442         SET(_IS_DEBUG OFF)\r
443         SET(_IS_DIR OFF)\r
444         SET(${NAME}_FIND_REQUIRED ON)\r
445       ELSEIF(_PARAM STREQUAL "DIR")\r
446         SET(_IS_RELEASE OFF)\r
447         SET(_IS_DEBUG OFF)\r
448         SET(_IS_DIR ON)\r
449       ELSE()\r
450         IF(_IS_RELEASE)\r
451           LIST(APPEND _RELEASE_LIBRARIES ${_PARAM})\r
452         ELSEIF(_IS_DEBUG)\r
453           LIST(APPEND _DEBUG_LIBRARIES ${_PARAM})\r
454         ELSEIF(_IS_DIR)\r
455           LIST(APPEND _BASE_DIRECTORIES ${_PARAM})\r
456         ELSE()\r
457           MESSAGE(STATUS "parameter ${_PARAM} with no prefix")\r
458         ENDIF()\r
459       ENDIF()\r
460     ENDFOREACH()\r
461   ENDIF()\r
463   # Fixes names if invalid characters are found\r
464   IF("${NAME}" MATCHES "^[a-zA-Z0-9]+$")\r
465     SET(_NAME_FIXED ${NAME})\r
466   ELSE()\r
467     # if invalid characters are detected, replace them by valid ones\r
468     STRING(REPLACE "+" "p" _NAME_FIXED ${NAME})\r
469   ENDIF()\r
471   # Create uppercase and lowercase versions of NAME\r
472   STRING(TOUPPER ${NAME} _UPNAME)\r
473   STRING(TOLOWER ${NAME} _LOWNAME)\r
475   STRING(TOUPPER ${_NAME_FIXED} _UPNAME_FIXED)\r
476   STRING(TOLOWER ${_NAME_FIXED} _LOWNAME_FIXED)\r
478   SET(_LIBRARY_PATHS)\r
480   # Check for root directories passed to CMake with -DXXX_DIR=...\r
481   IF(DEFINED ${_UPNAME_FIXED}_DIR)\r
482     SET(_TMP ${${_UPNAME_FIXED}_DIR})\r
483     GET_FILENAME_COMPONENT(_TMP ${_TMP} ABSOLUTE)\r
484     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
486     IF(_IS_VERBOSE)\r
487       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
488     ENDIF()\r
489   ENDIF()\r
491   IF(DEFINED ${_UPNAME}_DIR)\r
492     SET(_TMP ${${_UPNAME}_DIR})\r
493     LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})\r
495     IF(_IS_VERBOSE)\r
496       MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")\r
497     ENDIF()\r
498   ENDIF()\r
500   IF(_BASE_DIRECTORIES)\r
501     FOREACH(_DIR ${_BASE_DIRECTORIES})\r
502       IF(_DIR)\r
503         LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})\r
505         IF(_IS_VERBOSE)\r
506           MESSAGE(STATUS "Using ${_DIR} as root directory")\r
507         ENDIF()\r
508       ENDIF()\r
509     ENDFOREACH()\r
510   ENDIF()\r
512   # Append environment variables XXX_DIR\r
513   LIST(APPEND _LIBRARY_PATHS\r
514     $ENV{${_UPNAME}_DIR}/lib${LIB_SUFFIX}\r
515     $ENV{${_UPNAME_FIXED}_DIR}/lib${LIB_SUFFIX})\r
517   IF(UNIX)\r
518     SET(_UNIX_LIBRARY_PATHS)\r
520     # Append multiarch libraries paths\r
521     IF(CMAKE_LIBRARY_ARCHITECTURE)\r
522       LIST(APPEND _UNIX_LIBRARY_PATHS\r
523         /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
524         /lib/${CMAKE_LIBRARY_ARCHITECTURE}\r
525         /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})\r
526     ENDIF()\r
528     # Append UNIX standard libraries paths\r
529     LIST(APPEND _UNIX_LIBRARY_PATHS\r
530       /usr/local/lib\r
531       /usr/lib\r
532       /lib\r
533       /usr/local/X11R6/lib\r
534       /usr/X11R6/lib\r
535       /sw/lib\r
536       /opt/local/lib\r
537       /opt/csw/lib\r
538       /opt/lib\r
539       /usr/freeware/lib${LIB_SUFFIX})\r
540   ENDIF()\r
542   LIST(APPEND _RELEASE_LIBRARIES ${_LOWNAME} ${_LOWNAME_FIXED} ${NAME} ${_NAME_FIXED})\r
543   LIST(APPEND _DEBUG_LIBRARIES ${_LOWNAME}d ${_LOWNAME_FIXED}d ${NAME}d ${_NAME_FIXED}d)\r
545   # Under Windows, some libs may need the lib prefix\r
546   IF(WIN32)\r
547     SET(_LIBS ${_RELEASE_LIBRARIES})\r
548     FOREACH(_LIB ${_LIBS})\r
549       LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})\r
550     ENDFOREACH()\r
552     SET(_LIBS ${_DEBUG_LIBRARIES})\r
553     FOREACH(_LIB ${_LIBS})\r
554       LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})\r
555     ENDFOREACH()\r
556   ENDIF()\r
558   LIST(REMOVE_DUPLICATES _RELEASE_LIBRARIES)\r
559   LIST(REMOVE_DUPLICATES _DEBUG_LIBRARIES)\r
561   # Search for release library\r
562   FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_RELEASE\r
563     NAMES\r
564     ${_RELEASE_LIBRARIES}\r
565     HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
566     PATHS\r
567     ${_LIBRARY_PATHS}\r
568     ${_UNIX_LIBRARY_PATHS}\r
569     NO_CMAKE_SYSTEM_PATH\r
570   )\r
572   IF(_IS_VERBOSE)\r
573     IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
574       MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")\r
575     ELSE()\r
576       MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")\r
577     ENDIF()\r
578   ENDIF()\r
580   # Search for debug library\r
581   FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG\r
582     NAMES\r
583     ${_DEBUG_LIBRARIES}\r
584     HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}\r
585     PATHS\r
586     ${_LIBRARY_PATHS}\r
587     ${_UNIX_LIBRARY_PATHS}\r
588     NO_CMAKE_SYSTEM_PATH\r
589   )\r
591   IF(_IS_VERBOSE)\r
592     IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
593       MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")\r
594     ELSE()\r
595       MESSAGE(STATUS "${NAME} debug library not found")\r
596     ENDIF()\r
597   ENDIF()\r
599   # Library has been found if at least only one library and include are found\r
600   IF(${_UPNAME_FIXED}_LIBRARY_RELEASE AND ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
601     # Release and debug libraries found\r
602     SET(${_UPNAME_FIXED}_LIBRARIES optimized ${${_UPNAME_FIXED}_LIBRARY_RELEASE} debug ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
603     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
604   ELSEIF(${_UPNAME_FIXED}_LIBRARY_RELEASE)\r
605     # Release library found\r
606     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
607     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_RELEASE})\r
608   ELSEIF(${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
609     # Debug library found\r
610     SET(${_UPNAME_FIXED}_LIBRARIES ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
611     SET(${_UPNAME_FIXED}_LIBRARY ${${_UPNAME_FIXED}_LIBRARY_DEBUG})\r
612   ENDIF()\r
614   MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)\r
615 ENDMACRO()\r
617 MACRO(FIND_LIBCURL)\r
618   IF(NOT CURL_FOUND)\r
619     FIND_PACKAGE(CURL REQUIRED)\r
621     IF(WIN32 OR CURL_LIBRARY MATCHES "\\.a" OR WITH_STATIC_CURL)\r
622       SET(CURL_STATIC ON)\r
623     ELSE()\r
624       SET(CURL_STATIC OFF)\r
625     ENDIF()\r
627     IF(CURL_STATIC)\r
628       SET(CURL_DEFINITIONS -DCURL_STATICLIB)\r
630       IF(UNIX)\r
631         # CURL can depend on libidn\r
632         FIND_LIBRARY(IDN_LIBRARY idn)\r
633         IF(IDN_LIBRARY)\r
634           LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY})\r
635         ENDIF()\r
637         # CURL Macports version can depend on libidn, libintl and libiconv too\r
638         IF(APPLE)\r
639           FIND_LIBRARY(INTL_LIBRARY intl)\r
640           IF(INTL_LIBRARY)\r
641             LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY})\r
642           ENDIF()\r
643         ELSE()\r
644           # Only used by libcurl under Linux\r
645           FIND_PACKAGE(OpenSSL REQUIRED)\r
647           #IF(WIN32)\r
648           #  SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib)\r
649           #ENDIF()\r
651           # Only Linux version of libcurl depends on OpenSSL\r
652           LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})\r
653           LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})\r
654         ENDIF()\r
655       ENDIF()\r
656     ENDIF()\r
657   ENDIF()\r
658 ENDMACRO()\r
660 MACRO(FIND_LIBXML2)\r
661   IF(NOT LIBXML2_FOUND)\r
662     FIND_PACKAGE(LibXml2 REQUIRED)\r
664     IF(WIN32 OR WITH_STATIC_LIBXML2)\r
665       LIST(APPEND LIBXML2_DEFINITIONS -DLIBXML_STATIC)\r
666     ENDIF()\r
668     IF(WITH_LIBXML2_ICONV)\r
669       FIND_PACKAGE(Iconv REQUIRED)\r
670 #      LIST(APPEND CURL_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})\r
671       LIST(APPEND LIBXML2_LIBRARIES ${ICONV_LIBRARIES})\r
672     ENDIF()\r
674     IF(WITH_STATIC)\r
675       # libxml2 could need winsock2 library\r
676       IF(WIN32)\r
677         FIND_LIBRARY(WINSOCK2_LIB ws2_32)\r
678       \r
679         IF(WINSOCK2_LIB)\r
680           LIST(APPEND LIBXML2_LIBRARIES ${WINSOCK2_LIB})\r
681         ENDIF()\r
683         FIND_LIBRARY(CRYPT32_LIB Crypt32)\r
685         IF(CRYPT32_LIB)\r
686           LIST(APPEND LIBXML2_LIBRARIES ${CRYPT32_LIB})\r
687         ENDIF()\r
688       ELSE()\r
689         # under Linux and OS X, recent libxml2 versions are linked against liblzma\r
690         FIND_PACKAGE(LibLZMA)\r
692         IF(LIBLZMA_LIBRARIES)\r
693           LIST(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES})\r
694         ENDIF()\r
695       ENDIF()\r
696     ENDIF()\r
697   ENDIF()\r
698 ENDMACRO()\r
700 MACRO(ADD_QT_LIBRARY _NAME)\r
701   IF(WIN32)\r
702     SET(_PREFIX "Qt5")\r
703     SET(_EXT "lib")\r
704   ELSE()\r
705     SET(_PREFIX "libQt5")\r
706     SET(_EXT "a")\r
707   ENDIF()\r
708   SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}")\r
709   IF(EXISTS ${_LIB})\r
710     LIST(APPEND QT_LIBRARIES optimized ${_LIB})\r
711   ENDIF()\r
712   SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}")\r
713   IF(EXISTS ${_LIB})\r
714     LIST(APPEND QT_LIBRARIES debug ${_LIB})\r
715   ENDIF()\r
716 ENDMACRO()\r
718 MACRO(ADD_QT_PLUGIN _TYPE _NAME)\r
719   IF(WIN32)\r
720     SET(_PREFIX "")\r
721     SET(_EXT "lib")\r
722   ELSE()\r
723     SET(_PREFIX "lib")\r
724     SET(_EXT "a")\r
725   ENDIF()\r
726   SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}")\r
727   IF(EXISTS ${_LIB})\r
728     LIST(APPEND QT_LIBRARIES optimized ${_LIB})\r
729   ENDIF()\r
730   SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}")\r
731   IF(EXISTS ${_LIB})\r
732     LIST(APPEND QT_LIBRARIES debug ${_LIB})\r
733   ENDIF()\r
734 ENDMACRO()\r
736 MACRO(ADD_QT_SYSTEM_LIBRARY _NAME)\r
737   # Save default suffixes\r
738   SET(_OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})\r
740   # Define specific suffixes\r
741   SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})\r
743   # Find the library with specified suffixes\r
744   FIND_LIBRARY(${_NAME}_LIBRARY NAMES ${_NAME})\r
746   # Restore default suffixes\r
747   SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_OLD_SUFFIXES})\r
749   IF(${_NAME}_LIBRARY)\r
750     MESSAGE(STATUS "Found ${${_NAME}_LIBRARY} ${_NAME}")\r
752     LIST(APPEND QT_LIBRARIES ${${_NAME}_LIBRARY})\r
753   ELSE()\r
754     MESSAGE(STATUS "Didn't find ${_NAME}")\r
755   ENDIF()\r
756 ENDMACRO()\r
758 MACRO(FIND_QT5)\r
759   CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR)\r
761   SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR} $ENV{QTDIR})\r
763   FIND_PACKAGE(Qt5Core QUIET)\r
765   IF(Qt5Core_FOUND)\r
766     # Check if we are using Qt static or shared libraries\r
767     GET_TARGET_PROPERTY(_FILE Qt5::Core IMPORTED_LOCATION_RELEASE)\r
769     SET(QT_VERSION "${Qt5Core_VERSION_STRING}")\r
770     SET(_VERSION "${QT_VERSION}")\r
772     IF(_FILE MATCHES "\\.(lib|a)$")\r
773       SET(QT_STATIC ON)\r
774       SET(_VERSION "${_VERSION} static version")\r
775     ELSE()\r
776       SET(QT_STATIC OFF)\r
777       SET(_VERSION "${_VERSION} shared version")\r
778     ENDIF()\r
780     MESSAGE(STATUS "Found Qt ${_VERSION}")\r
782     # These variables are not defined with Qt5 CMake modules\r
783     SET(QT_BINARY_DIR "${_qt5Core_install_prefix}/bin")\r
784     SET(QT_LIBRARY_DIR "${_qt5Core_install_prefix}/lib")\r
785     SET(QT_PLUGINS_DIR "${_qt5Core_install_prefix}/plugins")\r
786     SET(QT_TRANSLATIONS_DIR "${_qt5Core_install_prefix}/translations")\r
788     # Fix wrong include directories with Qt 5 under Mac OS X\r
789     INCLUDE_DIRECTORIES("${_qt5Core_install_prefix}/include")\r
791     FIND_PACKAGE(Qt5Gui)\r
792     FIND_PACKAGE(Qt5Widgets)\r
793     FIND_PACKAGE(Qt5OpenGL)\r
794     FIND_PACKAGE(Qt5Xml)\r
795     FIND_PACKAGE(Qt5LinguistTools)\r
796     FIND_PACKAGE(Qt5Network)\r
798     IF(QT_STATIC)\r
799       FIND_PACKAGE(PNG REQUIRED)\r
800       FIND_PACKAGE(Jpeg REQUIRED)\r
802       ADD_DEFINITIONS(-DQT_STATICPLUGIN)\r
804       SET(QT_LIBRARIES Qt5::Widgets)\r
806       # Gui\r
807       LIST(APPEND QT_LIBRARIES Qt5::Gui Qt5::OpenGL)\r
809       ADD_QT_LIBRARY(PrintSupport)\r
811       IF(WIN32)\r
812         LIST(APPEND QT_LIBRARIES\r
813           ${WINSDK_LIBRARY_DIR}/Imm32.lib\r
814           ${WINSDK_LIBRARY_DIR}/OpenGL32.lib\r
815           ${WINSDK_LIBRARY_DIR}/WinMM.Lib)\r
816         ADD_QT_PLUGIN(platforms qwindows)\r
817         ADD_QT_LIBRARY(PlatformSupport)\r
818       ELSEIF(APPLE)\r
819         # Cups needs .dylib\r
820         SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})\r
821         SET(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)\r
822         FIND_LIBRARY(CUPS_LIBRARY cups)\r
823         SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES})\r
825         FIND_LIBRARY(IOKIT_FRAMEWORK IOKit)\r
826         FIND_LIBRARY(COCOA_FRAMEWORK Cocoa)\r
827         FIND_LIBRARY(SYSTEMCONFIGURATION_FRAMEWORK SystemConfiguration)\r
828         FIND_LIBRARY(OPENGL_FRAMEWORK NAMES OpenGL)\r
830         LIST(APPEND QT_LIBRARIES\r
831           ${CUPS_LIBRARY}\r
832           ${COCOA_FRAMEWORK}\r
833           ${SYSTEMCONFIGURATION_FRAMEWORK}\r
834           ${IOKIT_FRAMEWORK}\r
835           ${OPENGL_FRAMEWORK})\r
837         ADD_QT_PLUGIN(printsupport cocoaprintersupport)\r
838         ADD_QT_PLUGIN(platforms qcocoa)\r
839         ADD_QT_LIBRARY(PlatformSupport)\r
840       ELSE()\r
841         # order is very important there\r
842         ADD_QT_PLUGIN(platforms qxcb)\r
843         ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration)\r
845         ADD_QT_LIBRARY(XcbQpa)\r
846         ADD_QT_LIBRARY(GlxSupport)\r
847         ADD_QT_LIBRARY(ServiceSupport)\r
848         ADD_QT_LIBRARY(EdidSupport)\r
849         ADD_QT_LIBRARY(FontDatabaseSupport)\r
850         ADD_QT_LIBRARY(ThemeSupport)\r
851         ADD_QT_LIBRARY(EventDispatcherSupport)\r
852         ADD_QT_LIBRARY(PlatformSupport)\r
854         ADD_QT_LIBRARY(DBus)\r
856         IF(EXISTS "${QT_LIBRARY_DIR}/libxcb-static.a")\r
857           LIST(APPEND QT_LIBRARIES "${QT_LIBRARY_DIR}/libxcb-static.a")\r
858         ENDIF()\r
860         # always link these in dynamic, API never changes\r
861         ADD_QT_SYSTEM_LIBRARY(X11)\r
862         ADD_QT_SYSTEM_LIBRARY(Xmu)\r
863         ADD_QT_SYSTEM_LIBRARY(X11-xcb)\r
864         ADD_QT_SYSTEM_LIBRARY(Xi)\r
865         ADD_QT_SYSTEM_LIBRARY(SM)\r
866         ADD_QT_SYSTEM_LIBRARY(ICE)\r
867         ADD_QT_SYSTEM_LIBRARY(xcb)\r
868         ADD_QT_SYSTEM_LIBRARY(GL)\r
869         ADD_QT_SYSTEM_LIBRARY(xcb-glx)\r
870         ADD_QT_SYSTEM_LIBRARY(fontconfig)\r
871         ADD_QT_SYSTEM_LIBRARY(Xrender)\r
872       ENDIF()\r
874       ADD_QT_PLUGIN(imageformats qgif)\r
875       ADD_QT_PLUGIN(imageformats qicns)\r
876       ADD_QT_PLUGIN(imageformats qico)\r
877       ADD_QT_PLUGIN(imageformats qjpeg)\r
879       # harfbuzz is needed since Qt 5.3\r
880       IF(UNIX)\r
881         SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzzng.a")\r
882         IF(NOT EXISTS ${HB_LIB})\r
883           SET(HB_LIB "${QT_LIBRARY_DIR}/libqtharfbuzz.a")\r
884         ENDIF()\r
885       ELSEIF(WIN32)\r
886         SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib")\r
887       ENDIF()\r
888       IF(EXISTS ${HB_LIB})\r
889         LIST(APPEND QT_LIBRARIES ${HB_LIB})\r
890       ENDIF()\r
892       # freetype is needed since Qt 5.5\r
893       FIND_PACKAGE(Freetype)\r
895       IF(FREETYPE_FOUND)\r
896         LIST(APPEND QT_LIBRARIES ${FREETYPE_LIBRARIES})\r
897       ELSE()\r
898         IF(UNIX)\r
899           SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a")\r
900         ELSEIF(WIN32)\r
901           SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib")\r
902         ENDIF()\r
903         IF(EXISTS ${FREETYPE_LIB})\r
904           LIST(APPEND QT_LIBRARIES ${FREETYPE_LIB})\r
905         ENDIF()\r
906       ENDIF()\r
908       ADD_QT_PLUGIN(accessible qtaccessiblewidgets)\r
910       LIST(APPEND QT_LIBRARIES ${PNG_LIBRARIES} ${JPEG_LIBRARY})\r
912       # Network\r
913       LIST(APPEND QT_LIBRARIES Qt5::Network Qt5::Xml)\r
914       LIST(APPEND QT_LIBRARIES ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})\r
916       IF(WIN32)\r
917         LIST(APPEND QT_LIBRARIES\r
918           ${WINSDK_LIBRARY_DIR}/Crypt32.lib\r
919           ${WINSDK_LIBRARY_DIR}/WS2_32.Lib\r
920           ${WINSDK_LIBRARY_DIR}/IPHlpApi.Lib)\r
921       ENDIF()\r
923       # Core\r
924       LIST(APPEND QT_LIBRARIES Qt5::Core)\r
926       # pcre is needed since Qt 5.5\r
927       IF(UNIX)\r
928         SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a")\r
929         IF(NOT EXISTS ${PCRE_LIB})\r
930           SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre2.a")\r
931         ENDIF()\r
932       ELSEIF(WIN32)\r
933         SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib")\r
934       ENDIF()\r
935       IF(EXISTS ${PCRE_LIB})\r
936         LIST(APPEND QT_LIBRARIES ${PCRE_LIB})\r
937       ENDIF()\r
939       IF(APPLE)\r
940         FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre)\r
942         FIND_LIBRARY(SECURITY_FRAMEWORK Security)\r
944         LIST(APPEND QT_LIBRARIES\r
945           ${PCRE_LIBRARY}\r
946           ${FOUNDATION_FRAMEWORK}\r
947           ${CARBON_FRAMEWORK}\r
948           ${SECURITY_FRAMEWORK})\r
949       ELSEIF(UNIX)\r
950         FIND_PACKAGE(Threads)\r
951         LIST(APPEND QT_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} -lrt)\r
952       ENDIF()\r
953     ELSE()\r
954       SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)\r
955     ENDIF()\r
956   ELSE()\r
957     MESSAGE(WARNING "Unable to find Qt 5")\r
958   ENDIF()\r
959 ENDMACRO()\r