ceph/cmake/modules/BuildSPDK.cmake
Kefu Chai b3ceafe7d8 cmake,rpm,deb: update to accommodate SPDK v17.10
* cmake/modules/BuildSPDK.cmake: add lvol
* cmake/modules/BuildDPDK.cmake: add pci and bus_pci
* ceph.spec.in, cmake/modules/BuildSPDK.cmake, debian/control:
  re-introduce libuuid dependency, as 17.07 added lvol. and the latter
  depends on uuid.
* cmake/modules/BuildSPDK.cmake: avoid introducing local variable of
  `iface_libs`.
* cmake/modules/patch-dpdk-conf.sh: disable
  CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES, this option introduces the
  balanced allocation of memory. but it also requires libnuma-dev.
  let's disable it for now.

Signed-off-by: Kefu Chai <kchai@redhat.com>
2017-11-29 18:03:23 +08:00

40 lines
1.4 KiB
CMake

macro(build_spdk)
if(NOT TARGET dpdk-ext)
include(BuildDPDK)
build_dpdk()
endif()
find_package(CUnit REQUIRED)
if(LINUX)
find_package(aio REQUIRED)
find_package(uuid REQUIRED)
endif()
include(ExternalProject)
ExternalProject_Add(spdk-ext
DEPENDS dpdk-ext
SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/spdk
CONFIGURE_COMMAND ./configure --with-dpdk=${DPDK_DIR}
# unset $CFLAGS, otherwise it will interfere with how SPDK sets
# its include directory.
# unset $LDFLAGS, otherwise SPDK will fail to mock some functions.
BUILD_COMMAND env -i PATH=$ENV{PATH} CC=${CMAKE_C_COMPILER} $(MAKE) EXTRA_CFLAGS="-fPIC"
BUILD_IN_SOURCE 1
INSTALL_COMMAND "true")
ExternalProject_Get_Property(spdk-ext source_dir)
foreach(c nvme log lvol env_dpdk util)
add_library(spdk::${c} STATIC IMPORTED)
add_dependencies(spdk::${c} spdk-ext)
set_target_properties(spdk::${c} PROPERTIES
IMPORTED_LOCATION "${source_dir}/build/lib/${CMAKE_STATIC_LIBRARY_PREFIX}spdk_${c}${CMAKE_STATIC_LIBRARY_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${source_dir}/include")
list(APPEND SPDK_LIBRARIES spdk::${c})
endforeach()
set_target_properties(spdk::env_dpdk PROPERTIES
INTERFACE_LINK_LIBRARIES "${DPDK_LIBRARIES};rt")
if(LINUX)
set_target_properties(spdk::lvol PROPERTIES
INTERFACE_LINK_LIBRARIES ${UUID_LIBRARIES})
endif()
set(SPDK_INCLUDE_DIR "${source_dir}/include")
unset(source_dir)
endmacro()