set(HAVE_UDEV ${UDEV_FOUND})
find_package(blkid REQUIRED)
set(HAVE_BLKID ${BLKID_FOUND})
- if(WITH_RBD)
- find_package(genl REQUIRED)
- set(HAVE_GENL $GENL_FOUND)
- endif()
elseif(FREEBSD)
set(HAVE_UDEV OFF)
set(HAVE_LIBAIO OFF)
set(HAVE_BLKID OFF)
- set(HAVE_GENL OFF)
else()
set(HAVE_UDEV OFF)
- message(STATUS "Not using udev")
set(HAVE_BLKID OFF)
- message(STATUS "Not using BLKID")
- set(HAVE_GENL OFF)
- message(STATUS "Not using GENL")
endif(LINUX)
option(WITH_OPENLDAP "OPENLDAP is here" ON)
+++ /dev/null
-# - Find libnl-genl3
-# Find the genl library and includes
-#
-# GENL_INCLUDE_DIR - where to find netlink.h, etc.
-# GENL_LIBRARIES - List of libraries when using genl.
-# GENL_FOUND - True if genl found.
-
-find_path(GENL_INCLUDE_DIR NAMES netlink/netlink.h PATH_SUFFIXES libnl3)
-
-find_library(LIBNL_LIB nl-3)
-find_library(LIBNL_GENL_LIB nl-genl-3)
-set(GENL_LIBRARIES
- ${LIBNL_LIB}
- ${LIBNL_GENL_LIB}
- )
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(nl-genl-3
- DEFAULT_MSG GENL_LIBRARIES GENL_INCLUDE_DIR)
-
-mark_as_advanced(
- GENL_LIBRARIES
- GENL_INCLUDE_DIR)
--- /dev/null
+# - Find libnl
+# Find the libnl-3 library and includes
+#
+# nl_INCLUDE_DIR - where to find netlink.h, etc.
+# nl_<COMPONENT>_LIBRARY - library when using nl::<COMPONENT>.
+# nl_FOUND - True if nl found.
+
+find_path(nl_INCLUDE_DIR
+ NAMES
+ netlink/netlink.h
+ PATH_SUFFIXES
+ libnl3)
+
+foreach(component "core" ${nl_FIND_COMPONENTS})
+ set(nl_COMPONENTS core cli genl idiag nf route xfrm)
+ list(FIND nl_COMPONENTS "${component}" found)
+ if(found EQUAL -1)
+ message(FATAL_ERROR "unknown libnl-3 component: ${component}")
+ endif()
+ if(component STREQUAL "core")
+ find_library(nl_${component}_LIBRARY nl-3)
+ else()
+ find_library(nl_${component}_LIBRARY nl-${component}-3)
+ endif()
+ list(APPEND nl_LIBRARIES "nl_${component}_LIBRARY")
+endforeach()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(nl
+ DEFAULT_MSG ${nl_LIBRARIES} nl_INCLUDE_DIR)
+
+mark_as_advanced(
+ ${nl_LIBRARIES}
+ nl_INCLUDE_DIR)
+
+if(nl_FOUND)
+ foreach(component "core" ${nl_FIND_COMPONENTS})
+ if(NOT TARGET nl::${component})
+ add_library(nl::${component} UNKNOWN IMPORTED)
+ set_target_properties(nl::${component} PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${nl_INCLUDE_DIR}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${nl_${component}_LIBRARY}")
+ if(NOT component STREQUAL "core")
+ set_target_properties(nl::${component} PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${nl_core_LIBRARY}")
+ endif()
+ endif()
+ endforeach()
+endif()
+find_package(nl REQUIRED genl)
add_executable(rbd-nbd rbd-nbd.cc)
-target_include_directories(rbd-nbd PUBLIC ${GENL_INCLUDE_DIR})
-target_link_libraries(rbd-nbd librbd librados global ${GENL_LIBRARIES})
+target_link_libraries(rbd-nbd librbd librados global nl::genl)
install(TARGETS rbd-nbd DESTINATION bin)