From: Kefu Chai Date: Thu, 26 Jul 2018 05:50:29 +0000 (+0800) Subject: cmake: make cpu_profiler a library target X-Git-Tag: v14.0.1~756^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=332bb07303b81ef3054fad775dd88080e6d9ae0e;p=ceph.git cmake: make cpu_profiler a library target Signed-off-by: Kefu Chai --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40b5f9a84167c..91ad1529be75e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -210,12 +210,6 @@ if(LINUX OR APPLE) list(APPEND EXTRALIBS ${LIB_RESOLV}) endif() -option(WITH_PROFILER "build extra profiler binaries" OFF) -if(WITH_PROFILER) - find_package(gperftools REQUIRED) - list(APPEND EXTRALIBS profiler) -endif(WITH_PROFILER) - if(${ENABLE_COVERAGE}) find_program(HAVE_GCOV gcov) if(NOT HAVE_GCOV) @@ -619,14 +613,6 @@ set(common_mountcephfs_files add_library(common_mountcephfs_objs OBJECT ${common_mountcephfs_files}) -if(WITH_PROFILER) - list(APPEND libcommon_files - perfglue/cpu_profiler.cc) -else() - list(APPEND libcommon_files - perfglue/disabled_stubs.cc) -endif() - add_library(common-objs OBJECT ${libcommon_files}) set(ceph_common_objs diff --git a/src/mds/CMakeLists.txt b/src/mds/CMakeLists.txt index 42220805e4e55..63c2bd5f2923e 100644 --- a/src/mds/CMakeLists.txt +++ b/src/mds/CMakeLists.txt @@ -43,4 +43,5 @@ set(mds_srcs ${CMAKE_SOURCE_DIR}/src/common/MemoryModel.cc ${CMAKE_SOURCE_DIR}/src/osdc/Journaler.cc) add_library(mds STATIC ${mds_srcs}) -target_link_libraries(mds heap_profiler ${ALLOC_LIBS} osdc liblua) +target_link_libraries(mds PRIVATE + heap_profiler cpu_profiler ${ALLOC_LIBS} osdc liblua) diff --git a/src/osd/CMakeLists.txt b/src/osd/CMakeLists.txt index fa7d20dcac41e..31dd823c58b9b 100644 --- a/src/osd/CMakeLists.txt +++ b/src/osd/CMakeLists.txt @@ -43,9 +43,9 @@ endif() add_library(osd STATIC ${osd_srcs} $ $) -target_link_libraries(osd +target_link_libraries(osd PRIVATE ${LEVELDB_LIBRARIES} - dmclock heap_profiler ${CMAKE_DL_LIBS} ${ALLOC_LIBS}) + dmclock heap_profiler cpu_profiler ${CMAKE_DL_LIBS} ${ALLOC_LIBS}) if(WITH_LTTNG) add_dependencies(osd osd-tp pg-tp) endif() diff --git a/src/perfglue/CMakeLists.txt b/src/perfglue/CMakeLists.txt index f467209a65bce..11546e98e5373 100644 --- a/src/perfglue/CMakeLists.txt +++ b/src/perfglue/CMakeLists.txt @@ -7,3 +7,16 @@ else() add_library(heap_profiler STATIC disabled_heap_profiler.cc) endif() + +option(WITH_PROFILER "build extra profiler binaries" OFF) + +if(WITH_PROFILER) + find_package(gperftools REQUIRED profiler) + add_library(cpu_profiler STATIC + cpu_profiler.cc) + target_link_libraries(cpu_profiler + gperftools::profiler) +else() + add_library(cpu_profiler STATIC + disabled_stubs.cc) +endif()