]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: make cpu_profiler a library target 23254/head
authorKefu Chai <kchai@redhat.com>
Thu, 26 Jul 2018 05:50:29 +0000 (13:50 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 26 Jul 2018 07:16:48 +0000 (15:16 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/CMakeLists.txt
src/mds/CMakeLists.txt
src/osd/CMakeLists.txt
src/perfglue/CMakeLists.txt

index 40b5f9a84167cb600285ed9baf1d28b8dc983df0..91ad1529be75ea3af3006d0a7f982344c93c1338 100644 (file)
@@ -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
index 42220805e4e55338b24beff4efac8e390556117d..63c2bd5f2923edfd0467b9960f95deaca6dbb8b1 100644 (file)
@@ -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)
index fa7d20dcac41eefbdbfb692e7959774df4e76495..31dd823c58b9b6577300e43ceee76249c2e15cf6 100644 (file)
@@ -43,9 +43,9 @@ endif()
 add_library(osd STATIC ${osd_srcs}
   $<TARGET_OBJECTS:cls_references_objs>
   $<TARGET_OBJECTS:global_common_objs>)
-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()
index f467209a65bceb9d1570a361c8b922f405dbafc7..11546e98e53731ed30efb126b1cab799774872c7 100644 (file)
@@ -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()