Skip to content

Commit

Permalink
Merge pull request #10391 from ceph/wip-cmake
Browse files Browse the repository at this point in the history
cmake changes

Reviewed-by: Ali Maredia <amaredia@redhat.com>
  • Loading branch information
alimaredia committed Jul 26, 2016
2 parents a459c50 + e92c9cc commit 05e14bf
Show file tree
Hide file tree
Showing 17 changed files with 216 additions and 273 deletions.
36 changes: 12 additions & 24 deletions CMakeLists.txt
Expand Up @@ -57,22 +57,24 @@ endif(WITH_MANPAGE)

include_directories(
${PROJECT_BINARY_DIR}/src/include
${OFED_PREFIX}/include
${LEVELDB_PREFIX}/include
${PROJECT_SOURCE_DIR}/src
)

link_directories(
${OFED_PREFIX}/lib
${LEVELDB_PREFIX}/lib
)
${PROJECT_SOURCE_DIR}/src)

if(LEVELDB_PREFIX)
include_directories(${LEVELDB_PREFIX}/include)
link_directories(${LEVELDB_PREFIX}/lib)
endif()

if(OFED_PREFIX)
include_directories(${OFED_PREFIX}/include)
link_directories(${OFED_PREFIX}/lib)
endif()

if(FREEBSD)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include)
endif(FREEBSD)


#put all the libs and binaries in one place
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down Expand Up @@ -197,7 +199,6 @@ option(WITH_OPENLDAP "OPENLDAP is here" ON)
if(${WITH_OPENLDAP})
find_package(OpenLdap REQUIRED)
set(HAVE_OPENLDAP ${OPENLDAP_FOUND})
message(STATUS "${OPENLDAP_LIBS}")
endif(${WITH_OPENLDAP})

option(WITH_FUSE "Fuse is here" ON)
Expand Down Expand Up @@ -248,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
Expand Down Expand Up @@ -292,8 +282,6 @@ if(NOT FREEBSD)
find_package(keyutils REQUIRED)
endif(NOT FREEBSD)

find_package(libuuid REQUIRED)

find_package(CURL REQUIRED)
set(CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARIES})
Expand Down
101 changes: 101 additions & 0 deletions cmake/modules/FindBacktrace.cmake
@@ -0,0 +1,101 @@
#.rst:
# FindBacktrace
# -------------
#
# Find provider for backtrace(3).
#
# Checks if OS supports backtrace(3) via either libc or custom library.
# This module defines the following variables:
#
# ``Backtrace_HEADER``
# The header file needed for backtrace(3). Cached.
# Could be forcibly set by user.
# ``Backtrace_INCLUDE_DIRS``
# The include directories needed to use backtrace(3) header.
# ``Backtrace_LIBRARIES``
# The libraries (linker flags) needed to use backtrace(3), if any.
# ``Backtrace_FOUND``
# Is set if and only if backtrace(3) support detected.
#
# The following cache variables are also available to set or use:
#
# ``Backtrace_LIBRARY``
# The external library providing backtrace, if any.
# ``Backtrace_INCLUDE_DIR``
# The directory holding the backtrace(3) header.
#
# Typical usage is to generate of header file using configure_file() with the
# contents like the following::
#
# #cmakedefine01 Backtrace_FOUND
# #if Backtrace_FOUND
# # include <${Backtrace_HEADER}>
# #endif
#
# And then reference that generated header file in actual source.

#=============================================================================
# Copyright 2013 Vadim Zhukov
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)


include(CMakePushCheckState)
include(CheckSymbolExists)
include(FindPackageHandleStandardArgs)

# List of variables to be provided to find_package_handle_standard_args()
set(_Backtrace_STD_ARGS Backtrace_INCLUDE_DIR)

if(Backtrace_HEADER)
set(_Backtrace_HEADER_TRY "${Backtrace_HEADER}")
else(Backtrace_HEADER)
set(_Backtrace_HEADER_TRY "execinfo.h")
endif(Backtrace_HEADER)

find_path(Backtrace_INCLUDE_DIR "${_Backtrace_HEADER_TRY}")
set(Backtrace_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})

if (NOT DEFINED Backtrace_LIBRARY)
# First, check if we already have backtrace(), e.g., in libc
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS})
set(CMAKE_REQUIRED_QUIET ${Backtrace_FIND_QUIETLY})
check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND)
cmake_pop_check_state()
endif()

if(_Backtrace_SYM_FOUND)
# Avoid repeating the message() call below each time CMake is run.
if(NOT Backtrace_FIND_QUIETLY AND NOT DEFINED Backtrace_LIBRARY)
message(STATUS "backtrace facility detected in default set of libraries")
endif()
set(Backtrace_LIBRARY "" CACHE FILEPATH "Library providing backtrace(3), empty for default set of libraries")
else()
# Check for external library, for non-glibc systems
if(Backtrace_INCLUDE_DIR)
# OpenBSD has libbacktrace renamed to libexecinfo
find_library(Backtrace_LIBRARY "execinfo")
elseif() # respect user wishes
set(_Backtrace_HEADER_TRY "backtrace.h")
find_path(Backtrace_INCLUDE_DIR ${_Backtrace_HEADER_TRY})
find_library(Backtrace_LIBRARY "backtrace")
endif()

# Prepend list with library path as it's more common practice
set(_Backtrace_STD_ARGS Backtrace_LIBRARY ${_Backtrace_STD_ARGS})
endif()

set(Backtrace_LIBRARIES ${Backtrace_LIBRARY})
set(Backtrace_HEADER "${_Backtrace_HEADER_TRY}" CACHE STRING "Header providing backtrace(3) facility")

find_package_handle_standard_args(Backtrace FOUND_VAR Backtrace_FOUND REQUIRED_VARS ${_Backtrace_STD_ARGS})
mark_as_advanced(Backtrace_HEADER Backtrace_INCLUDE_DIR Backtrace_LIBRARY)
38 changes: 11 additions & 27 deletions cmake/modules/FindOpenLdap.cmake
@@ -1,38 +1,22 @@
# - Find OpenLDAP C Libraries
#
# OPENLDAP_PREFIX - where to find ldap.h and libraries
# OPENLDAP_FOUND - True if found.
# OPENLDAP_INCLUDE_DIR - Path to the openldap include directory
# OPENLDAP_LIBRARIES - Paths to the ldap and lber libraries

set(OPENLDAP_LIB_DIR "${OPENLDAP_PREFIX}/lib")

find_path(OPENLDAP_INCLUDE_DIR ldap.h NO_DEFAULT_PATH PATHS
find_path(OPENLDAP_INCLUDE_DIR ldap.h PATHS
/usr/include
/opt/local/include
/usr/local/include
"${OPENLDAP_PREFIX}/include"
)

find_library(LIBLDAP NAMES ldap)
find_library(LIBLBER NAMES lber)
/usr/local/include)

if (OPENLDAP_INCLUDE_DIR AND LIBLDAP AND LIBLBER)
set(OPENLDAP_FOUND TRUE)
else (OPENLDAP_INCLUDE_DIR AND LIBLDAP AND LIBLBER)
set(OPENLDAP_FOUND FALSE)
endif (OPENLDAP_INCLUDE_DIR AND LIBLDAP AND LIBLBER)
find_library(LDAP_LIBRARY ldap)
find_library(LBER_LIBRARY lber)

if (OPENLDAP_FOUND)
message(STATUS "Found ldap: ${OPENLDAP_INCLUDE_DIR}")
else (OPENLDAP_FOUND)
if (NOT OPENLDAP_INCLUDE_DIR)
message(FATAL_ERROR "Missing required ldap.h (openldap-devel)")
else (NOT OPENLDAP_INCLUDE_DIR)
message (FATAL_ERROR "Missing required LDAP libraries (openldap)")
endif (NOT OPENLDAP_INCLUDE_DIR)
endif (OPENLDAP_FOUND)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenLdap DEFAULT_MSG
OPENLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY)

set(OPENLDAP_LIBS ${LIBLDAP} ${LIBLBER})
set(OPENLDAP_LIBRARIES ${LDAP_LIBRARY} ${LBER_LIBRARY})

mark_as_advanced(
OPENLDAP_INCLUDE_DIR OPENLDAP_LIB_DIR OPENLDAP_LIBRARIES
)
OPENLDAP_INCLUDE_DIR LDAP_LIBRARY LBER_LIBRARY)
52 changes: 10 additions & 42 deletions cmake/modules/Findaio.cmake
@@ -1,50 +1,18 @@
# - Find AIO
#
# AIO_INCLUDE - Where to find AIO/aio.h
# AIO_INCLUDE - Where to find libaio.h
# AIO_LIBS - List of libraries when using AIO.
# AIO_FOUND - True if AIO found.

get_filename_component(module_file_path ${CMAKE_CURRENT_LIST_FILE} PATH)
find_path(AIO_INCLUDE_DIR
libaio.h
HINTS $ENV{AIO_ROOT}/include)

# Look for the header file.
find_path(AIO_INCLUDE
NAMES aio.h
PATHS /usr/include $ENV{AIO_ROOT}/include /opt/local/include /usr/local/include
DOC "Path in which the file AIO/aio.h is located." )
find_library(AIO_LIBRARIES
aio
HINTS $ENV{AIO_ROOT}/lib)

mark_as_advanced(AIO_INCLUDE)

# Look for the library.
# Does this work on UNIX systems? (LINUX)
find_library(AIO_LIBS
NAMES aio
PATHS /usr/lib /usr/lib/x86_64-linux-gnu $ENV{AIO_ROOT}/lib
DOC "Path to AIO library.")

mark_as_advanced(AIO_LIBS)

# Copy the results to the output variables.
if (AIO_INCLUDE AND AIO_LIBS)
message(STATUS "Found AIO in ${AIO_INCLUDE} ${AIO_LIBS}")
set(AIO_FOUND 1)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_LIBRARY ${AIO_LIBS} pthread)
set(CMAKE_REQUIRED_INCLUDES ${AIO_INCLUDE})
else ()
set(AIO_FOUND 0)
endif ()

# Report the results.
if (NOT AIO_FOUND)
set(AIO_DIR_MESSAGE "AIO was not found. Make sure AIO_LIBS and AIO_INCLUDE are set.")
if (AIO_FIND_REQUIRED)
message(FATAL_ERROR "${AIO_DIR_MESSAGE}")
elseif (NOT AIO_FIND_QUIETLY)
message(STATUS "${AIO_DIR_MESSAGE}")
endif ()
endif ()

# handle the QUIETLY and REQUIRED arguments and set UUID_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(aio DEFAULT_MSG AIO_LIBS AIO_INCLUDE)
find_package_handle_standard_args(aio DEFAULT_MSG AIO_LIBRARIES AIO_INCLUDE_DIR)

mark_as_advanced(AIO_INCLUDE_DIR AIO_LIBRARIES)
55 changes: 8 additions & 47 deletions cmake/modules/Findbabeltrace.cmake
@@ -1,61 +1,22 @@
# - Find Babeltrace
# This module accepts the following optional variables:
# BABELTRACE_PATH_HINT = A hint on BABELTRACE install path.
#
# This module defines the following variables:
# BABELTRACE_FOUND = Was Babeltrace found or not?
# BABELTRACE_EXECUTABLE = The path to lttng command
# BABELTRACE_LIBRARIES = The list of libraries to link to when using Babeltrace
# BABELTRACE_INCLUDE_DIR = The path to Babeltrace include directory
#
# On can set BABELTRACE_PATH_HINT before using find_package(Babeltrace) and the
# module with use the PATH as a hint to find Babeltrace.
#
# The hint can be given on the command line too:
# cmake -DBABELTRACE_PATH_HINT=/DATA/ERIC/Babeltrace /path/to/source

if(BABELTRACE_PATH_HINT)
message(STATUS "FindBabeltrace: using PATH HINT: ${BABELTRACE_PATH_HINT}")
else()
set(BABELTRACE_PATH_HINT)
endif()

#One can add his/her own builtin PATH.
#FILE(TO_CMAKE_PATH "/DATA/ERIC/Babeltrace" MYPATH)
#list(APPEND BABELTRACE_PATH_HINT ${MYPATH})

find_path(BABELTRACE_INCLUDE_DIR
NAMES babeltrace/babeltrace.h babeltrace/ctf/events.h babeltrace/ctf/iterator.h
PATHS ${BABELTRACE_PATH_HINT}
PATH_SUFFIXES include
DOC "The Babeltrace include headers")

find_path(BABELTRACE_LIBRARY_DIR
NAMES libbabeltrace.so
NAMES libbabeltrace-ctf.so
PATHS ${BABELTRACE_PATH_HINT}
PATH_SUFFIXES lib lib64
DOC "The Babeltrace libraries")

find_library(BABELTRACE NAMES babeltrace babeltrace-ctf PATHS ${BABELTRACE_LIBRARY_DIR})
NAMES babeltrace/babeltrace.h babeltrace/ctf/events.h babeltrace/ctf/iterator.h)

set(BABELTRACE_LIBRARIES ${BABELTRACE})
find_library(BABELTRACE_LIBRARY
NAMES babeltrace babeltrace-ctf)

message(STATUS "Looking for Babeltrace...")
set(BABELTRACE_NAMES "babeltrace;babeltrace-ctf")
# FIND_PROGRAM twice using NO_DEFAULT_PATH on first shot
find_program(BABELTRACE_EXECUTABLE
NAMES ${BABELTRACE_NAMES}
PATHS ${BABELTRACE_PATH_HINT}/bin /bin
NO_DEFAULT_PATH
DOC "The BABELTRACE command line tool")
NAMES babeltrace babeltrace-ctf)

# handle the QUIETLY and REQUIRED arguments and set PRELUDE_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(BABELTRACE
REQUIRED_VARS BABELTRACE_INCLUDE_DIR BABELTRACE_LIBRARY_DIR)
# VERSION FPHSA options not handled by CMake version < 2.8.2)
# VERSION_VAR)
mark_as_advanced(BABELTRACE_INCLUDE_DIR)
mark_as_advanced(BABELTRACE_LIBRARY_DIR)
find_package_handle_standard_args(BABELTRACE DEFAULT_MSG
BABELTRACE_INCLUDE_DIR BABELTRACE_LIBRARY)
set(BABELTRACE_LIBRARIES ${BABELTRACE_LIBRARY})
mark_as_advanced(BABELTRACE_INCLUDE_DIR BABELTRACE_LIBRARY)
28 changes: 2 additions & 26 deletions cmake/modules/Findblkid.cmake
Expand Up @@ -25,33 +25,9 @@

find_path(BLKID_INCLUDE_DIR blkid/blkid.h)

set(BLKID_NAMES ${BLKID_NAMES} blkid)
find_library(BLKID_LIBRARY NAMES ${BLKID_NAMES})
find_library(BLKID_LIBRARIES blkid)

if (BLKID_INCLUDE_DIR AND BLKID_LIBRARY)
set(BLKID_FOUND TRUE)
set( BLKID_LIBRARIES ${BLKID_LIBRARY} )
else ()
set(BLKID_FOUND FALSE)
set( BLKID_LIBRARIES )
endif ()

if (BLKID_FOUND)
message(STATUS "Found libblkid: ${BLKID_LIBRARY}")
else ()
message(STATUS "Not Found libblkid: ${BLKID_LIBRARY}")
if (BLKID_FIND_REQUIRED)
message(STATUS "Looked for libblkid named ${BLKID_NAMES}.")
message(FATAL_ERROR "Could NOT find libblkid")
endif ()
endif ()

# handle the QUIETLY and REQUIRED arguments and set UUID_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(blkid DEFAULT_MSG BLKID_LIBRARIES BLKID_INCLUDE_DIR)

mark_as_advanced(
BLKID_LIBRARY
BLKID_I
)
mark_as_advanced(BLKID_LIBRARIES BLKID_INCLUDE_DIR)

0 comments on commit 05e14bf

Please sign in to comment.