Skip to content

Commit

Permalink
CMake - fix libatomic_ops and gperftools checks
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Gryniewicz <dang@fprintf.net>
  • Loading branch information
dang committed Sep 23, 2015
1 parent 3afd517 commit b02e0f9
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 61 deletions.
23 changes: 12 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ 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
# 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)
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)
Expand Down
35 changes: 35 additions & 0 deletions cmake/modules/Findgperftools.cmake
Original file line number Diff line number Diff line change
@@ -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)
34 changes: 0 additions & 34 deletions cmake/modules/Findprofiler.cmake

This file was deleted.

22 changes: 8 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions src/include/config-h.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit b02e0f9

Please sign in to comment.