From b823952d245db4967828033003729a643d8e276f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 17 Apr 2020 13:46:21 +0800 Subject: [PATCH] cmake: link against FUSE::FUSE instead of specifying the include directory and linkage separately Signed-off-by: Kefu Chai --- cmake/modules/FindFUSE.cmake | 11 +++++++++++ src/CMakeLists.txt | 5 ++--- src/os/CMakeLists.txt | 3 +-- src/rbd_fuse/CMakeLists.txt | 2 +- src/tools/CMakeLists.txt | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cmake/modules/FindFUSE.cmake b/cmake/modules/FindFUSE.cmake index 58c50cb9808..73fef22d7b3 100644 --- a/cmake/modules/FindFUSE.cmake +++ b/cmake/modules/FindFUSE.cmake @@ -26,3 +26,14 @@ find_package_handle_standard_args(FUSE DEFAULT_MSG mark_as_advanced( FUSE_INCLUDE_DIRS FUSE_LIBRARIES) + +if(FUSE_FOUND) + if(NOT TARGET FUSE::FUSE) + add_library(FUSE::FUSE UNKNOWN IMPORTED) + set_target_properties(FUSE::FUSE PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FUSE_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${FUSE_LIBRARIES}" + VERSION "${FUSE_VERSION}") + endif() +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 23fc2b80d91..b77f77c9c6a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -552,7 +552,7 @@ add_dependencies(ceph-osd erasure_code_plugins) target_link_libraries(ceph-osd osd os global-static common ${BLKID_LIBRARIES}) if(WITH_FUSE) - target_link_libraries(ceph-osd ${FUSE_LIBRARIES}) + target_link_libraries(ceph-osd FUSE::FUSE) endif() set_target_properties(ceph-osd PROPERTIES POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE} @@ -705,10 +705,9 @@ if(WITH_FUSE) ceph_fuse.cc client/fuse_ll.cc) add_executable(ceph-fuse ${ceph_fuse_srcs}) - target_link_libraries(ceph-fuse ${FUSE_LIBRARIES} + target_link_libraries(ceph-fuse FUSE::FUSE ${GSSAPI_LIBRARIES} client ceph-common global-static ${EXTRALIBS}) set_target_properties(ceph-fuse PROPERTIES - COMPILE_FLAGS "-I${FUSE_INCLUDE_DIRS}" POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE}) install(TARGETS ceph-fuse DESTINATION bin) install(PROGRAMS mount.fuse.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR}) diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index 3eb03cbe9e8..760244b9b43 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -93,8 +93,7 @@ if(HAVE_LIBAIO) endif(HAVE_LIBAIO) if(WITH_FUSE) - target_include_directories(os SYSTEM PRIVATE ${FUSE_INCLUDE_DIRS}) - target_link_libraries(os ${FUSE_LIBRARIES}) + target_link_libraries(os FUSE::FUSE) endif() if(HAVE_LIBZFS) diff --git a/src/rbd_fuse/CMakeLists.txt b/src/rbd_fuse/CMakeLists.txt index e0bd3e2497d..f83f97a3f7d 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 - ceph-common librbd librados global ${FUSE_LIBRARIES}) + ceph-common librbd librados global FUSE::FUSE) install(TARGETS rbd-fuse DESTINATION bin) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 0f8120a7775..8cccf208dfd 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -50,7 +50,7 @@ add_executable(ceph-objectstore-tool RadosDump.cc) target_link_libraries(ceph-objectstore-tool osd os global Boost::program_options ${CMAKE_DL_LIBS}) if(WITH_FUSE) - target_link_libraries(ceph-objectstore-tool ${FUSE_LIBRARIES}) + target_link_libraries(ceph-objectstore-tool FUSE::FUSE) endif(WITH_FUSE) install(TARGETS ceph-objectstore-tool DESTINATION bin) -- 2.39.5