mirror of
https://github.com/ceph/ceph
synced 2024-12-24 04:14:07 +00:00
599a9ef3ca
otherwise it's always true, even if the libaries are not found. also the cmake output will be wrong without this change: without this change, it is: -- Found gperftools: GPERFTOOLS_TCMALLOC_LIBRARY;GPERFTOOLS_TCMALLOC_MINIMAL_LIBRARY;GPERFTOOLS_PROFILER_LIBRARY (found version "2.5.93") with this change, it would be: -- Found gperftools: /tmp/gperf/lib/libtcmalloc.so (found version "2.5.93") Signed-off-by: Kefu Chai <kchai@redhat.com>
47 lines
1.8 KiB
CMake
47 lines
1.8 KiB
CMake
# Try to find gperftools
|
|
# Once done, this will define
|
|
#
|
|
# GPERFTOOLS_FOUND - system has Profiler
|
|
# GPERFTOOLS_INCLUDE_DIR - the Profiler include directories
|
|
# Tcmalloc_INCLUDE_DIR - where to find Tcmalloc.h
|
|
# GPERFTOOLS_TCMALLOC_LIBRARY - link it to use tcmalloc
|
|
# GPERFTOOLS_TCMALLOC_MINIMAL_LIBRARY - link it to use tcmalloc_minimal
|
|
# GPERFTOOLS_PROFILER_LIBRARY - link it to use Profiler
|
|
# TCMALLOC_VERSION_STRING
|
|
# TCMALLOC_VERSION_MAJOR
|
|
# TCMALLOC_VERSION_MINOR
|
|
# TCMALLOC_VERSION_PATCH
|
|
|
|
find_path(GPERFTOOLS_INCLUDE_DIR gperftools/profiler.h
|
|
HINTS $ENV{GPERF_ROOT}/include)
|
|
find_path(Tcmalloc_INCLUDE_DIR gperftools/tcmalloc.h
|
|
HINTS $ENV{GPERF_ROOT}/include)
|
|
|
|
if(Tcmalloc_INCLUDE_DIR AND EXISTS "${Tcmalloc_INCLUDE_DIR}/gperftools/tcmalloc.h")
|
|
foreach(ver "MAJOR" "MINOR" "PATCH")
|
|
file(STRINGS "${Tcmalloc_INCLUDE_DIR}/gperftools/tcmalloc.h" TC_VER_${ver}_LINE
|
|
REGEX "^#define[ \t]+TC_VERSION_${ver}[ \t]+[^ \t]+$")
|
|
string(REGEX REPLACE "^#define[ \t]+TC_VERSION_${ver}[ \t]+(\".)?([0-9]*)\"?$"
|
|
"\\2" TCMALLOC_VERSION_${ver} "${TC_VER_${ver}_LINE}")
|
|
unset(TC_VER_${ver}_LINE)
|
|
endforeach()
|
|
set(TCMALLOC_VERSION_STRING "${TCMALLOC_VERSION_MAJOR}.${TCMALLOC_VERSION_MINOR}")
|
|
if(NOT TCMALLOC_VERSION_PATCH STREQUAL "")
|
|
set(TCMALLOC_VERSION_STRING "${TCMALLOC_VERSION_STRING}.${TCMALLOC_VERSION_PATCH}")
|
|
endif()
|
|
endif()
|
|
|
|
foreach(component tcmalloc tcmalloc_minimal profiler)
|
|
string(TOUPPER ${component} COMPONENT)
|
|
find_library(GPERFTOOLS_${COMPONENT}_LIBRARY ${component}
|
|
HINTS $ENV{GPERF_ROOT}/lib)
|
|
list(APPEND GPERFTOOLS_LIBRARIES GPERFTOOLS_${COMPONENT}_LIBRARY)
|
|
endforeach()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(gperftools
|
|
REQUIRED_VARS ${GPERFTOOLS_LIBRARIES} GPERFTOOLS_INCLUDE_DIR
|
|
VERSION_VAR TCMALLOC_VERSION_STRING)
|
|
|
|
mark_as_advanced(${GPERFTOOLS_LIBRARIES} GPERFTOOLS_INCLUDE_DIR)
|