From: Kefu Chai Date: Mon, 25 Jul 2016 08:18:46 +0000 (+0800) Subject: cmake: do not link against profiler if gperftools is found X-Git-Tag: ses5-milestone5~300^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8268d1ba6aaa6e8552040e95c8bd6d6d6e035c81;p=ceph.git cmake: do not link against profiler if gperftools is found 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index aeb59b49ad80..6014a5ba2289 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8784350b775a..20173cb3c541 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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}")