Code

Cmake: more fixes plus a patch for OSX paths by Henrik Gustafsson
[inkscape.git] / CMakeScripts / FindGLIBMM.cmake
1 # - Try to find glibmm
2 # Once done this will define
3 #
4 #  GLIBMM_FOUND - system has glibmm
5 #  GLIBMM_INCLUDE_DIRS - the glibmm include directory
6 #  GLIBMM_LIBRARIES - Link these to use glibmm
7 #  GLIBMM_DEFINITIONS - Compiler switches required for using glibmm
8 #
9 #  Copyright (c) 2008 Joshua L. Blocher <verbalshadow@gmail.com>
10 #
11 #  Redistribution and use is allowed according to the terms of the New
12 #  BSD license.
13 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 #
17 if (GLIBMM_LIBRARIES AND GLIBMM_INCLUDE_DIRS)
18   # in cache already
19   set(GLIBMM_FOUND TRUE)
20 else (GLIBMM_LIBRARIES AND GLIBMM_INCLUDE_DIRS)
21   # use pkg-config to get the directories and then use these values
22   # in the FIND_PATH() and FIND_LIBRARY() calls
23   if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
24     include(UsePkgConfig)
25     pkgconfig(glibmm-2.4 _GLIBMM_INCLUDEDIR _GLIBMM_LIBDIR _GLIBMM_LDFLAGS _GLIBMM_CFLAGS)
26   else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
27     find_package(PkgConfig)
28     if (PKG_CONFIG_FOUND)
29       pkg_check_modules(_GLIBMM glibmm-2.4)
30     endif (PKG_CONFIG_FOUND)
31   endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
32   find_path(GLIBMM_INCLUDE_DIR
33     NAMES
34       glibmm.h
35     PATHS
36       ${_GLIBMM_INCLUDEDIR}
37       /usr/include
38       /usr/local/include
39       /opt/local/include
40       /opt/local/lib/glibmm-2.4/include
41       /sw/include
42     PATH_SUFFIXES
43       glibmm-2.4
44   )
46   find_path(GLIBMM_CONFIG_INCLUDE_DIR
47     NAMES
48       glibmmconfig.h
49     PATHS
50       ${_GLIBMM_INCLUDEDIR}
51       /usr/include
52       /usr/local/include
53       /opt/local/include
54       /opt/local/lib/glibmm-2.4/include
55       /sw/include
56       /usr/lib/glibmm-2.4/include
57       /usr/lib64/glibmm-2.4/include
58   )
59   find_library(GLIBMM-2.4_LIBRARY
60     NAMES
61       glibmm-2.4
62     PATHS
63       ${_GLIBMM_LIBDIR}
64       /usr/lib
65       /usr/local/lib
66       /opt/local/lib
67       /sw/lib
68   )
70   if (GLIBMM-2.4_LIBRARY)
71     set(GLIBMM-2.4_FOUND TRUE)
72   endif (GLIBMM-2.4_LIBRARY)
74   set(GLIBMM_INCLUDE_DIRS
75     ${GLIBMM_INCLUDE_DIR}
76     ${GLIBMM_CONFIG_INCLUDE_DIR}
77   )
79   if (GLIBMM-2.4_FOUND)
80     set(GLIBMM_LIBRARIES
81       ${GLIBMM_LIBRARIES}
82       ${GLIBMM-2.4_LIBRARY}
83     )
84   endif (GLIBMM-2.4_FOUND)
86   if (GLIBMM_INCLUDE_DIRS AND GLIBMM_LIBRARIES)
87      set(GLIBMM_FOUND TRUE)
88   endif (GLIBMM_INCLUDE_DIRS AND GLIBMM_LIBRARIES)
90   if (GLIBMM_FOUND)
91     if (NOT glibmm_FIND_QUIETLY)
92       message(STATUS "Found glibmm: ${GLIBMM_LIBRARIES}")
93     endif (NOT glibmm_FIND_QUIETLY)
94   else (GLIBMM_FOUND)
95     if (glibmm_FIND_REQUIRED)
96       message(FATAL_ERROR "Could not find glibmm")
97     endif (glibmm_FIND_REQUIRED)
98   endif (GLIBMM_FOUND)
100   # show the GLIBMM_INCLUDE_DIRS and GLIBMM_LIBRARIES variables only in the advanced view
101   mark_as_advanced(GLIBMM_INCLUDE_DIRS GLIBMM_LIBRARIES)
103 endif (GLIBMM_LIBRARIES AND GLIBMM_INCLUDE_DIRS)