From 417c54f1ef58c575267bd2dc11b2f9675f535007 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 11:27:34 +0800 Subject: [PATCH 1/9] cmake: exclude private symbols in librbd missed it in 0edfad0. * librbd: pass '--exclude-libs,ALL' to linker * rbd: link against used libraries explicitly, rbd is accessing some internal symbols not exposed by librbd. Signed-off-by: Kefu Chai --- src/cls/CMakeLists.txt | 1 + src/journal/CMakeLists.txt | 1 + src/librbd/CMakeLists.txt | 3 ++- src/rbd_fuse/CMakeLists.txt | 2 +- src/test/librbd/CMakeLists.txt | 1 + src/tools/rbd/CMakeLists.txt | 7 ++++++- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cls/CMakeLists.txt b/src/cls/CMakeLists.txt index 659662726c855..185da04f7f8c5 100644 --- a/src/cls/CMakeLists.txt +++ b/src/cls/CMakeLists.txt @@ -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 diff --git a/src/journal/CMakeLists.txt b/src/journal/CMakeLists.txt index e5337127200d1..50b8c307cb28b 100644 --- a/src/journal/CMakeLists.txt +++ b/src/journal/CMakeLists.txt @@ -12,3 +12,4 @@ set(journal_srcs ObjectRecorder.cc Utils.cc) add_library(journal STATIC ${journal_srcs}) +target_link_libraries(journal cls_journal_client) diff --git a/src/librbd/CMakeLists.txt b/src/librbd/CMakeLists.txt index a08f17d61377e..216f76d666f5c 100644 --- a/src/librbd/CMakeLists.txt +++ b/src/librbd/CMakeLists.txt @@ -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}) diff --git a/src/rbd_fuse/CMakeLists.txt b/src/rbd_fuse/CMakeLists.txt index efeda706cc8a5..61a02d3ad0e8f 100644 --- a/src/rbd_fuse/CMakeLists.txt +++ b/src/rbd_fuse/CMakeLists.txt @@ -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) diff --git a/src/test/librbd/CMakeLists.txt b/src/test/librbd/CMakeLists.txt index 560ec50e4eebd..ad2cf9488ce24 100644 --- a/src/test/librbd/CMakeLists.txt +++ b/src/test/librbd/CMakeLists.txt @@ -133,6 +133,7 @@ add_executable(ceph_test_librbd_fsx target_link_libraries(ceph_test_librbd_fsx librbd librados + journal global m ${CMAKE_DL_LIBS} diff --git a/src/tools/rbd/CMakeLists.txt b/src/tools/rbd/CMakeLists.txt index 36c7303b45ff4..42d3a5d0e5b32 100644 --- a/src/tools/rbd/CMakeLists.txt +++ b/src/tools/rbd/CMakeLists.txt @@ -42,7 +42,12 @@ add_executable(rbd ${rbd_srcs} $ $) set_target_properties(rbd PROPERTIES OUTPUT_NAME rbd) -target_link_libraries(rbd librbd librados global common keyutils udev +target_link_libraries(rbd librbd librados + cls_journal_client cls_rbd_client + rbd_types + journal + common global + keyutils udev ${Boost_REGEX_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) install(TARGETS rbd DESTINATION bin) From 998a50627f72d536b21e2cd1129d22b3ebd5d267 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 11:38:46 +0800 Subject: [PATCH 2/9] cmake: do not link ec_jerasure_generic against crush crush is not used in erasure plugins at this moment. Signed-off-by: Kefu Chai --- src/erasure-code/jerasure/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/erasure-code/jerasure/CMakeLists.txt b/src/erasure-code/jerasure/CMakeLists.txt index da28a4ac5a8e6..fe4d9e1dfb395 100644 --- a/src/erasure-code/jerasure/CMakeLists.txt +++ b/src/erasure-code/jerasure/CMakeLists.txt @@ -31,7 +31,7 @@ add_library(ec_jerasure_generic SHARED $ ) 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}) From ce1d2e47ed2f060b340eeb2db76effc87e87fb87 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 12:11:14 +0800 Subject: [PATCH 3/9] cmake: remove uuid as it is replaced by the boost implementation, and not detected in cmake anymore. Signed-off-by: Kefu Chai --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ed57d665fde0..e457b84b7ab1a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) @@ -521,7 +521,7 @@ 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}) +target_link_libraries(common json_spirit erasure_code rt resolv ${CRYPTO_LIBS} ${Boost_LIBRARIES} ${BLKID_LIBRARIES} ${Backtrace_LIBRARIES}) if(${WITH_LTTNG}) add_subdirectory(tracing) From 221c47d34951100d4b0399100736683aae9db160 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 12:24:14 +0800 Subject: [PATCH 4/9] cmake: set policies this makes sure we are compatible with latest and future cmake Signed-off-by: Kefu Chai --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6014a5ba22890..3542554076e1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. @@ -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/") From 7296be4e84d90c1350aef277cdf37b43fdde5082 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 12:25:50 +0800 Subject: [PATCH 5/9] cmake: use fullpaths of libraries better off using the detected path, instead of using the default path for finding the linked libaries. see "cmake --help-policy CMP0065" for more details. Signed-off-by: Kefu Chai --- src/CMakeLists.txt | 4 ++-- src/rgw/CMakeLists.txt | 19 +++++++++++++------ src/test/CMakeLists.txt | 18 +++++++++--------- src/test/rgw/CMakeLists.txt | 11 +++++------ 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e457b84b7ab1a..92feff535ea9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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}) diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 92187570459bd..0be612ace066a 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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}) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 38ffbda0ab421..8e3a1e987b500 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -86,7 +86,7 @@ endif(${WITH_RADOSGW}) # From src/test/Makefile-client.am: I dont get this one... testing the osdc build but link in libcephfs? add_executable(test_build_libcephfs buildtest_skeleton.cc) -target_link_libraries(test_build_libcephfs cephfs expat pthread ${CRYPTO_LIBS} ${EXTRALIBS}) +target_link_libraries(test_build_libcephfs cephfs pthread ${CRYPTO_LIBS} ${EXTRALIBS}) add_executable(test_build_librados buildtest_skeleton.cc) target_link_libraries(test_build_librados librados pthread ${CRYPTO_LIBS} ${EXTRALIBS} osdc osd os common cls_lock_client ${BLKID_LIBRARIES}) @@ -155,9 +155,9 @@ if(${WITH_RADOSGW}) librados rgw_a global - curl - expat ${BLKID_LIBRARIES} + ${CURL_LIBRARIES} + ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS}) set_target_properties(test_cors PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) @@ -171,8 +171,6 @@ if(${WITH_RADOSGW}) librados rgw_a global - curl - expat cls_version_client cls_log_client cls_statelog_client @@ -182,6 +180,8 @@ if(${WITH_RADOSGW}) cls_lock_client ${Boost_REGEX_LIBRARY} ${BLKID_LIBRARIES} + ${CURL_LIBRARIES} + ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS} ${CRYPTO_LIBS}) set_target_properties(ceph_test_cls_rgw_meta PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) @@ -201,8 +201,6 @@ if(${WITH_RADOSGW}) librados rgw_a global - curl - expat cls_version_client cls_log_client cls_statelog_client @@ -212,6 +210,8 @@ if(${WITH_RADOSGW}) cls_lock_client ${Boost_REGEX_LIBRARY} ${BLKID_LIBRARIES} + ${CURL_LIBRARIES} + ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS} ${EXTRALIBS} @@ -237,9 +237,9 @@ if(${WITH_RADOSGW}) cls_user_client cls_lock_client global - curl - expat ${BLKID_LIBRARIES} + ${CURL_LIBRARIES} + ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS} ${CRYPTO_LIBS} diff --git a/src/test/rgw/CMakeLists.txt b/src/test/rgw/CMakeLists.txt index f4797442836f6..0aad7ae8bbde4 100644 --- a/src/test/rgw/CMakeLists.txt +++ b/src/test/rgw/CMakeLists.txt @@ -31,9 +31,9 @@ target_link_libraries(ceph_test_rgw_manifest cls_user_client librados global - curl - expat ${BLKID_LIBRARIES} + ${CURL_LIBRARIES} + ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS} ${CRYPTO_LIBS} @@ -58,12 +58,11 @@ target_link_libraries(ceph_test_rgw_obj cls_user_client librados global - curl - uuid - expat + ${CURL_LIBRARIES} + ${EXPAT_LIBRARIES} ${CMAKE_DL_LIBS} ${UNITTEST_LIBS} ${CRYPTO_LIBS} ) set_target_properties(ceph_test_rgw_obj PROPERTIES COMPILE_FLAGS - ${UNITTEST_CXX_FLAGS}) \ No newline at end of file + ${UNITTEST_CXX_FLAGS}) From aa524e689dd9f8f4816405cf97e6422912d91068 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 12:48:23 +0800 Subject: [PATCH 6/9] cmake: remove duplicated linked lib for libcommon Signed-off-by: Kefu Chai --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92feff535ea9c..463d0d3c2e334 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -506,7 +506,9 @@ endif(ENABLE_SHARED) add_library(common STATIC ${libcommon_files} $ $) -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_DL_LIBS}) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/ceph_ver.c ${CMAKE_SOURCE_DIR}/src/common/version.cc @@ -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 resolv ${CRYPTO_LIBS} ${Boost_LIBRARIES} ${BLKID_LIBRARIES} ${Backtrace_LIBRARIES}) - if(${WITH_LTTNG}) add_subdirectory(tracing) endif(${WITH_LTTNG}) From 8bac1c1eeb22eb96676b97c32883e44da5c9ab4f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 12:48:51 +0800 Subject: [PATCH 7/9] cmake: do not reference undefined variables * AIO_LIBS is now named AIO_LIBARIES, and there is not point to print out its path * USE_NSS is not defined if NSS is not checked, so if(USE_NSS) is better here. Signed-off-by: Kefu Chai --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3542554076e1d..7edf4566bdd40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,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}) @@ -307,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) From 8bf5cd1606b9c65d6e86a8a6af085b0bd86888aa Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jul 2016 13:25:57 +0800 Subject: [PATCH 8/9] cmake: cleanup Findfuse.cmake * remove unused stuff, we do not pass/use FUSE_VERSION in cmake. the FUSE_VERSION we are using is defined by "fuse_common.h". * use FindPackageHandleStandardArgs for handling find_package() arguments. * also detect osxfuse on MacOS. Signed-off-by: Kefu Chai --- cmake/modules/Findfuse.cmake | 165 +++-------------------------------- 1 file changed, 13 insertions(+), 152 deletions(-) diff --git a/cmake/modules/Findfuse.cmake b/cmake/modules/Findfuse.cmake index dd8a6c17faef2..58c50cb9808e3 100644 --- a/cmake/modules/Findfuse.cmake +++ b/cmake/modules/Findfuse.cmake @@ -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 -#include -#include -#include -#include -#include - -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) From a27bbaaebf1391e41495f33d66237bcf485e332b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 30 Jul 2016 00:26:43 +0800 Subject: [PATCH 9/9] cmake: link libcommon against pthread as Thread.cc lives in libcommon, and global is not using libpthread directly. so moving libpthread linkage from libglobal to libcommon. Signed-off-by: Kefu Chai --- src/CMakeLists.txt | 2 +- src/global/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 463d0d3c2e334..5a7e6126b9fa5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -508,7 +508,7 @@ add_library(common STATIC ${libcommon_files} $) target_link_libraries(common json_spirit erasure_code rt resolv ${Boost_LIBRARIES} ${BLKID_LIBRARIES} ${Backtrace_LIBRARIES} - ${CRYPTO_LIBS} ${CMAKE_DL_LIBS}) + ${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 diff --git a/src/global/CMakeLists.txt b/src/global/CMakeLists.txt index 7cbee098d977f..f9a1c264ed32b 100644 --- a/src/global/CMakeLists.txt +++ b/src/global/CMakeLists.txt @@ -7,4 +7,4 @@ set(global_common_files add_library(global_common_objs OBJECT ${global_common_files}) add_library(global STATIC ${libglobal_srcs} $) -target_link_libraries(global common ${CMAKE_THREAD_LIBS_INIT} ${EXTRALIBS}) +target_link_libraries(global common ${EXTRALIBS})