From 7dd82bbeb149c75e3f7b936f16144194405bfd7d Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 28 Jul 2018 01:51:20 +0800 Subject: [PATCH] cmake: extract mount.ceph into src/mount Signed-off-by: Kefu Chai --- cmake/modules/Findkeyutils.cmake | 22 +++++++++++----------- src/CMakeLists.txt | 14 ++------------ src/mount/CMakeLists.txt | 9 +++++++++ 3 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 src/mount/CMakeLists.txt diff --git a/cmake/modules/Findkeyutils.cmake b/cmake/modules/Findkeyutils.cmake index e34be8b5eb4..d88bc078234 100644 --- a/cmake/modules/Findkeyutils.cmake +++ b/cmake/modules/Findkeyutils.cmake @@ -5,23 +5,23 @@ # KEYUTILS_INCLUDE_DIR - the keyutils include directories # KEYUTILS_LIBRARIES - link these to use keyutils -if(KEYUTILS_INCLUDE_DIR AND KEYUTILS_LIBRARIES) - set(KEYUTILS_FIND_QUIETLY TRUE) -endif(KEYUTILS_INCLUDE_DIR AND KEYUTILS_LIBRARIES) - -# include dir find_path(KEYUTILS_INCLUDE_DIR keyutils.h PATHS /opt/local/include /usr/local/include ) -# finally the library itself -find_library(LIBKEYUTILS NAMES keyutils) -set(KEYUTILS_LIBRARIES ${LIBKEYUTILS}) +find_library(KEYUTILS_LIBRARIES NAMES keyutils) -# handle the QUIETLY and REQUIRED arguments and set KEYUTILS_FOUND to TRUE if -# all listed variables are TRUE include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(keyutils DEFAULT_MSG KEYUTILS_LIBRARIES KEYUTILS_INCLUDE_DIR) +find_package_handle_standard_args(keyutils + DEFAULT_MSG KEYUTILS_LIBRARIES KEYUTILS_INCLUDE_DIR) mark_as_advanced(KEYUTILS_LIBRARIES KEYUTILS_INCLUDE_DIR) + +if(KEYUTILS_FOUND AND NOT (TARGET keyutils::keyutils)) + add_library(keyutils::keyutils UNKNOWN IMPORTED) + set_target_properties(keyutils::keyutils PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${KEYUTILS_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${KEYUTILS_LIBRARIES}") +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3c0a5ef1a8..292b0d9404b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -636,18 +636,8 @@ if(WITH_LIBCEPHFS) client/SyntheticClient.cc) add_executable(ceph-syn ${ceph_syn_srcs}) target_link_libraries(ceph-syn client global-static ceph-common) - - set(mount_ceph_srcs - mount/mount.ceph.c) - add_executable(mount.ceph ${mount_ceph_srcs} - $ - $) - set_target_properties(mount.ceph PROPERTIES - INSTALL_RPATH "") - target_link_libraries(mount.ceph ${KEYUTILS_LIBRARIES}) - install(TARGETS ceph-syn DESTINATION bin) - install(TARGETS mount.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR}) + add_subdirectory(mount) endif(WITH_LIBCEPHFS) if(WITH_FUSE) @@ -668,7 +658,7 @@ if(WITH_RBD) if(WITH_KRBD) add_library(krbd STATIC krbd.cc $) - target_link_libraries(krbd ${KEYUTILS_LIBRARIES}) + target_link_libraries(krbd keyutils::keyutils) endif() add_subdirectory(librbd) if(WITH_FUSE) diff --git a/src/mount/CMakeLists.txt b/src/mount/CMakeLists.txt new file mode 100644 index 00000000000..6ff26174461 --- /dev/null +++ b/src/mount/CMakeLists.txt @@ -0,0 +1,9 @@ +set(mount_ceph_srcs + mount.ceph.c) +add_executable(mount.ceph ${mount_ceph_srcs} + $ + $) +set_target_properties(mount.ceph PROPERTIES + INSTALL_RPATH "") +target_link_libraries(mount.ceph keyutils::keyutils) +install(TARGETS mount.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR})