Created
May 14, 2009 20:55
-
-
Save michaelmelanson/111912 to your computer and use it in GitHub Desktop.
CMake packages for libevent, Net-SNMP, and others.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find Libevent | |
# http://monkey.org/~provos/libevent/ | |
# | |
# Once done, this will define: | |
# | |
# Event_FOUND - system has Event | |
# Event_INCLUDE_DIRS - the Event include directories | |
# Event_LIBRARIES - link these to use Event | |
# | |
if (EVENT_INCLUDE_DIR AND EVENT_LIBRARY) | |
# Already in cache, be silent | |
set(EVENT_FIND_QUIETLY TRUE) | |
endif (EVENT_INCLUDE_DIR AND EVENT_LIBRARY) | |
find_path(EVENT_INCLUDE_DIR event.h | |
PATHS /usr/include | |
PATH_SUFFIXES event | |
) | |
find_library(EVENT_LIBRARY | |
NAMES event | |
PATHS /usr/lib /usr/local/lib | |
) | |
set(EVENT_LIBRARIES ${EVENT_LIBRARY} ) | |
add_definitions(-DLIBNET_LIL_ENDIAN) | |
include(FindPackageHandleStandardArgs) | |
find_package_handle_standard_args(EVENT | |
DEFAULT_MSG | |
EVENT_INCLUDE_DIR | |
EVENT_LIBRARIES | |
) | |
mark_as_advanced(EVENT_INCLUDE_DIR EVENT_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Try to find GLib2 | |
# Once done this will define | |
# | |
# GLIB2_FOUND - system has GLib2 | |
# GLIB2_INCLUDE_DIRS - the GLib2 include directory | |
# GLIB2_LIBRARIES - Link these to use GLib2 | |
# | |
# HAVE_GLIB_GREGEX_H glib has gregex.h header and | |
# supports g_regex_match_simple | |
# | |
# Copyright (c) 2006 Andreas Schneider <[email protected]> | |
# Copyright (c) 2006 Philippe Bernery <[email protected]> | |
# Copyright (c) 2007 Daniel Gollub <[email protected]> | |
# Copyright (c) 2007 Alban Browaeys <[email protected]> | |
# Copyright (c) 2008 Michael Bell <[email protected]> | |
# Copyright (c) 2008 Bjoern Ricks <[email protected]> | |
# | |
# Redistribution and use is allowed according to the terms of the New | |
# BSD license. | |
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | |
# | |
IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) | |
# in cache already | |
SET(GLIB2_FOUND TRUE) | |
ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) | |
INCLUDE(FindPkgConfig) | |
## Glib | |
IF ( GLIB2_FIND_REQUIRED ) | |
SET( _pkgconfig_REQUIRED "REQUIRED" ) | |
ELSE ( GLIB2_FIND_REQUIRED ) | |
SET( _pkgconfig_REQUIRED "" ) | |
ENDIF ( GLIB2_FIND_REQUIRED ) | |
IF ( GLIB2_MIN_VERSION ) | |
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) | |
ELSE ( GLIB2_MIN_VERSION ) | |
PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) | |
ENDIF ( GLIB2_MIN_VERSION ) | |
IF ( PKG_CONFIG_FOUND ) | |
IF ( GLIB2_FOUND ) | |
SET ( GLIB2_CORE_FOUND TRUE ) | |
ELSE ( GLIB2_FOUND ) | |
SET ( GLIB2_CORE_FOUND FALSE ) | |
ENDIF ( GLIB2_FOUND ) | |
ENDIF ( PKG_CONFIG_FOUND ) | |
# Look for glib2 include dir and libraries w/o pkgconfig | |
IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) | |
FIND_PATH( | |
_glibconfig_include_DIR | |
NAMES | |
glibconfig.h | |
PATHS | |
/opt/gnome/lib64 | |
/opt/gnome/lib | |
/opt/lib/ | |
/opt/local/lib | |
/sw/lib/ | |
/usr/lib64 | |
/usr/lib | |
/usr/local/include | |
${CMAKE_LIBRARY_PATH} | |
PATH_SUFFIXES | |
glib-2.0/include | |
) | |
FIND_PATH( | |
_glib2_include_DIR | |
NAMES | |
glib.h | |
PATHS | |
/opt/gnome/include | |
/opt/local/include | |
/sw/include | |
/usr/include | |
/usr/local/include | |
PATH_SUFFIXES | |
glib-2.0 | |
) | |
#MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") | |
FIND_LIBRARY( | |
_glib2_link_DIR | |
NAMES | |
glib-2.0 | |
glib | |
PATHS | |
/opt/gnome/lib | |
/opt/local/lib | |
/sw/lib | |
/usr/lib | |
/usr/local/lib | |
) | |
IF ( _glib2_include_DIR AND _glib2_link_DIR ) | |
SET ( _glib2_FOUND TRUE ) | |
ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) | |
IF ( _glib2_FOUND ) | |
SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) | |
SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) | |
SET ( GLIB2_CORE_FOUND TRUE ) | |
ELSE ( _glib2_FOUND ) | |
SET ( GLIB2_CORE_FOUND FALSE ) | |
ENDIF ( _glib2_FOUND ) | |
# Handle dependencies | |
# libintl | |
IF ( NOT LIBINTL_FOUND ) | |
FIND_PATH(LIBINTL_INCLUDE_DIR | |
NAMES | |
libintl.h | |
PATHS | |
/opt/gnome/include | |
/opt/local/include | |
/sw/include | |
/usr/include | |
/usr/local/include | |
) | |
FIND_LIBRARY(LIBINTL_LIBRARY | |
NAMES | |
intl | |
PATHS | |
/opt/gnome/lib | |
/opt/local/lib | |
/sw/lib | |
/usr/local/lib | |
/usr/lib | |
) | |
IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) | |
SET (LIBINTL_FOUND TRUE) | |
ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) | |
ENDIF ( NOT LIBINTL_FOUND ) | |
# libiconv | |
IF ( NOT LIBICONV_FOUND ) | |
FIND_PATH(LIBICONV_INCLUDE_DIR | |
NAMES | |
iconv.h | |
PATHS | |
/opt/gnome/include | |
/opt/local/include | |
/opt/local/include | |
/sw/include | |
/sw/include | |
/usr/local/include | |
/usr/include | |
PATH_SUFFIXES | |
glib-2.0 | |
) | |
FIND_LIBRARY(LIBICONV_LIBRARY | |
NAMES | |
iconv | |
PATHS | |
/opt/gnome/lib | |
/opt/local/lib | |
/sw/lib | |
/usr/lib | |
/usr/local/lib | |
) | |
IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) | |
SET (LIBICONV_FOUND TRUE) | |
ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) | |
ENDIF ( NOT LIBICONV_FOUND ) | |
IF (LIBINTL_FOUND) | |
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) | |
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) | |
ENDIF (LIBINTL_FOUND) | |
IF (LIBICONV_FOUND) | |
SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) | |
SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) | |
ENDIF (LIBICONV_FOUND) | |
ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) | |
## | |
IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) | |
SET (GLIB2_FOUND TRUE) | |
ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) | |
IF (GLIB2_FOUND) | |
IF (NOT GLIB2_FIND_QUIETLY) | |
MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") | |
ENDIF (NOT GLIB2_FIND_QUIETLY) | |
ELSE (GLIB2_FOUND) | |
IF (GLIB2_FIND_REQUIRED) | |
MESSAGE (SEND_ERROR "Could not find GLib2") | |
ENDIF (GLIB2_FIND_REQUIRED) | |
ENDIF (GLIB2_FOUND) | |
# show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view | |
MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) | |
MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) | |
MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) | |
ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) | |
IF ( GLIB2_FOUND ) | |
# Check if system has a newer version of glib | |
# which supports g_regex_match_simple | |
INCLUDE( CheckIncludeFiles ) | |
SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) | |
CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) | |
# Reset CMAKE_REQUIRED_INCLUDES | |
SET( CMAKE_REQUIRED_INCLUDES "" ) | |
ENDIF( GLIB2_FOUND ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Find libnet | |
# | |
# -*- cmake -*- | |
# | |
# Find the libnet module | |
# | |
# LIBNET_INCLUDE_DIR - where to find libnet.h, etc. | |
# LIBNET_LIBRARIES - List of libraries when using LibNet. | |
# LIBNET_FOUND - True if libnet found. | |
IF (LIBNET_INCLUDE_DIR) | |
# Already in cache, be silent | |
SET(LIBNET_FIND_QUIETLY TRUE) | |
ENDIF (LIBNET_INCLUDE_DIR) | |
FIND_PATH(LIBNET_INCLUDE_DIR libnet.h | |
/usr/include | |
) | |
SET(LIBNET_NAMES net) | |
FIND_LIBRARY(LIBNET_LIBRARY | |
NAMES ${LIBNET_NAMES} | |
PATHS /usr/lib /usr/local/lib | |
PATH_SUFFIXES libnet | |
) | |
ADD_DEFINITIONS(-DLIBNET_LIL_ENDIAN=1) | |
IF (LIBNET_INCLUDE_DIR AND LIBNET_LIBRARY) | |
SET(LIBNET_FOUND TRUE) | |
SET(LIBNET_LIBRARIES ${LIBNET_LIBRARY} ) | |
ELSE (LIBNET_INCLUDE_DIR AND LIBNET_LIBRARY) | |
SET(LIBNET_FOUND FALSE) | |
SET(LIBNET_LIBRARIES ) | |
ENDIF (LIBNET_INCLUDE_DIR AND LIBNET_LIBRARY) | |
IF (LIBNET_FOUND) | |
IF (NOT LIBNET_FIND_QUIETLY) | |
MESSAGE(STATUS "Found LibNet: ${LIBNET_LIBRARY}") | |
ENDIF (NOT LIBNET_FIND_QUIETLY) | |
ELSE (LIBNET_FOUND) | |
IF (LIBNET_FIND_REQUIRED) | |
MESSAGE(STATUS "Looked for LibNet libraries named ${LIBNET_NAMES}.") | |
MESSAGE(FATAL_ERROR "Could NOT find LibNet library") | |
ENDIF (LIBNET_FIND_REQUIRED) | |
ENDIF (LIBNET_FOUND) | |
MARK_AS_ADVANCED( | |
LIBNET_LIBRARY | |
LIBNET_INCLUDE_DIR | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Find mysqlclient | |
# | |
# -*- cmake -*- | |
# | |
# Find the native MySQL includes and library | |
# | |
# MYSQL_INCLUDE_DIR - where to find mysql.h, etc. | |
# MYSQL_LIBRARIES - List of libraries when using MySQL. | |
# MYSQL_FOUND - True if MySQL found. | |
IF (MYSQL_INCLUDE_DIR) | |
# Already in cache, be silent | |
SET(MYSQL_FIND_QUIETLY TRUE) | |
ENDIF (MYSQL_INCLUDE_DIR) | |
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h | |
/usr/local/include/mysql | |
/usr/include/mysql | |
) | |
SET(MYSQL_NAMES mysqlclient mysqlclient_r) | |
FIND_LIBRARY(MYSQL_LIBRARY | |
NAMES ${MYSQL_NAMES} | |
PATHS /usr/lib /usr/local/lib | |
PATH_SUFFIXES mysql | |
) | |
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY) | |
SET(MYSQL_FOUND TRUE) | |
SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} ) | |
ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY) | |
SET(MYSQL_FOUND FALSE) | |
SET( MYSQL_LIBRARIES ) | |
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY) | |
IF (MYSQL_FOUND) | |
IF (NOT MYSQL_FIND_QUIETLY) | |
MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}") | |
ENDIF (NOT MYSQL_FIND_QUIETLY) | |
ELSE (MYSQL_FOUND) | |
IF (MYSQL_FIND_REQUIRED) | |
MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.") | |
MESSAGE(FATAL_ERROR "Could NOT find MySQL library") | |
ENDIF (MYSQL_FIND_REQUIRED) | |
ENDIF (MYSQL_FOUND) | |
MARK_AS_ADVANCED( | |
MYSQL_LIBRARY | |
MYSQL_INCLUDE_DIR | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Find Net-SNMP | |
# | |
# -*- cmake -*- | |
# | |
# Find the Net-SNMP module | |
# | |
# NETSNMP_INCLUDE_DIR - where to find Net-SNMP.h, etc. | |
# NETSNMP_LIBRARIES - List of libraries when using Net-SNMP. | |
# NETSNMP_FOUND - True if Net-SNMP found. | |
IF (NETSNMP_INCLUDE_DIR) | |
# Already in cache, be silent | |
SET(NETSNMP_FIND_QUIETLY TRUE) | |
ENDIF (NETSNMP_INCLUDE_DIR) | |
FIND_PATH(NETSNMP_INCLUDE_DIR snmp.h | |
/usr/include/net-snmp/library | |
) | |
SET(NETSNMP_NAMES netsnmp) | |
FIND_LIBRARY(NETSNMP_LIBRARY | |
NAMES ${NETSNMP_NAMES} | |
PATHS /usr/lib /usr/local/lib | |
) | |
SET(NETSNMPAGENT_NAMES netsnmpagent) | |
FIND_LIBRARY(NETSNMPAGENT_LIBRARY | |
NAMES ${NETSNMPAGENT_NAMES} | |
PATHS /usr/lib /usr/local/lib | |
) | |
SET(NETSNMPHELPERS_NAMES netsnmphelpers) | |
FIND_LIBRARY(NETSNMPHELPERS_LIBRARY | |
NAMES ${NETSNMPHELPERS_NAMES} | |
PATHS /usr/lib /usr/local/lib | |
) | |
SET(NETSNMPMIBS_NAMES netsnmpmibs) | |
FIND_LIBRARY(NETSNMPMIBS_LIBRARY | |
NAMES ${NETSNMPMIBS_NAMES} | |
PATHS /usr/lib /usr/local/lib | |
) | |
SET(NETSNMPTRAPD_NAMES netsnmptrapd) | |
FIND_LIBRARY(NETSNMPTRAPD_LIBRARY | |
NAMES ${NETSNMPTRAPD_NAMES} | |
PATHS /usr/lib /usr/local/lib | |
) | |
SET(NETSNMP_LIBRARIES | |
${NETSNMP_LIBRARY} | |
${NETSNMPAGENT_LIBRARY} | |
${NETSNMPHELPERS_LIBRARY} | |
${NETSNMPMIBS_LIBRARY} | |
# ${NETSNMPTRAPD_LIBRARY} | |
) | |
INCLUDE(FindPackageHandleStandardArgs) | |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETSNMP | |
DEFAULT_MSG | |
NETSNMP_INCLUDE_DIR | |
NETSNMP_LIBRARIES | |
) | |
MARK_AS_ADVANCED( | |
NETSNMP_LIBRARY | |
NETSNMPAGENT_LIBRARY | |
NETSNMPHELPERS_LIBRARY | |
NETSNMPMIBS_LIBRARY | |
NETSNMPTRAPD_LIBRARY | |
NETSNMP_INCLUDE_DIR | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Find PCRE library | |
# -*- cmake -*- | |
# | |
# Find the Perl-Compatible Regular Expressions (PCRE) includes and | |
# library | |
# | |
# Sets the following variables: | |
# | |
# PCRE_INCLUDE_DIR - where to find headers | |
# PCRE_LIBRARIES - List of libraries to link against | |
# PCRE_FOUND - True if PCRE found. | |
# | |
FIND_PACKAGE(PkgConfig) | |
PKG_CHECK_MODULES(PCRE REQUIRED libpcre) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment