Warning, /graphics/krita/cmake/modules/LibFindMacros.cmake is written in an unsupported language. File is not indexed.

0001 # Version 1.0 (2013-04-12)
0002 # Written by Lasse Kärkkäinen <tronic@zi.fi>
0003 #
0004 # SPDX-License-Identifier: CC-PDDC
0005 #
0006 # Published at http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
0007 
0008 # If you improve the script, please modify the forementioned wiki page because
0009 # I no longer maintain my scripts (hosted as static files at zi.fi). Feel free
0010 # to remove this entire header if you use real version control instead.
0011 
0012 # Changelog:
0013 # 2013-04-12  Added version number (1.0) and this header, no other changes
0014 # 2009-10-08  Originally published
0015 
0016 
0017 # Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
0018 # used for the current package. For this to work, the first parameter must be the
0019 # prefix of the current package, then the prefix of the new package etc, which are
0020 # passed to find_package.
0021 macro (libfind_package PREFIX)
0022   set (LIBFIND_PACKAGE_ARGS ${ARGN})
0023   if (${PREFIX}_FIND_QUIETLY)
0024     set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
0025   endif ()
0026   if (${PREFIX}_FIND_REQUIRED)
0027     set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
0028   endif ()
0029   find_package(${LIBFIND_PACKAGE_ARGS})
0030 endmacro (libfind_package)
0031 
0032 # CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
0033 # where they added pkg_check_modules. Consequently I need to support both in my scripts
0034 # to avoid those deprecated warnings. Here's a helper that does just that.
0035 # Works identically to pkg_check_modules, except that no checks are needed prior to use.
0036 macro (libfind_pkg_check_modules PREFIX PKGNAME)
0037   if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
0038     include(UsePkgConfig)
0039     pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
0040   else ()
0041     find_package(PkgConfig)
0042     if (PKG_CONFIG_FOUND)
0043       pkg_check_modules(${PREFIX} ${PKGNAME})
0044     endif ()
0045   endif ()
0046 endmacro (libfind_pkg_check_modules)
0047 
0048 # Do the final processing once the paths have been detected.
0049 # If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
0050 # all the variables, each of which contain one include directory.
0051 # Ditto for ${PREFIX}_PROCESS_LIBS and library files.
0052 # Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
0053 # Also handles errors in case library detection was required, etc.
0054 macro (libfind_process PREFIX)
0055   # Skip processing if already processed during this run
0056   if (NOT ${PREFIX}_FOUND)
0057     # Start with the assumption that the library was found
0058     set (${PREFIX}_FOUND TRUE)
0059 
0060     # Process all includes and set _FOUND to false if any are missing
0061     foreach (i ${${PREFIX}_PROCESS_INCLUDES})
0062       if (${i})
0063         set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
0064         mark_as_advanced(${i})
0065       else ()
0066         set (${PREFIX}_FOUND FALSE)
0067       endif ()
0068     endforeach (i)
0069 
0070     # Process all libraries and set _FOUND to false if any are missing
0071     foreach (i ${${PREFIX}_PROCESS_LIBS})
0072       if (${i})
0073         set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
0074         mark_as_advanced(${i})
0075       else ()
0076         set (${PREFIX}_FOUND FALSE)
0077       endif ()
0078     endforeach (i)
0079 
0080     # Print message and/or exit on fatal error
0081     if (${PREFIX}_FOUND)
0082       if (NOT ${PREFIX}_FIND_QUIETLY)
0083         message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
0084       endif ()
0085     else ()
0086       if (${PREFIX}_FIND_REQUIRED)
0087         foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
0088           message("${i}=${${i}}")
0089         endforeach (i)
0090         message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
0091       endif ()
0092     endif ()
0093   endif ()
0094 endmacro (libfind_process)
0095 
0096 macro(libfind_library PREFIX basename)
0097   set(TMP "")
0098   if(MSVC80)
0099     set(TMP -vc80)
0100   endif()
0101   if(MSVC90)
0102     set(TMP -vc90)
0103   endif()
0104   set(${PREFIX}_LIBNAMES ${basename}${TMP})
0105   if(${ARGC} GREATER 2)
0106     set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
0107     string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
0108     set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
0109   endif()
0110   find_library(${PREFIX}_LIBRARY
0111     NAMES ${${PREFIX}_LIBNAMES}
0112     PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
0113   )
0114 endmacro(libfind_library)
0115