summaryrefslogtreecommitdiff
path: root/cmake/FindGlib.cmake
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-07-19 08:41:04 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-07-19 08:41:04 -0400
commit299b166ff820e8413f0c34ed5a2e7afac46cd477 (patch)
treeb0b8e1520af740e8a63fd132ebae82326054e12f /cmake/FindGlib.cmake
initial commit
Diffstat (limited to 'cmake/FindGlib.cmake')
-rw-r--r--cmake/FindGlib.cmake43
1 files changed, 43 insertions, 0 deletions
diff --git a/cmake/FindGlib.cmake b/cmake/FindGlib.cmake
new file mode 100644
index 0000000..cddc9f0
--- /dev/null
+++ b/cmake/FindGlib.cmake
@@ -0,0 +1,43 @@
+find_package(PkgConfig)
+pkg_check_modules(GLIB_PKG glib-2.0)
+
+if (GLIB_PKG_FOUND)
+ find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0
+ PATHS
+ ${GLIB_PKG_INCLUDE_DIRS}
+ /usr/include/glib-2.0
+ /usr/include
+ /usr/local/include
+ )
+ find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_PKG_LIBDIR} PATH_SUFFIXES glib-2.0/include)
+
+ find_library(GLIB_LIBRARIES NAMES glib-2.0
+ PATHS
+ ${GLIB_PKG_LIBRARY_DIRS}
+ /usr/lib
+ /usr/local/lib
+ )
+
+else (GLIB_PKG_FOUND)
+ # Find Glib even if pkg-config is not working (eg. cross compiling to Windows)
+ find_library(GLIB_LIBRARIES NAMES glib-2.0)
+ string (REGEX REPLACE "/[^/]*$" "" GLIB_LIBRARIES_DIR ${GLIB_LIBRARIES})
+
+ find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0)
+ find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_LIBRARIES_DIR} PATH_SUFFIXES glib-2.0/include)
+
+endif (GLIB_PKG_FOUND)
+
+if (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)
+ set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR})
+endif (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)
+
+if(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
+ set(GLIB_FOUND TRUE CACHE INTERNAL "glib-2.0 found")
+ message(STATUS "Found glib-2.0: ${GLIB_INCLUDE_DIR}, ${GLIB_LIBRARIES}")
+else(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
+ set(GLIB_FOUND FALSE CACHE INTERNAL "glib-2.0 found")
+ message(STATUS "glib-2.0 not found.")
+endif(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
+
+mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR GLIB_INCLUDE_DIRS GLIB_LIBRARIES)