mirror of
https://github.com/ceph/ceph
synced 2026-08-01 22:45:39 +00:00
cmake: add WITH_SYSTEM_SPDK to link a system-installed SPDK
By default ceph builds the bundled src/spdk fork via BuildSPDK. Add a WITH_SYSTEM_SPDK option that instead locates a distro-provided SPDK through a new Findspdk.cmake (pkg-config based, modelled on Finddpdk.cmake), exposing the same spdk::spdk target. Signed-off-by: Sun Yuechi <sunyuechi@iscas.ac.cn>
This commit is contained in:
parent
d18ffa868f
commit
6af1a85946
@ -326,13 +326,18 @@ if(WITH_BLUESTORE_PMEM)
|
||||
endif()
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(WITH_SPDK "Enable SPDK" OFF
|
||||
"CMAKE_SYSTEM_PROCESSOR MATCHES i386|i686|amd64|x86_64|AMD64|aarch64" OFF)
|
||||
"CMAKE_SYSTEM_PROCESSOR MATCHES i386|i686|amd64|x86_64|AMD64|aarch64|riscv64" OFF)
|
||||
option(WITH_SYSTEM_SPDK "Require a system SPDK instead of building bundled src/spdk" OFF)
|
||||
if(WITH_SPDK)
|
||||
if(NOT WITH_BLUESTORE)
|
||||
message(SEND_ERROR "Please enable WITH_BLUESTORE for using SPDK")
|
||||
endif()
|
||||
include(BuildSPDK)
|
||||
build_spdk()
|
||||
if(WITH_SYSTEM_SPDK)
|
||||
find_package(spdk REQUIRED)
|
||||
else()
|
||||
include(BuildSPDK)
|
||||
build_spdk()
|
||||
endif()
|
||||
set(HAVE_SPDK TRUE)
|
||||
endif(WITH_SPDK)
|
||||
|
||||
|
||||
26
cmake/modules/Findspdk.cmake
Normal file
26
cmake/modules/Findspdk.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
# Findspdk.cmake -- locate a system-installed SPDK via pkg-config.
|
||||
#
|
||||
# Paired with WITH_SYSTEM_SPDK: link a distro-provided spdk-devel instead of
|
||||
# building the bundled src/spdk fork. Modelled on Finddpdk.cmake.
|
||||
#
|
||||
# Provides: spdk::spdk, spdk_FOUND, SPDK_INCLUDE_DIRS
|
||||
|
||||
find_package(PkgConfig REQUIRED QUIET)
|
||||
|
||||
pkg_check_modules(SPDK IMPORTED_TARGET spdk_nvme spdk_env_dpdk)
|
||||
|
||||
# spdk's .so leave ISA-L symbols (crc32_iscsi, xor_gen, ...) undefined for the
|
||||
# final link and don't Require isa-l in their .pc; pull it in explicitly.
|
||||
pkg_check_modules(ISAL REQUIRED IMPORTED_TARGET libisal)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(spdk
|
||||
REQUIRED_VARS SPDK_FOUND SPDK_INCLUDE_DIRS)
|
||||
|
||||
if(spdk_FOUND AND NOT TARGET spdk::spdk)
|
||||
add_library(spdk::spdk INTERFACE IMPORTED)
|
||||
# SPDK/DPDK register drivers via C constructors; keep the libs in DT_NEEDED
|
||||
# (shared-lib equivalent of the bundled target's --whole-archive).
|
||||
set_target_properties(spdk::spdk PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "-Wl,--no-as-needed;PkgConfig::SPDK;PkgConfig::ISAL")
|
||||
endif()
|
||||
Loading…
Reference in New Issue
Block a user