Warning, /sdk/ktechlab/cmake/modules/FindGLIB.cmake is written in an unsupported language. File is not indexed.
0001 # - Try to find Glib and its components (gio, gobject etc) 0002 # Once done, this will define 0003 # 0004 # GLIB_FOUND - system has Glib 0005 # GLIB_INCLUDE_DIRS - the Glib include directories 0006 # GLIB_LIBRARIES - link these to use Glib 0007 # 0008 # Optionally, the COMPONENTS keyword can be passed to find_package() 0009 # and Glib components can be looked for. Currently, the following 0010 # components can be used, and they define the following variables if 0011 # found: 0012 # 0013 # gio: GLIB_GIO_LIBRARIES 0014 # gobject: GLIB_GOBJECT_LIBRARIES 0015 # gmodule: GLIB_GMODULE_LIBRARIES 0016 # gthread: GLIB_GTHREAD_LIBRARIES 0017 # 0018 # Note that the respective _INCLUDE_DIR variables are not set, since 0019 # all headers are in the same directory as GLIB_INCLUDE_DIRS. 0020 # 0021 # Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org> 0022 # 0023 # Redistribution and use in source and binary forms, with or without 0024 # modification, are permitted provided that the following conditions 0025 # are met: 0026 # 1. Redistributions of source code must retain the above copyright 0027 # notice, this list of conditions and the following disclaimer. 0028 # 2. Redistributions in binary form must reproduce the above copyright 0029 # notice, this list of conditions and the following disclaimer in the 0030 # documentation and/or other materials provided with the distribution. 0031 # 0032 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS 0033 # IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 0034 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0035 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS 0036 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0037 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0038 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 0039 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 0040 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 0041 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 0042 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0043 0044 find_package(PkgConfig) 0045 pkg_check_modules(PC_GLIB QUIET glib-2.0) 0046 0047 find_library(GLIB_LIBRARIES 0048 NAMES glib-2.0 0049 HINTS ${PC_GLIB_LIBDIR} 0050 ${PC_GLIB_LIBRARY_DIRS} 0051 ) 0052 0053 # Files in glib's main include path may include glibconfig.h, which, 0054 # for some odd reason, is normally in $LIBDIR/glib-2.0/include. 0055 get_filename_component(_GLIB_LIBRARY_DIR ${GLIB_LIBRARIES} PATH) 0056 find_path(GLIBCONFIG_INCLUDE_DIR 0057 NAMES glibconfig.h 0058 HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${_GLIB_LIBRARY_DIR} 0059 ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} 0060 PATH_SUFFIXES glib-2.0/include 0061 ) 0062 0063 find_path(GLIB_INCLUDE_DIR 0064 NAMES glib.h 0065 HINTS ${PC_GLIB_INCLUDEDIR} 0066 ${PC_GLIB_INCLUDE_DIRS} 0067 PATH_SUFFIXES glib-2.0 0068 ) 0069 0070 set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIBCONFIG_INCLUDE_DIR}) 0071 0072 # Version detection 0073 if (EXISTS "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h") 0074 file(READ "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h" GLIBCONFIG_H_CONTENTS) 0075 string(REGEX MATCH "#define GLIB_MAJOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") 0076 set(GLIB_VERSION_MAJOR "${CMAKE_MATCH_1}") 0077 string(REGEX MATCH "#define GLIB_MINOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") 0078 set(GLIB_VERSION_MINOR "${CMAKE_MATCH_1}") 0079 string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") 0080 set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}") 0081 set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}") 0082 endif () 0083 0084 # Additional Glib components. We only look for libraries, as not all of them 0085 # have corresponding headers and all headers are installed alongside the main 0086 # glib ones. 0087 foreach (_component ${GLIB_FIND_COMPONENTS}) 0088 if (${_component} STREQUAL "gio") 0089 find_library(GLIB_GIO_LIBRARIES NAMES gio-2.0 HINTS ${_GLIB_LIBRARY_DIR}) 0090 set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GIO_LIBRARIES) 0091 elseif (${_component} STREQUAL "gobject") 0092 find_library(GLIB_GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${_GLIB_LIBRARY_DIR}) 0093 set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GOBJECT_LIBRARIES) 0094 elseif (${_component} STREQUAL "gmodule") 0095 find_library(GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 HINTS ${_GLIB_LIBRARY_DIR}) 0096 set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GMODULE_LIBRARIES) 0097 elseif (${_component} STREQUAL "gthread") 0098 find_library(GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 HINTS ${_GLIB_LIBRARY_DIR}) 0099 set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GTHREAD_LIBRARIES) 0100 elseif (${_component} STREQUAL "gio-unix") 0101 # gio-unix is compiled as part of the gio library, but the include paths 0102 # are separate from the shared glib ones. Since this is currently only used 0103 # by WebKitGTK we don't go to extraordinary measures beyond pkg-config. 0104 pkg_check_modules(GIO_UNIX QUIET gio-unix-2.0) 0105 endif () 0106 endforeach () 0107 0108 include(FindPackageHandleStandardArgs) 0109 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS} 0110 VERSION_VAR GLIB_VERSION) 0111 0112 mark_as_advanced( 0113 GLIBCONFIG_INCLUDE_DIR 0114 GLIB_GIO_LIBRARIES 0115 GLIB_GIO_UNIX_LIBRARIES 0116 GLIB_GMODULE_LIBRARIES 0117 GLIB_GOBJECT_LIBRARIES 0118 GLIB_GTHREAD_LIBRARIES 0119 GLIB_INCLUDE_DIR 0120 GLIB_INCLUDE_DIRS 0121 GLIB_LIBRARIES 0122 )