ceph/cmake/modules/FindLinuxZNS.cmake
Kefu Chai 76c35c6dd9 cmake: detect linux/blk/zoned support
* add find_package() support for detecting the existence of
  linux/blkzoned.h before using it.
* link against Linux::ZNS for adding the compilation definition of
  HAVE_ZNS instead of including it in the global config.h
* move the CMake option closer to where it is used for
  better readability. as this option takes effect only if
  crimson is compiled.
* make WITH_ZNS an option which depends on the value of
  CMAKE_SYSTEM_NAME. it is hidden and off if CMAKE_SYSTEM_NAME
  is not "Linux".

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2021-12-25 16:13:47 +08:00

19 lines
471 B
CMake

# Try to find linux/blkzoned.h
find_path(LinuxZNS_INCLUDE_DIR NAMES
"linux/blkzoned.h")
find_package_handle_standard_args(LinuxZNS
REQUIRED_VARS
LinuxZNS_INCLUDE_DIR)
mark_as_advanced(
LinuxZNS_INCLUDE_DIR)
if(LinuxZNS_FOUND AND NOT (TARGET Linux::ZNS))
add_library(Linux::ZNS INTERFACE IMPORTED)
set_target_properties(Linux::ZNS PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LinuxZNS_INCLUDE_DIR}"
INTERFACE_COMPILE_DEFINITIONS HAVE_ZNS=1)
endif()