diff options
author | Kefu Chai <kchai@redhat.com> | 2020-04-17 07:50:16 +0200 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2020-04-17 08:10:55 +0200 |
commit | 220fa91d80175daa045022d9df50a1e44e5aebe9 (patch) | |
tree | 36645fcc46436f0fc551c2a99d8a886c856d553b /cmake/modules/FindFUSE.cmake | |
parent | cmake: link against FUSE::FUSE (diff) | |
download | ceph-220fa91d80175daa045022d9df50a1e44e5aebe9.tar.xz ceph-220fa91d80175daa045022d9df50a1e44e5aebe9.zip |
cmake: check for FUSE version
and refactor FindFUSE.cmake a little bit to conditionalize OSX support
Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'cmake/modules/FindFUSE.cmake')
-rw-r--r-- | cmake/modules/FindFUSE.cmake | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/cmake/modules/FindFUSE.cmake b/cmake/modules/FindFUSE.cmake index 73fef22d7b3..3578a088c69 100644 --- a/cmake/modules/FindFUSE.cmake +++ b/cmake/modules/FindFUSE.cmake @@ -4,30 +4,44 @@ # - FUSE_FOUND : was FUSE found? # - FUSE_INCLUDE_DIRS : FUSE include directory # - FUSE_LIBRARIES : FUSE library - -find_path( - FUSE_INCLUDE_DIRS - NAMES fuse_common.h fuse_lowlevel.h fuse.h - PATHS /usr/local/include/osxfuse /usr/local/include - PATH_SUFFIXES fuse) +# - FUSE_VERSION : the version of the FUSE library found set(fuse_names fuse) +set(fuse_suffixes fuse) + if(APPLE) list(APPEND fuse_names libosxfuse.dylib) + list(APPEND fuse_suffixes osxfuse) endif() +find_path( + FUSE_INCLUDE_DIR + NAMES fuse_common.h fuse_lowlevel.h fuse.h + PATH_SUFFIXES ${fuse_suffixes}) + find_library(FUSE_LIBRARIES NAMES ${fuse_names} PATHS /usr/local/lib64 /usr/local/lib) +foreach(ver "MAJOR" "MINOR") + file(STRINGS "${FUSE_INCLUDE_DIR}/fuse_common.h" fuse_ver_${ver}_line + REGEX "^#define[\t ]+FUSE_${ver}_VERSION[\t ]+[0-9]+$") + string(REGEX REPLACE ".*#define[\t ]+FUSE_${ver}_VERSION[\t ]+([0-9]+)$" + "\\1" FUSE_VERSION_${ver} "${fuse_ver_${ver}_line}") +endforeach() +set(FUSE_VERSION + "${FUSE_VERSION_MAJOR}.${FUSE_VERSION_MINOR}") + include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FUSE DEFAULT_MSG - FUSE_INCLUDE_DIRS FUSE_LIBRARIES) +find_package_handle_standard_args(FUSE + REQUIRED_VARS FUSE_LIBRARIES FUSE_INCLUDE_DIR + VERSION_VAR FUSE_VERSION) mark_as_advanced( - FUSE_INCLUDE_DIRS FUSE_LIBRARIES) + FUSE_INCLUDE_DIR) if(FUSE_FOUND) + set(FUSE_INCLUDE_DIRS ${FUSE_INCLUDE_DIR}) if(NOT TARGET FUSE::FUSE) add_library(FUSE::FUSE UNKNOWN IMPORTED) set_target_properties(FUSE::FUSE PROPERTIES |