From: Daniel Gryniewicz Date: Mon, 21 Sep 2015 14:37:19 +0000 (-0400) Subject: CMake - fix libatomic_ops and gperftools checks X-Git-Tag: v9.1.0~84^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b02e0f9bfe4cdab7d681ee8d864082dbcc80968f;p=ceph.git CMake - fix libatomic_ops and gperftools checks Signed-off-by: Daniel Gryniewicz --- diff --git a/CMakeLists.txt b/CMakeLists.txt index af4776c39999..a96a57a4fe36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,6 @@ CHECK_INCLUDE_FILES("expat.h" HAVE_EXPAT_H) CHECK_INCLUDE_FILES("fuse/fuse_lowlevel.h" HAVE_FUSE_LOWLEVEL_H) CHECK_INCLUDE_FILES("curl/curl.h" HAVE_FUSE_LOWLEVEL_H) CHECK_INCLUDE_FILES("fuse/fuse.h" HAVE_FUSE_H) -CHECK_INCLUDE_FILES("google/profiler.h" HAVE_PROFILER_H) CHECK_INCLUDE_FILES("libedit/vis.h" HAVE_LIBEDIT_VIS_H) CHECK_INCLUDE_FILES("fcgi_config.h" HAVE_FASTCGI_CONFIG_H) CHECK_INCLUDE_FILES("fastcgi.h" HAVE_FASTCGI_H) @@ -81,7 +80,6 @@ CHECK_INCLUDE_FILES("fcgios.h" FASTCGI_FASTCGIOS_DIR) CHECK_INCLUDE_FILES("fcgi_stdio.h" HAVE_FASTCGI_STDIO_H) CHECK_INCLUDE_FILES("openssl/ssl.h" HAVE_SSL_H) CHECK_INCLUDE_FILES("snappy.h" HAVE_SNAPPY_H) -CHECK_INCLUDE_FILES("atomic_ops.h" HAVE_ATOMIC_OPS) CHECK_INCLUDE_FILES("keyutils.h" HAVE_KEYUTILS_H) include(CheckSymbolExists) @@ -151,17 +149,20 @@ find_package(fcgi REQUIRED) set(HAVE_FCGI ${FCGI_FOUND}) endif(${WITH_FCGI}) -option(WITH_ATOMICS_OPS "Atomic Ops is here" ON) -if(${WITH_ATOMIC_OPS}) find_package(atomic_ops REQUIRED) set(HAVE_ATOMIC_OPS ${ATOMIC_OPS_FOUND}) -endif(${WITH_ATOMIC_OPS}) - -option(WITH_PROFILER "The Profiler is here" ON) -if(${WITH_PROFILER}) -find_package(profiler REQUIRED) -set(HAVE_PROFILER ${PROFILER_FOUND}) -endif(${WITH_PROFILER}) +message(STATUS "${ATOMIC_OPS_LIBRARIES}") + +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}) option(WITH_SNAPPY "Snappy is here" ON) if(${WITH_SNAPPY}) diff --git a/cmake/modules/Findatomic_ops.cmake b/cmake/modules/Findatomic_ops.cmake new file mode 100644 index 000000000000..c6714b77f96c --- /dev/null +++ b/cmake/modules/Findatomic_ops.cmake @@ -0,0 +1,28 @@ +# - Find atomic_ops +# Find the native ATOMIC_OPS headers and libraries. +# +# ATOMIC_OPS_INCLUDE_DIRS - where to find atomic_ops.h, etc. +# ATOMIC_OPS_LIBRARIES - List of libraries when using atomic_ops. +# ATOMIC_OPS_FOUND - True if atomic_ops found. + +# Look for the header file. +FIND_PATH(ATOMIC_OPS_INCLUDE_DIR NAMES atomic_ops.h) + +# Look for the library. +FIND_LIBRARY(ATOMIC_OPS_LIBRARY NAMES atomic_ops) + +# handle the QUIETLY and REQUIRED arguments and set ATOMIC_OPS_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(atomic_ops DEFAULT_MSG ATOMIC_OPS_LIBRARY ATOMIC_OPS_INCLUDE_DIR) + +# Copy the results to the output variables. +IF(ATOMIC_OPS_FOUND) + SET(ATOMIC_OPS_LIBRARIES ${ATOMIC_OPS_LIBRARY}) + SET(ATOMIC_OPS_INCLUDE_DIRS ${ATOMIC_OPS_INCLUDE_DIR}) +ELSE(ATOMIC_OPS_FOUND) + SET(ATOMIC_OPS_LIBRARIES) + SET(ATOMIC_OPS_INCLUDE_DIRS) +ENDIF(ATOMIC_OPS_FOUND) + +MARK_AS_ADVANCED(ATOMIC_OPS_INCLUDE_DIR ATOMIC_OPS_LIBRARY) diff --git a/cmake/modules/Findatomicops.cmake b/cmake/modules/Findatomicops.cmake deleted file mode 100644 index 18e8b03bc25f..000000000000 --- a/cmake/modules/Findatomicops.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# - Find atomic_ops -# Find the native ATOMIC_OPS headers and libraries. -# -# ATOMIC_OPS_INCLUDE_DIRS - where to find atomic_ops.h, etc. -# ATOMIC_OPS_LIBRARIES - List of libraries when using atomic_ops. -# ATOMIC_OPS_FOUND - True if atomic_ops found. - -# Look for the header file. -FIND_PATH(ATOMIC_OPS_INCLUDE_DIR NAMES atomic_ops.h) - -# Look for the library. -FIND_LIBRARY(ATOMIC_OPS_LIBRARY NAMES atomic_ops) - -# handle the QUIETLY and REQUIRED arguments and set ATOMIC_OPS_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ATOMIC_OPS DEFAULT_MSG ATOMIC_OPS_LIBRARY ATOMIC_OPS_INCLUDE_DIR) - -# Copy the results to the output variables. -IF(ATOMIC_OPS_FOUND) - SET(ATOMIC_OPS_LIBRARIES ${ATOMIC_OPS_LIBRARY}) - SET(ATOMIC_OPS_INCLUDE_DIRS ${ATOMIC_OPS_INCLUDE_DIR}) -ELSE(ATOMIC_OPS_FOUND) - SET(ATOMIC_OPS_LIBRARIES) - SET(ATOMIC_OPS_INCLUDE_DIRS) -ENDIF(ATOMIC_OPS_FOUND) - -MARK_AS_ADVANCED(ATOMIC_OPS_INCLUDE_DIR ATOMIC_OPS_LIBRARY) diff --git a/cmake/modules/Findgperftools.cmake b/cmake/modules/Findgperftools.cmake new file mode 100644 index 000000000000..28b08b6ffbe3 --- /dev/null +++ b/cmake/modules/Findgperftools.cmake @@ -0,0 +1,35 @@ +# Try to find Profiler +# Once done, this will define +# +# GPERFTOOLS_FOUND - system has Profiler +# GPERFTOOLS_INCLUDE_DIR - the Profiler include directories +# GPERFTOOLS_LIBRARIES - link these to use Profiler + +if(GPERFTOOLS_INCLUDE_DIR AND GPERFTOOLS_LIBRARIES) + set(GPERFTOOLS_FIND_QUIETLY TRUE) +endif(GPERFTOOLS_INCLUDE_DIR AND GPERFTOOLS_LIBRARIES) + +INCLUDE(CheckCXXSymbolExists) + +# include dir + +find_path(GPERFTOOLS_INCLUDE_DIR profiler.h NO_DEFAULT_PATH PATHS + /usr/include + /usr/include/gperftools + /usr/include/google + /opt/local/include + /usr/local/include +) + + +# finally the library itself +find_library(LIBPROFILER NAMES profiler) +CHECK_INCLUDE_FILES("google/profiler.h" HAVE_PROFILER_H) +set(GPERFTOOLS_LIBRARIES ${LIBPROFILER}) + +# handle the QUIETLY and REQUIRED arguments and set GPERFTOOLS_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(gperftools DEFAULT_MSG GPERFTOOLS_LIBRARIES GPERFTOOLS_INCLUDE_DIR) + +mark_as_advanced(GPERFTOOLS_LIBRARIES GPERFTOOLS_INCLUDE_DIR) diff --git a/cmake/modules/Findprofiler.cmake b/cmake/modules/Findprofiler.cmake deleted file mode 100644 index ca54227f56bc..000000000000 --- a/cmake/modules/Findprofiler.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# Try to find Profiler -# Once done, this will define -# -# PROFILER_FOUND - system has Profiler -# PROFILER_INCLUDE_DIR - the Profiler include directories -# PROFILER_LIBRARIES - link these to use Profiler - -if(PROFILER_INCLUDE_DIR AND PROFILER_LIBRARIES) -set(PROFILER_FIND_QUIETLY TRUE) -endif(PROFILER_INCLUDE_DIR AND PROFILER_LIBRARIES) - -INCLUDE(CheckCXXSymbolExists) - -# include dir - -find_path(PROFILER_INCLUDE_DIR profiler.h NO_DEFAULT_PATH PATHS - ${HT_DEPENDENCY_INCLUDE_DIR} - /usr/include - /usr/include/google - /opt/local/include - /usr/local/include -) - - -# finally the library itself -find_library(LIBPROFILER NAMES profiler) -set(PROFILER_LIBRARIES ${LIBPROFILER}) - -# handle the QUIETLY and REQUIRED arguments and set PROFILER_FOUND to TRUE if -# all listed variables are TRUE -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PROFILER DEFAULT_MSG PROFILER_LIBRARIES PROFILER_INCLUDE_DIR) - -mark_as_advanced(PROFILER_LIBRARIES PROFILER_INCLUDE_DIR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a790fa7023a..582d4b9ad33b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -69,7 +69,7 @@ else() endif() -set(EXTRALIBS uuid rt dl ${Boost_LIBS}) +set(EXTRALIBS uuid rt dl ${Boost_LIBS} ${ATOMIC_OPS_LIBRARIES}) if(${WITH_PROFILER}) list(APPEND EXTRALIBS profiler) @@ -83,12 +83,6 @@ if(USE_NSS) endif(NSS_FOUND) endif(USE_NSS) -if(${HAVE_ATOMIC_OPS}) - set(EXTRALIBS - atomic_ops - ${EXTRALIBS}) -endif(${HAVE_ATOMIC_OPS}) - set(GCOV_PREFIX_STRIP 4) get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER) @@ -120,13 +114,13 @@ if(HAVE_XIO) list(APPEND EXTRALIBS ${Xio_LIBRARY} ibverbs rdmacm pthread rt) endif(HAVE_XIO) -if(${WITH_TCMALLOC}) +if(${WITH_TCMALLOC} AND ${HAVE_GPERFTOOLS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free") set(TCMALLOC_LIBS tcmalloc) set(TCMALLOC_srcs perfglue/heap_profiler.cc) -else() +else(${WITH_TCMALLOC} AND ${HAVE_GPERFTOOLS}) set(TCMALLOC_srcs perfglue/disabled_heap_profiler.cc) -endif(${WITH_TCMALLOC}) +endif(${WITH_TCMALLOC} AND ${HAVE_GPERFTOOLS}) # tcmalloc heap profiler set(heap_profiler_files ${TCMALLOC_srcs}) @@ -313,13 +307,13 @@ set(common_mountcephfs_files add_library(common_mountcephfs_objs OBJECT ${common_mountcephfs_files}) -if(${WITH_PROFILER}) +if(${WITH_GPERFTOOLS}) list(APPEND libcommon_files perfglue/cpu_profiler.cc) else() list(APPEND libcommon_files perfglue/disabled_stubs.cc) -endif(${WITH_PROFILER}) +endif(${WITH_GPERFTOOLS}) if(${ENABLE_SHARED}) list(APPEND libcommon_files @@ -335,9 +329,9 @@ 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(${WITH_PROFILER}) +if(${WITH_GPERFTOOLS}) target_link_libraries(common profiler) -endif(${WITH_PROFILER}) +endif(${WITH_GPERFTOOLS}) add_library(common_utf8 STATIC common/utf8.c) diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 84514915e510..53d0f2ec050f 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -232,4 +232,9 @@ /* Defined if XIO */ #cmakedefine HAVE_XIO +/* Defined if new gperftools */ +#cmakedefine HAVE_GPERFTOOLS_HEAP_PROFILER_H +#cmakedefine HAVE_GPERFTOOLS_MALLOC_EXTENSION_H +#cmakedefine HAVE_GPERFTOOLS_PROFILER_H + #endif /* CONFIG_H */