Skip to content

Commit

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

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
Reviewed-by: Ali Maredia <amaredia@redhat.com>
  • Loading branch information
tchaikov committed Jul 30, 2016
2 parents e5b3ee0 + a27bbaa commit 00b6fe1
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 190 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 2.8.11)
project(ceph)
set(VERSION "10.2.1")

if (NOT (CMAKE_MAJOR_VERSION LESS 3))
if(POLICY CMP0046)
# Tweak policies (this one disables "missing" dependency warning)
cmake_policy(SET CMP0046 OLD)
endif(NOT (CMAKE_MAJOR_VERSION LESS 3))
endif()
# we use LINK_PRIVATE keyword instead of PRIVATE, but do not specify the LINK_PUBLIC
# for target_link_libraries() command when PUBLIC should be used instead, it's just
# for backward compatibility with cmake 2.8.11.
Expand All @@ -16,6 +16,12 @@ endif (POLICY CMP0022)
if (POLICY CMP0023)
cmake_policy(SET CMP0023 OLD)
endif (POLICY CMP0023)
if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")

Expand Down Expand Up @@ -182,7 +188,6 @@ if(LINUX)

find_package(aio REQUIRED)
set(HAVE_LIBAIO ${AIO_FOUND})
message(STATUS "${AIO_LIBS}")

find_package(blkid REQUIRED)
set(HAVE_BLKID ${BLKID_FOUND})
Expand Down Expand Up @@ -301,17 +306,17 @@ else ()
endif (${WITH_NSS})

option(WITH_SSL "SSL build selected" ON)
if (${USE_NSS})
if(USE_NSS)
#nss
set(SSL_LIBRARIES ${NSS_LIBRARIES})
message(STATUS "SSL with NSS selected (Libs: ${SSL_LIBRARIES})")
else (${USE_NSS})
else(USE_NSS)
#openssl
find_package(OpenSSL REQUIRED)
set(HAVE_OPENSSL ON)
set(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
message(STATUS "SSL with OpenSSL selected (Libs: ${SSL_LIBRARIES})")
endif(${USE_NSS})
endif(USE_NSS)

option(WITH_XIO "Enable XIO messaging" OFF)
if(WITH_XIO)
Expand Down
165 changes: 13 additions & 152 deletions cmake/modules/Findfuse.cmake
Original file line number Diff line number Diff line change
@@ -1,167 +1,28 @@
# This module can find FUSE Library
#
# Requirements:
# - CMake >= 2.8.3
#
# The following variables will be defined for your use:
# - FUSE_FOUND : was FUSE found?
# - FUSE_INCLUDE_DIRS : FUSE include directory
# - FUSE_LIBRARIES : FUSE library
# - FUSE_DEFINITIONS : FUSE cflags
# - FUSE_VERSION : complete version of FUSE (major.minor)
# - FUSE_MAJOR_VERSION : major version of FUSE
# - FUSE_MINOR_VERSION : minor version of FUSE
#
# Example Usage:
#
# 1. Copy this file in the root of your project source directory
# 2. Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt:
# set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
# 3. Finally call find_package() once, here are some examples to pick from
#
# Require FUSE 2.6 or later
# find_package(FUSE 2.6 REQUIRED)
#
# if(FUSE_FOUND)
# add_definitions(${FUSE_DEFINITIONS})
# include_directories(${FUSE_INCLUDE_DIRS})
# add_executable(myapp myapp.c)
# target_link_libraries(myapp ${FUSE_LIBRARIES})
# endif()

#=============================================================================
# Copyright (c) 2012, julp
#
# Distributed under the OSI-approved BSD License
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#=============================================================================

cmake_minimum_required(VERSION 2.8.3)

########## Private ##########
function(fusedebug _varname)
if(FUSE_DEBUG)
message("${_varname} = ${${_varname}}")
endif(FUSE_DEBUG)
endfunction(fusedebug)

########## Public ##########
set(FUSE_FOUND TRUE)
set(FUSE_LIBRARIES )
set(FUSE_DEFINITIONS )
set(FUSE_INCLUDE_DIRS )

find_package(PkgConfig)

set(PC_FUSE_INCLUDE_DIRS )
set(PC_FUSE_LIBRARY_DIRS )
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_FUSE "fuse" QUIET)
if(PC_FUSE_FOUND)
# fusedebug(PC_FUSE_LIBRARIES)
# fusedebug(PC_FUSE_LIBRARY_DIRS)
# fusedebug(PC_FUSE_LDFLAGS)
# fusedebug(PC_FUSE_LDFLAGS_OTHER)
# fusedebug(PC_FUSE_INCLUDE_DIRS)
# fusedebug(PC_FUSE_CFLAGS)
# fusedebug(PC_FUSE_CFLAGS_OTHER)
set(FUSE_DEFINITIONS "${PC_FUSE_CFLAGS_OTHER}")
endif(PC_FUSE_FOUND)
endif(PKG_CONFIG_FOUND)

find_path(
FUSE_INCLUDE_DIRS
NAMES fuse_common.h fuse_lowlevel.h fuse.h
PATHS "${PC_FUSE_INCLUDE_DIRS}"
DOC "Include directories for FUSE"
)

if(NOT FUSE_INCLUDE_DIRS)
set(FUSE_FOUND FALSE)
endif(NOT FUSE_INCLUDE_DIRS)

find_library(
FUSE_LIBRARIES
NAMES "fuse"
PATHS "${PC_FUSE_LIBRARY_DIRS}"
DOC "Libraries for FUSE"
)
PATHS /usr/local/include/osxfuse /usr/local/include
PATH_SUFFIXES fuse)

if(NOT FUSE_LIBRARIES)
set(FUSE_FOUND FALSE)
endif(NOT FUSE_LIBRARIES)
set(fuse_names fuse)
if(APPLE)
list(APPEND fuse_names libosxfuse.dylib)
endif()

if(FUSE_FOUND)
if(EXISTS "${FUSE_INCLUDE_DIRS}/fuse_common.h")
file(READ "${FUSE_INCLUDE_DIRS}/fuse_common.h" _contents)
string(REGEX REPLACE ".*# *define *FUSE_MAJOR_VERSION *([0-9]+).*" "\\1" FUSE_MAJOR_VERSION "${_contents}")
string(REGEX REPLACE ".*# *define *FUSE_MINOR_VERSION *([0-9]+).*" "\\1" FUSE_MINOR_VERSION "${_contents}")
set(FUSE_VERSION "${FUSE_MAJOR_VERSION}.${FUSE_MINOR_VERSION}")
endif()
find_library(FUSE_LIBRARIES
NAMES ${fuse_names}
PATHS /usr/local/lib64 /usr/local/lib)

include(CheckCSourceCompiles)
# Backup CMAKE_REQUIRED_*
set(OLD_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
set(OLD_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
set(OLD_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
# Add FUSE compilation flags
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}" "${FUSE_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" "${FUSE_LIBRARIES}")
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" "${FUSE_DEFINITIONS}")
check_c_source_compiles("#include <stdlib.h>
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
int main(void) {
return 0;
}" FUSE_CFLAGS_CHECK)
if(NOT FUSE_CFLAGS_CHECK)
set(FUSE_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
# Should we run again previous test to assume the failure was due to missing definition -D_FILE_OFFSET_BITS=64?
endif(NOT FUSE_CFLAGS_CHECK)
# Restore CMAKE_REQUIRED_*
set(CMAKE_REQUIRED_INCLUDES "${OLD_CMAKE_REQUIRED_INCLUDES}")
set(CMAKE_REQUIRED_LIBRARIES "${OLD_CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_DEFINITIONS "${OLD_CMAKE_REQUIRED_DEFINITIONS}")
endif(FUSE_FOUND)

if(FUSE_INCLUDE_DIRS)
include(FindPackageHandleStandardArgs)
if(FUSE_FIND_REQUIRED AND NOT FUSE_FIND_QUIETLY)
find_package_handle_standard_args(FUSE REQUIRED_VARS FUSE_LIBRARIES FUSE_INCLUDE_DIRS VERSION_VAR FUSE_VERSION)
else()
find_package_handle_standard_args(FUSE "FUSE not found" FUSE_LIBRARIES FUSE_INCLUDE_DIRS)
endif()
else(FUSE_INCLUDE_DIRS)
if(FUSE_FIND_REQUIRED AND NOT FUSE_FIND_QUIETLY)
message(FATAL_ERROR "Could not find FUSE include directory")
endif()
endif(FUSE_INCLUDE_DIRS)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FUSE DEFAULT_MSG
FUSE_INCLUDE_DIRS FUSE_LIBRARIES)

mark_as_advanced(
FUSE_INCLUDE_DIRS
FUSE_LIBRARIES
)

# IN (args)
fusedebug("FUSE_FIND_COMPONENTS")
fusedebug("FUSE_FIND_REQUIRED")
fusedebug("FUSE_FIND_QUIETLY")
fusedebug("FUSE_FIND_VERSION")
# OUT
# Found
fusedebug("FUSE_FOUND")
# Definitions
fusedebug("FUSE_DEFINITIONS")
# Linking
fusedebug("FUSE_INCLUDE_DIRS")
fusedebug("FUSE_LIBRARIES")
# Version
fusedebug("FUSE_MAJOR_VERSION")
fusedebug("FUSE_MINOR_VERSION")
fusedebug("FUSE_VERSION")
FUSE_INCLUDE_DIRS FUSE_LIBRARIES)
12 changes: 6 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ else(INTEL_SSE4_1)
endif(INTEL_SSE4_1)


set(EXTRALIBS uuid rt ${CMAKE_DL_LIBS} ${ATOMIC_OPS_LIBRARIES})
set(EXTRALIBS rt ${CMAKE_DL_LIBS} ${ATOMIC_OPS_LIBRARIES})

option(WITH_PROFILER "build extra profiler binaries" OFF)
if(WITH_PROFILER)
Expand Down Expand Up @@ -506,7 +506,9 @@ endif(ENABLE_SHARED)
add_library(common STATIC ${libcommon_files}
$<TARGET_OBJECTS:mon_common_objs>
$<TARGET_OBJECTS:common_mountcephfs_objs>)
target_link_libraries(common ${CRYPTO_LIBS} ${CMAKE_DL_LIBS})
target_link_libraries(common json_spirit erasure_code rt resolv
${Boost_LIBRARIES} ${BLKID_LIBRARIES} ${Backtrace_LIBRARIES}
${CRYPTO_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})

set_source_files_properties(${CMAKE_SOURCE_DIR}/src/ceph_ver.c
${CMAKE_SOURCE_DIR}/src/common/version.cc
Expand All @@ -521,8 +523,6 @@ endif(HAVE_ARMV8_CRC)

add_library(common_utf8 STATIC common/utf8.c)

target_link_libraries(common json_spirit erasure_code rt uuid resolv ${CRYPTO_LIBS} ${Boost_LIBRARIES} ${BLKID_LIBRARIES} ${Backtrace_LIBRARIES})

if(${WITH_LTTNG})
add_subdirectory(tracing)
endif(${WITH_LTTNG})
Expand Down Expand Up @@ -586,9 +586,9 @@ if(${WITH_RADOSGW})
cls_user_client
cls_statelog_client
cls_rgw_client
curl
expat
fcgi
${CURL_LIBRARIES}
${EXPAT_LIBRARIES}
)
endif(${WITH_RADOSGW})
if(${WITH_RBD})
Expand Down
1 change: 1 addition & 0 deletions src/cls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if (WITH_RBD)
install(TARGETS cls_rbd DESTINATION ${cls_dir})

add_library(cls_rbd_client STATIC rbd/cls_rbd_client.cc rbd/cls_rbd_types.cc)
target_link_libraries(cls_rbd_client cls_lock_client)
endif (WITH_RBD)

# cls_lock
Expand Down
2 changes: 1 addition & 1 deletion src/erasure-code/jerasure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ add_library(ec_jerasure_generic SHARED
$<TARGET_OBJECTS:erasure_code_objs>
)
add_dependencies(ec_jerasure_generic ${CMAKE_SOURCE_DIR}/src/ceph_ver.h)
target_link_libraries(ec_jerasure_generic crush ${EXTRALIBS})
target_link_libraries(ec_jerasure_generic ${EXTRALIBS})
set_target_properties(ec_jerasure_generic PROPERTIES VERSION 2.0.0 SOVERSION 2)
install(TARGETS ec_jerasure_generic DESTINATION ${erasure_plugin_dir})

Expand Down
2 changes: 1 addition & 1 deletion src/global/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set(global_common_files
add_library(global_common_objs OBJECT ${global_common_files})
add_library(global STATIC ${libglobal_srcs}
$<TARGET_OBJECTS:global_common_objs>)
target_link_libraries(global common ${CMAKE_THREAD_LIBS_INIT} ${EXTRALIBS})
target_link_libraries(global common ${EXTRALIBS})
1 change: 1 addition & 0 deletions src/journal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ set(journal_srcs
ObjectRecorder.cc
Utils.cc)
add_library(journal STATIC ${journal_srcs})
target_link_libraries(journal cls_journal_client)
3 changes: 2 additions & 1 deletion src/librbd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ if(ENABLE_SHARED)
OUTPUT_NAME rbd
VERSION 1.0.0
SOVERSION 1
COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden"
LINK_FLAGS "-Wl,--exclude-libs,ALL")
endif(ENABLE_SHARED)
install(TARGETS librbd DESTINATION ${CMAKE_INSTALL_LIBDIR})
2 changes: 1 addition & 1 deletion src/rbd_fuse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(rbd-fuse
rbd-fuse.cc)
target_link_libraries(rbd-fuse
librbd librados ${FUSE_LIBRARIES})
librbd librados common ${FUSE_LIBRARIES})
install(TARGETS rbd-fuse DESTINATION bin)
19 changes: 13 additions & 6 deletions src/rgw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ add_library(rgw_a STATIC ${rgw_a_srcs})
target_include_directories(rgw_a PUBLIC ${FCGI_INCLUDE_DIR})
target_link_libraries(rgw_a librados cls_lock_client cls_rgw_client cls_refcount_client
cls_log_client cls_statelog_client cls_timeindex_client cls_version_client
cls_replica_log_client cls_user_client common common_utf8 curl global expat
cls_replica_log_client cls_user_client common common_utf8 global
${CURL_LIBRARIES}
${EXPAT_LIBRARIES}
${OPENLDAP_LIBRARIES} ${CRYPTO_LIBS})

set(radosgw_srcs
Expand All @@ -107,7 +109,8 @@ target_link_libraries(radosgw rgw_a librados
cls_rgw_client cls_lock_client cls_refcount_client
cls_log_client cls_statelog_client cls_timeindex_client
cls_version_client cls_replica_log_client cls_user_client
curl expat global fcgi resolv ${SSL_LIBRARIES} ${BLKID_LIBRARIES}
global fcgi resolv
${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${SSL_LIBRARIES} ${BLKID_LIBRARIES}
${ALLOC_LIBS})
# radosgw depends on cls libraries at runtime, but not as link dependencies
add_dependencies(radosgw cls_rgw cls_lock cls_refcount
Expand All @@ -123,7 +126,8 @@ target_link_libraries(radosgw-admin rgw_a librados
cls_rgw_client cls_lock_client cls_refcount_client
cls_log_client cls_statelog_client cls_timeindex_client
cls_version_client cls_replica_log_client cls_user_client
curl expat global fcgi resolv ${SSL_LIBRARIES} ${BLKID_LIBRARIES})
global fcgi resolv
${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${SSL_LIBRARIES} ${BLKID_LIBRARIES})
install(TARGETS radosgw-admin DESTINATION bin)

set(radosgw_token_srcs
Expand All @@ -140,7 +144,8 @@ target_link_libraries(radosgw-object-expirer rgw_a librados
cls_rgw_client cls_lock_client cls_refcount_client
cls_log_client cls_statelog_client cls_timeindex_client
cls_version_client cls_replica_log_client cls_user_client
curl expat global fcgi resolv)
global fcgi resolv
${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
install(TARGETS radosgw-object-expirer DESTINATION bin)

set(librgw_srcs
Expand All @@ -159,8 +164,10 @@ target_link_libraries(rgw LINK_PRIVATE
cls_version_client
cls_replica_log_client
cls_user_client
curl expat global
resolv)
global
resolv
${CURL_LIBRARIES}
${EXPAT_LIBRARIES})
set_target_properties(rgw PROPERTIES OUTPUT_NAME rgw VERSION 2.0.0
SOVERSION 1)
install(TARGETS rgw DESTINATION ${CMAKE_INSTALL_LIBDIR})

0 comments on commit 00b6fe1

Please sign in to comment.