]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: do not link against profiler if gperftools is found
authorKefu Chai <kchai@redhat.com>
Mon, 25 Jul 2016 08:18:46 +0000 (16:18 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 25 Jul 2016 08:22:20 +0000 (16:22 +0800)
this behaviour matches the autotools. and we should not enable profiling
unless asked to do so.

Fixes: http://tracker.ceph.com/issues/16804
Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
src/CMakeLists.txt

index aeb59b49ad800b00207b65de3233a207d9db4f0d..6014a5ba2289003beb3faca46b4a0fa8ba372254 100644 (file)
@@ -249,17 +249,6 @@ if(NOT ${ATOMIC_OPS_FOUND})
   set(NO_ATOMIC_OPS 1)
 endif(NOT ${ATOMIC_OPS_FOUND})
 
-option(WITH_GPERFTOOLS "gperftools is here" ON)
-if(${WITH_GPERFTOOLS})
-       find_package(gperftools)
-       set(HAVE_GPERFTOOLS ${GPERFTOOLS_FOUND})
-       if(${HAVE_GPERFTOOLS})
-               find_file(HAVE_GPERFTOOLS_HEAP_PROFILER_H heap-profiler.h PATHS /usr/include/gperftools)
-               find_file(HAVE_GPERFTOOLS_MALLOC_EXTENSION_H malloc_extension.h PATHS /usr/include/gperftools)
-               find_file(HAVE_GPERFTOOLS_PROFILER_H profiler.h PATHS /usr/include/gperftools)
-       endif(${HAVE_GPERFTOOLS})
-endif(${WITH_GPERFTOOLS})
-
 find_package(snappy REQUIRED)
 
 #if allocator is set on command line make sure it matches below strings
index 8784350b775a475dc646d7b58d61a9ddb6256a51..20173cb3c5414bff0a76278261bd3236c4cb79d3 100644 (file)
@@ -201,9 +201,19 @@ set(EXTRALIBS uuid rt ${CMAKE_DL_LIBS} ${ATOMIC_OPS_LIBRARIES})
 
 option(WITH_PROFILER "build extra profiler binaries" OFF)
 if(WITH_PROFILER)
+  find_package(gperftools REQUIRED)
   list(APPEND EXTRALIBS profiler)
 endif(WITH_PROFILER)
 
+if(WITH_PROFILER AND ALLOCATOR STREQUAL "tcmalloc")
+  find_file(HAVE_GPERFTOOLS_HEAP_PROFILER_H heap-profiler.h
+    PATHS ${GPERFTOOLS_INCLUDE_DIR})
+  find_file(HAVE_GPERFTOOLS_MALLOC_EXTENSION_H malloc_extension.h
+    PATHS ${GPERFTOOLS_INCLUDE_DIR})
+  find_file(HAVE_GPERFTOOLS_PROFILER_H profiler.h
+    PATHS ${GPERFTOOLS_INCLUDE_DIR})
+endif()
+
 if(${ENABLE_COVERAGE})
   find_program(HAVE_GCOV gcov)
   if(NOT HAVE_GCOV)
@@ -476,13 +486,13 @@ set(common_mountcephfs_files
 add_library(common_mountcephfs_objs OBJECT
   ${common_mountcephfs_files})
 
-if(WITH_PROFILER AND HAVE_GPERFTOOLS)
+if(WITH_PROFILER)
   list(APPEND libcommon_files
     perfglue/cpu_profiler.cc)
 else()
   list(APPEND libcommon_files
     perfglue/disabled_stubs.cc)
-endif(WITH_PROFILER AND HAVE_GPERFTOOLS)
+endif()
 
 if(ENABLE_SHARED)
   list(APPEND libcommon_files
@@ -499,10 +509,6 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/ceph_ver.c
   ${CMAKE_SOURCE_DIR}/src/test/encoding/ceph_dencoder.cc
   APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
 
-if(${HAVE_GPERFTOOLS})
-  target_link_libraries(common profiler)
-endif(${HAVE_GPERFTOOLS})
-
 if(HAVE_ARMV8_CRC)
   add_library(common_crc_aarch64 STATIC common/crc32c_aarch64.c)
   set_target_properties(common_crc_aarch64 PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARM_CRC_FLAGS}")