1 MACRO(CONVERT_NUMBER_VERSION _VERSION_NUMBER _BASE _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
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
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
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
31 IF(NOT ${_VAR} AND NOT STREQUAL "0")
\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
50 SET(NEW_OPTION ${NEWNAME}_FIND_${_OPTION})
\r
51 SET(${NEW_OPTION} ${OLD_OPTION})
\r
56 MACRO(FIND_PACKAGE_HELPER NAME INCLUDE)
\r
57 # Looks for a directory containing NAME.
\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
62 # INCLUDE is the file to check for includes
\r
64 # Following parameters are optional variables and must be prefixed by:
\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
74 # The first match will be used in the specified order and next matches will be ignored
\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
86 SET(_BASE_DIRECTORIES)
\r
88 SET(_IS_RELEASE OFF)
\r
90 SET(_IS_SUFFIXES OFF)
\r
91 SET(_IS_VERBOSE OFF)
\r
95 FOREACH(_PARAM ${_PARAMS})
\r
96 IF(_PARAM STREQUAL "RELEASE")
\r
99 SET(_IS_SUFFIXES OFF)
\r
101 ELSEIF(_PARAM STREQUAL "DEBUG")
\r
102 SET(_IS_RELEASE OFF)
\r
104 SET(_IS_SUFFIXES OFF)
\r
106 ELSEIF(_PARAM STREQUAL "SUFFIXES")
\r
107 SET(_IS_RELEASE OFF)
\r
110 SET(_IS_SUFFIXES ON)
\r
111 ELSEIF(_PARAM STREQUAL "QUIET")
\r
112 SET(_IS_RELEASE OFF)
\r
114 SET(_IS_SUFFIXES OFF)
\r
116 SET(${NAME}_FIND_QUIETLY ON)
\r
117 ELSEIF(_PARAM STREQUAL "VERBOSE")
\r
118 SET(_IS_RELEASE OFF)
\r
120 SET(_IS_SUFFIXES OFF)
\r
122 SET(_IS_VERBOSE ON)
\r
123 ELSEIF(_PARAM STREQUAL "REQUIRED")
\r
124 SET(_IS_RELEASE OFF)
\r
126 SET(_IS_SUFFIXES OFF)
\r
128 SET(${NAME}_FIND_REQUIRED ON)
\r
129 ELSEIF(_PARAM STREQUAL "DIR")
\r
130 SET(_IS_RELEASE OFF)
\r
132 SET(_IS_SUFFIXES OFF)
\r
136 LIST(APPEND _RELEASE_LIBRARIES ${_PARAM})
\r
138 LIST(APPEND _DEBUG_LIBRARIES ${_PARAM})
\r
139 ELSEIF(_IS_SUFFIXES)
\r
140 LIST(APPEND _SUFFIXES ${_PARAM})
\r
142 LIST(APPEND _BASE_DIRECTORIES ${_PARAM})
\r
144 MESSAGE(STATUS "parameter ${_PARAM} with no prefix")
\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
154 # if invalid characters are detected, replace them by valid ones
\r
155 STRING(REPLACE "+" "p" _NAME_FIXED ${NAME})
\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
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
188 MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
\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
198 MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
\r
202 IF(_BASE_DIRECTORIES)
\r
203 FOREACH(_DIR ${_BASE_DIRECTORIES})
\r
205 LIST(APPEND _INCLUDE_PATHS ${_DIR}/include ${_DIR})
\r
206 LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})
\r
209 MESSAGE(STATUS "Using ${_DIR} as root directory")
\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
226 LIST(APPEND _UNIX_INCLUDE_PATHS
\r
236 MESSAGE(STATUS "Searching header ${INCLUDE} in: ${_INCLUDE_PATHS} with suffixes ${_SUFFIXES}")
\r
239 # Search for include directory
\r
240 FIND_PATH(${_UPNAME_FIXED}_INCLUDE_DIR
\r
243 ${PKG_${_NAME_FIXED}_INCLUDE_DIRS}
\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
250 ${_UNIX_INCLUDE_PATHS}
\r
253 DOC "Include path for ${NAME}"
\r
257 IF(${_UPNAME_FIXED}_INCLUDE_DIR)
\r
258 MESSAGE(STATUS "${INCLUDE} found in ${${_UPNAME_FIXED}_INCLUDE_DIR}")
\r
260 MESSAGE(STATUS "${INCLUDE} not found")
\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
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
280 # Append UNIX standard libraries paths
\r
281 LIST(APPEND _UNIX_LIBRARY_PATHS
\r
285 /usr/local/X11R6/lib
\r
291 /usr/freeware/lib${LIB_SUFFIX})
\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
299 SET(_LIBS ${_RELEASE_LIBRARIES})
\r
300 FOREACH(_LIB ${_LIBS})
\r
301 LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})
\r
304 SET(_LIBS ${_DEBUG_LIBRARIES})
\r
305 FOREACH(_LIB ${_LIBS})
\r
306 LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})
\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
316 ${_RELEASE_LIBRARIES}
\r
317 HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
\r
320 ${_UNIX_LIBRARY_PATHS}
\r
321 NO_CMAKE_SYSTEM_PATH
\r
325 IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)
\r
326 MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")
\r
328 MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")
\r
332 # Search for debug library
\r
333 FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG
\r
335 ${_DEBUG_LIBRARIES}
\r
336 HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
\r
339 ${_UNIX_LIBRARY_PATHS}
\r
340 NO_CMAKE_SYSTEM_PATH
\r
344 IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)
\r
345 MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")
\r
347 MESSAGE(STATUS "${NAME} debug library not found")
\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
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
376 IF(${_UPNAME_FIXED}_FOUND)
\r
377 IF(NOT ${NAME}_FIND_QUIETLY)
\r
378 MESSAGE(STATUS "Found ${NAME}: ${${_UPNAME_FIXED}_LIBRARIES}")
\r
381 IF(${NAME}_FIND_REQUIRED)
\r
382 MESSAGE(FATAL_ERROR "Error: Unable to find ${NAME}!")
\r
384 IF(NOT ${NAME}_FIND_QUIETLY)
\r
385 MESSAGE(STATUS "Warning: Unable to find ${NAME}!")
\r
389 MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)
\r
392 MACRO(MESSAGE_VERSION_PACKAGE_HELPER NAME VERSION)
\r
393 MESSAGE(STATUS "Found ${NAME} ${VERSION}: ${ARGN}")
\r
396 MACRO(FIND_LIBRARY_HELPER NAME)
\r
397 # Looks for libraries.
\r
399 # NAME is the name of the library, lowercase and uppercase can be mixed
\r
401 # Following parameters are optional variables and must be prefixed by:
\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
409 # The first match will be used in the specified order and next matches will be ignored
\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
422 SET(_IS_VERBOSE OFF)
\r
426 FOREACH(_PARAM ${_PARAMS})
\r
427 IF(_PARAM STREQUAL "RELEASE")
\r
428 SET(_IS_RELEASE ON)
\r
431 ELSEIF(_PARAM STREQUAL "DEBUG")
\r
432 SET(_IS_RELEASE OFF)
\r
435 ELSEIF(_PARAM STREQUAL "VERBOSE")
\r
436 SET(_IS_RELEASE OFF)
\r
439 SET(_IS_VERBOSE ON)
\r
440 ELSEIF(_PARAM STREQUAL "REQUIRED")
\r
441 SET(_IS_RELEASE OFF)
\r
444 SET(${NAME}_FIND_REQUIRED ON)
\r
445 ELSEIF(_PARAM STREQUAL "DIR")
\r
446 SET(_IS_RELEASE OFF)
\r
451 LIST(APPEND _RELEASE_LIBRARIES ${_PARAM})
\r
453 LIST(APPEND _DEBUG_LIBRARIES ${_PARAM})
\r
455 LIST(APPEND _BASE_DIRECTORIES ${_PARAM})
\r
457 MESSAGE(STATUS "parameter ${_PARAM} with no prefix")
\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
467 # if invalid characters are detected, replace them by valid ones
\r
468 STRING(REPLACE "+" "p" _NAME_FIXED ${NAME})
\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
487 MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
\r
491 IF(DEFINED ${_UPNAME}_DIR)
\r
492 SET(_TMP ${${_UPNAME}_DIR})
\r
493 LIST(APPEND _LIBRARY_PATHS ${_TMP}/lib${LIB_SUFFIX})
\r
496 MESSAGE(STATUS "Using ${_UPNAME_FIXED}_DIR as root directory ${_TMP}")
\r
500 IF(_BASE_DIRECTORIES)
\r
501 FOREACH(_DIR ${_BASE_DIRECTORIES})
\r
503 LIST(APPEND _LIBRARY_PATHS ${_DIR}/lib${LIB_SUFFIX})
\r
506 MESSAGE(STATUS "Using ${_DIR} as root directory")
\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
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
528 # Append UNIX standard libraries paths
\r
529 LIST(APPEND _UNIX_LIBRARY_PATHS
\r
533 /usr/local/X11R6/lib
\r
539 /usr/freeware/lib${LIB_SUFFIX})
\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
547 SET(_LIBS ${_RELEASE_LIBRARIES})
\r
548 FOREACH(_LIB ${_LIBS})
\r
549 LIST(APPEND _RELEASE_LIBRARIES lib${_LIB})
\r
552 SET(_LIBS ${_DEBUG_LIBRARIES})
\r
553 FOREACH(_LIB ${_LIBS})
\r
554 LIST(APPEND _DEBUG_LIBRARIES lib${_LIB})
\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
564 ${_RELEASE_LIBRARIES}
\r
565 HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
\r
568 ${_UNIX_LIBRARY_PATHS}
\r
569 NO_CMAKE_SYSTEM_PATH
\r
573 IF(${_UPNAME_FIXED}_LIBRARY_RELEASE)
\r
574 MESSAGE(STATUS "${NAME} release library found: ${${_UPNAME_FIXED}_LIBRARY_RELEASE}")
\r
576 MESSAGE(STATUS "${NAME} release library not found in ${_LIBRARY_PATHS};${_UNIX_LIBRARY_PATHS}")
\r
580 # Search for debug library
\r
581 FIND_LIBRARY(${_UPNAME_FIXED}_LIBRARY_DEBUG
\r
583 ${_DEBUG_LIBRARIES}
\r
584 HINTS ${PKG_${_NAME_FIXED}_LIBRARY_DIRS}
\r
587 ${_UNIX_LIBRARY_PATHS}
\r
588 NO_CMAKE_SYSTEM_PATH
\r
592 IF(${_UPNAME_FIXED}_LIBRARY_DEBUG)
\r
593 MESSAGE(STATUS "${NAME} debug library found: ${${_UPNAME_FIXED}_LIBRARY_DEBUG}")
\r
595 MESSAGE(STATUS "${NAME} debug library not found")
\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
614 MARK_AS_ADVANCED(${_UPNAME_FIXED}_LIBRARY_RELEASE ${_UPNAME_FIXED}_LIBRARY_DEBUG)
\r
617 MACRO(FIND_LIBCURL)
\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
624 SET(CURL_STATIC OFF)
\r
628 SET(CURL_DEFINITIONS -DCURL_STATICLIB)
\r
631 # CURL can depend on libidn
\r
632 FIND_LIBRARY(IDN_LIBRARY idn)
\r
634 LIST(APPEND CURL_LIBRARIES ${IDN_LIBRARY})
\r
637 # CURL Macports version can depend on libidn, libintl and libiconv too
\r
639 FIND_LIBRARY(INTL_LIBRARY intl)
\r
641 LIST(APPEND CURL_LIBRARIES ${INTL_LIBRARY})
\r
644 # Only used by libcurl under Linux
\r
645 FIND_PACKAGE(OpenSSL REQUIRED)
\r
648 # SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib)
\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
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
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
675 # libxml2 could need winsock2 library
\r
677 FIND_LIBRARY(WINSOCK2_LIB ws2_32)
\r
680 LIST(APPEND LIBXML2_LIBRARIES ${WINSOCK2_LIB})
\r
683 FIND_LIBRARY(CRYPT32_LIB Crypt32)
\r
686 LIST(APPEND LIBXML2_LIBRARIES ${CRYPT32_LIB})
\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
700 MACRO(ADD_QT_LIBRARY _NAME)
\r
705 SET(_PREFIX "libQt5")
\r
708 SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}.${_EXT}")
\r
710 LIST(APPEND QT_LIBRARIES optimized ${_LIB})
\r
712 SET(_LIB "${QT_LIBRARY_DIR}/${_PREFIX}${_NAME}d.${_EXT}")
\r
714 LIST(APPEND QT_LIBRARIES debug ${_LIB})
\r
718 MACRO(ADD_QT_PLUGIN _TYPE _NAME)
\r
726 SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}.${_EXT}")
\r
728 LIST(APPEND QT_LIBRARIES optimized ${_LIB})
\r
730 SET(_LIB "${QT_PLUGINS_DIR}/${_TYPE}/${_PREFIX}${_NAME}d.${_EXT}")
\r
732 LIST(APPEND QT_LIBRARIES debug ${_LIB})
\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
754 MESSAGE(STATUS "Didn't find ${_NAME}")
\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
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
774 SET(_VERSION "${_VERSION} static version")
\r
777 SET(_VERSION "${_VERSION} shared version")
\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
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
807 LIST(APPEND QT_LIBRARIES Qt5::Gui Qt5::OpenGL)
\r
809 ADD_QT_LIBRARY(PrintSupport)
\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
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
833 ${SYSTEMCONFIGURATION_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
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
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
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
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
886 SET(HB_LIB "${QT_LIBRARY_DIR}/qtharfbuzzng.lib")
\r
888 IF(EXISTS ${HB_LIB})
\r
889 LIST(APPEND QT_LIBRARIES ${HB_LIB})
\r
892 # freetype is needed since Qt 5.5
\r
893 FIND_PACKAGE(Freetype)
\r
896 LIST(APPEND QT_LIBRARIES ${FREETYPE_LIBRARIES})
\r
899 SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/libqtfreetype.a")
\r
901 SET(FREETYPE_LIB "${QT_LIBRARY_DIR}/qtfreetype.lib")
\r
903 IF(EXISTS ${FREETYPE_LIB})
\r
904 LIST(APPEND QT_LIBRARIES ${FREETYPE_LIB})
\r
908 ADD_QT_PLUGIN(accessible qtaccessiblewidgets)
\r
910 LIST(APPEND QT_LIBRARIES ${PNG_LIBRARIES} ${JPEG_LIBRARY})
\r
913 LIST(APPEND QT_LIBRARIES Qt5::Network Qt5::Xml)
\r
914 LIST(APPEND QT_LIBRARIES ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})
\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
924 LIST(APPEND QT_LIBRARIES Qt5::Core)
\r
926 # pcre is needed since Qt 5.5
\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
933 SET(PCRE_LIB "${QT_LIBRARY_DIR}/qtpcre.lib")
\r
935 IF(EXISTS ${PCRE_LIB})
\r
936 LIST(APPEND QT_LIBRARIES ${PCRE_LIB})
\r
940 FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre)
\r
942 FIND_LIBRARY(SECURITY_FRAMEWORK Security)
\r
944 LIST(APPEND QT_LIBRARIES
\r
946 ${FOUNDATION_FRAMEWORK}
\r
947 ${CARBON_FRAMEWORK}
\r
948 ${SECURITY_FRAMEWORK})
\r
950 FIND_PACKAGE(Threads)
\r
951 LIST(APPEND QT_LIBRARIES ${ZLIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} -lrt)
\r
954 SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)
\r
957 MESSAGE(WARNING "Unable to find Qt 5")
\r