mirror of
https://github.com/ceph/ceph
synced 2025-03-25 11:48:05 +00:00
Merge pull request #28460 from tchaikov/wip-cmake-detect-libnl
cmake: rewrite Findgenl to support components argument Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
b2f75ba2aa
@ -218,22 +218,13 @@ if(LINUX)
|
||||
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)
|
||||
|
@ -1,23 +0,0 @@
|
||||
# - 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)
|
50
cmake/modules/Findnl.cmake
Normal file
50
cmake/modules/Findnl.cmake
Normal file
@ -0,0 +1,50 @@
|
||||
# - 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()
|
1
debian/control
vendored
1
debian/control
vendored
@ -53,7 +53,6 @@ Build-Depends: cmake (>= 3.5),
|
||||
libssl-dev,
|
||||
libtool,
|
||||
libudev-dev,
|
||||
libnl-3-dev,
|
||||
libnl-genl-3-dev,
|
||||
libxml2-dev,
|
||||
# Crimson libyaml-cpp-dev,
|
||||
|
@ -1,4 +1,4 @@
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user