summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindGLIB2.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/FindGLIB2.cmake')
-rw-r--r--cmake/modules/FindGLIB2.cmake51
1 files changed, 51 insertions, 0 deletions
diff --git a/cmake/modules/FindGLIB2.cmake b/cmake/modules/FindGLIB2.cmake
new file mode 100644
index 0000000..226d551
--- /dev/null
+++ b/cmake/modules/FindGLIB2.cmake
@@ -0,0 +1,51 @@
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
14if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
15 # Already in cache, be silent
16 set(GLIB2_FIND_QUIETLY TRUE)
17endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
18
19if (NOT WIN32)
20 FIND_PACKAGE(PkgConfig)
21 PKG_CHECK_MODULES(PC_GLIB2 glib-2.0)
22 SET(GLIB2_DEFINITIONS ${PC_GLIB2_CFLAGS_OTHER})
23endif(NOT WIN32)
24
25find_path(GLIB2_MAIN_INCLUDE_DIR glib.h
26 PATH_SUFFIXES glib-2.0
27 PATHS ${_LibGLIB2IncDir} )
28
29# search the glibconfig.h include dir under the same root where the library is found
30find_library(GLIB2_LIBRARIES
31 NAMES glib-2.0
32 PATHS ${_LibGLIB2LinkDir} )
33
34get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH)
35
36find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
37 PATH_SUFFIXES glib-2.0/include
38 PATHS ${_LibGLIB2IncDir} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH})
39
40set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}")
41
42# not sure if this include dir is optional or required
43# for now it is optional
44if(GLIB2_INTERNAL_INCLUDE_DIR)
45 set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}")
46endif(GLIB2_INTERNAL_INCLUDE_DIR)
47
48include(FindPackageHandleStandardArgs)
49find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR)
50
51mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) \ No newline at end of file