Changeset View
Changeset View
Standalone View
Standalone View
cmake/FindGLIB2.cmake
- This file was added.
1 | # - Try to find the GLIB2 libraries | ||||
---|---|---|---|---|---|
2 | # Once done this will define | ||||
3 | # | ||||
4 | # GLIB2_FOUND - system has glib2 | ||||
5 | # GLIB2_INCLUDE_DIR - the glib2 include directory | ||||
6 | # GLIB2_LIBRARIES - glib2 library | ||||
7 | | ||||
8 | # Copyright (c) 2008 Laurent Montel, <montel@kde.org> | ||||
9 | # | ||||
10 | # Redistribution and use is allowed according to the terms of the BSD license. | ||||
11 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||||
12 | | ||||
13 | | ||||
14 | if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) | ||||
15 | # Already in cache, be silent | ||||
16 | set(GLIB2_FIND_QUIETLY TRUE) | ||||
17 | endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) | ||||
18 | | ||||
19 | find_package(PkgConfig) | ||||
20 | pkg_check_modules(PC_LibGLIB2 glib-2.0) | ||||
21 | | ||||
22 | find_path(GLIB2_MAIN_INCLUDE_DIR | ||||
23 | NAMES glib.h | ||||
24 | HINTS ${PC_LibGLIB2_INCLUDEDIR} | ||||
25 | PATH_SUFFIXES glib-2.0) | ||||
26 | | ||||
27 | find_library(GLIB2_LIBRARY | ||||
28 | NAMES glib-2.0 | ||||
29 | HINTS ${PC_LibGLIB2_LIBDIR} | ||||
30 | ) | ||||
31 | | ||||
32 | set(GLIB2_LIBRARIES ${GLIB2_LIBRARY}) | ||||
33 | | ||||
34 | # search the glibconfig.h include dir under the same root where the library is found | ||||
35 | get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH) | ||||
36 | | ||||
37 | find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h | ||||
38 | PATH_SUFFIXES glib-2.0/include | ||||
39 | HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) | ||||
40 | | ||||
41 | set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}") | ||||
42 | | ||||
43 | # not sure if this include dir is optional or required | ||||
44 | # for now it is optional | ||||
45 | if(GLIB2_INTERNAL_INCLUDE_DIR) | ||||
46 | set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}") | ||||
47 | endif(GLIB2_INTERNAL_INCLUDE_DIR) | ||||
48 | | ||||
49 | include(FindPackageHandleStandardArgs) | ||||
50 | find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) | ||||
51 | | ||||
52 | mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) |