From e22ec206ca784dcfc08ccd7bcefc8cf8a39dcf23 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 22 Oct 2010 10:27:27 -0500 Subject: [PATCH] Added support for optional google-perftools. --- BuildOptions.cmake | 5 ++-- CMakeLists.txt | 10 ++++++-- cmake/FindGooglePerftools.cmake | 44 +++++++++++++++++++++++++++++++++ config.h.in | 2 +- src/CMakeLists.txt | 1 + 5 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 cmake/FindGooglePerftools.cmake diff --git a/BuildOptions.cmake b/BuildOptions.cmake index 1f422d8837..306d52cb9d 100644 --- a/BuildOptions.cmake +++ b/BuildOptions.cmake @@ -36,7 +36,6 @@ set(BROv6 false CACHE STRING "enable IPv6 processing" FORCE) # TODO: add to configure wrapper as '--enable-perftools' -# TODO: make this option do stuff set(ENABLE_PERFTOOLS false CACHE STRING "use Google's perftools" FORCE) @@ -70,5 +69,5 @@ set(BinPAC_SKIP_INSTALL true) # Uncomment to specify a custom prefix containing the libGeoIP installation. #set(LibGeoIP_ROOT_DIR path/to/your/libGeoIP) -# TODO: more dependencies: -# Google perftools +# Uncomment to specify a custom prefix containing Google Perftools installation. +#set(GooglePerftools_ROOT_DIR path/to/your/google-perftools) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf5cd6659a..9a5d3047d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,12 @@ if (LIBGEOIP_FOUND) set(USE_GEOIP true) endif () -# TODO: optional Google perftools +if (ENABLE_PERFTOOLS) + find_package(GooglePerftools) + if (GOOGLEPERFTOOLS_FOUND) + set(USE_PERFTOOLS true) + endif () +endif () include_directories(BEFORE ${PCAP_INCLUDE_DIR} @@ -115,6 +120,7 @@ include_directories(BEFORE ${LibMagic_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${LibGeoIP_INCLUDE_DIR} + ${GooglePerftools_INCLUDE_DIR} ) ## @@ -171,7 +177,7 @@ message( "\nGeoIP: ${USE_GEOIP}" "\nlibz: ${HAVE_LIBZ}" "\nlibmagic: ${HAVE_LIBMAGIC}" - "\nGoogle perftools: ${use_perftools}" + "\nGoogle perftools: ${USE_PERFTOOLS}" "\n" "\n================================================================\n" ) diff --git a/cmake/FindGooglePerftools.cmake b/cmake/FindGooglePerftools.cmake new file mode 100644 index 0000000000..7ddd5a532e --- /dev/null +++ b/cmake/FindGooglePerftools.cmake @@ -0,0 +1,44 @@ +# - Try to find GooglePerftools headers and libraries +# +# Usage of this module as follows: +# +# find_package(GooglePerftools) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# GooglePerftools_ROOT_DIR Set this variable to the root installation of +# GooglePerftools if the module has problems finding +# the proper installation path. +# +# Variables defined by this module: +# +# GOOGLEPERFTOOLS_FOUND System has GooglePerftools libs/headers +# GooglePerftools_LIBRARIES The GooglePerftools libraries +# GooglePerftools_INCLUDE_DIR The location of GooglePerftools headers + +find_path(GooglePerftools_ROOT_DIR + NAMES include/google/heap-profiler.h +) + +find_library(GooglePerftools_LIBRARIES + NAMES tcmalloc + HINTS ${GooglePerftools_ROOT_DIR}/lib +) + +find_path(GooglePerftools_INCLUDE_DIR + NAMES google/heap-profiler.h + HINTS ${GooglePerftools_ROOT_DIR}/include +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GooglePerftools DEFAULT_MSG + GooglePerftools_LIBRARIES + GooglePerftools_INCLUDE_DIR +) + +mark_as_advanced( + GooglePerftools_ROOT_DIR + GooglePerftools_LIBRARIES + GooglePerftools_INCLUDE_DIR +) diff --git a/config.h.in b/config.h.in index 905a76ba99..232912c6aa 100644 --- a/config.h.in +++ b/config.h.in @@ -178,7 +178,7 @@ #undef USE_LIBCLAMAV /* Use Google's perftools */ -#undef USE_PERFTOOLS +#cmakedefine USE_PERFTOOLS /* Version number of package */ #define VERSION "@VERSION@" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 019841fbd6..a541f1a866 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -370,6 +370,7 @@ target_link_libraries(bro ${LibMagic_LIBRARY} ${ZLIB_LIBRARIES} ${LibGeoIP_LIBRARY} + ${GooglePerftools_LIBRARIES} ) install(TARGETS bro DESTINATION bin)