1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
# - Try to find Google perftools include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(Perftools)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# PERFTOOLS_ROOT Preferred installation prefix for searching for
# Perftools, set this if the module has problems
# finding the proper installation path.
# PERFTOOLS_INCLUDEDIR Set this to the include directory of the Google
# perftools, if the module has problems finding the
# installation path.
# PERFTOOLS_LIBRARYDIR Set this to the library directory of the Google
# perftools if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# Perftools_FOUND System has Google perftools, this means the
# include dir and all the libraries were found.
# Perftools_INCLUDE_DIRS Google perftools include directories.
# Perftools_LIBRARIES Link these to use the Google perftools libraries.
#
# Perftools_TCMALLOC_LIBRARY Path to the tcmalloc library.
# Perftools_STACKTRACE_LIBRARY Path to the stacktrace library.
# Perftools_PROFILER_LIBRARY Path to the profiler library.
if (PERFTOOLS_ROOT)
set(Perftools_ADDITIONAL_INCLUDE_SEARCH_DIRS ${PERFTOOLS_ROOT}/include)
set(Perftools_ADDITIONAL_LIBRARY_SEARCH_DIRS ${PERFTOOLS_ROOT}/lib)
endif ()
if (PERFTOOLS_INCLUDEDIR)
set(Perftools_ADDITIONAL_INCLUDE_SEARCH_DIRS ${PERFTOOLS_ROOT}/include)
endif ()
if (PERFTOOLS_LIBRARYDIR)
set(Perftools_ADDITIONAL_LIBRARY_SEARCH_DIRS ${PERFTOOLS_ROOT}/lib)
endif ()
if (Perftools_LIBRARIES AND Perftools_INCLUDE_DIRS)
# In cache already.
set(Perftools_FOUND true)
else ()
find_path(Perftools_INCLUDE_DIRS
NAMES
google/heap-profiler.h
PATHS
${Perftools_ADDITIONAL_INCLUDE_SEARCH_DIRS}
/usr/local/include
/opt/local/include
/sw/include
/usr/include
)
# tcmalloc
set(tcmalloc_names ${tcmalloc_names} tcmalloc)
find_library(perftools_tcmalloc_library
NAMES
${tcmalloc_names}
PATHS
${Perftools_ADDITIONAL_LIBRARY_SEARCH_DIRS}
/usr/local/lib
/opt/local/lib
/sw/lib
/usr/lib
)
if (perftools_tcmalloc_library AND Perftools_INCLUDE_DIRS)
set(Perftools_TCMALLOC_LIBRARY ${perftools_tcmalloc_library})
set(Perftools_LIBRARIES
${Perftools_LIBRARIES} ${perftools_tcmalloc_library})
set(Perftools_FOUND true)
else ()
set(Perftools_FOUND false)
endif ()
# stacktrace
set(stacktrace_names ${stacktrace_names} stacktrace)
find_library(perftools_stacktrace_library
NAMES
${stacktrace_names}
PATHS
${Perftools_ADDITIONAL_LIBRARY_SEARCH_DIRS}
/usr/local/lib
/opt/local/lib
/sw/lib
/usr/lib
)
if (perftools_stacktrace_library AND Perftools_INCLUDE_DIRS)
set(Perftools_STACKTRACE_LIBRARY ${perftools_stacktrace_library})
set(Perftools_LIBRARIES
${Perftools_LIBRARIES} ${perftools_stacktrace_library})
endif ()
# profiler
set(profiler_names ${profiler_names} profiler)
find_library(perftools_profiler_library
NAMES
${profiler_names}
PATHS
${Perftools_ADDITIONAL_LIBRARY_SEARCH_DIRS}
/usr/local/lib
/opt/local/lib
/sw/lib
/usr/lib
)
if (perftools_profiler_library AND Perftools_INCLUDE_DIRS)
set(Perftools_PROFILER_LIBRARY ${perftools_profiler_library})
set(Perftools_LIBRARIES
${Perftools_LIBRARIES} ${perftools_profiler_library})
endif ()
if (Perftools_FOUND)
if (NOT Perftools_FIND_QUIETLY)
message(STATUS "Found Google perftools")
endif ()
else ()
if (Perftools_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Google perftools")
endif ()
endif ()
mark_as_advanced(
Perftools_INCLUDE_DIRS
Perftools_LIBRARIES
Perftools_TCMALLOC_LIBRARY
Perftools_STACKTRACE_LIBRARY
Perftools_PROFILER_LIBRARY
)
endif()
|