2017-11-15 12:54:46 +00:00
|
|
|
macro(build_spdk)
|
|
|
|
if(NOT TARGET dpdk-ext)
|
|
|
|
include(BuildDPDK)
|
|
|
|
build_dpdk()
|
|
|
|
endif()
|
|
|
|
find_package(CUnit REQUIRED)
|
2017-11-19 18:09:35 +00:00
|
|
|
if(LINUX)
|
|
|
|
find_package(aio REQUIRED)
|
2017-11-28 10:00:37 +00:00
|
|
|
find_package(uuid REQUIRED)
|
2017-11-19 18:09:35 +00:00
|
|
|
endif()
|
2017-11-15 12:54:46 +00:00
|
|
|
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)
|
2017-11-28 10:00:37 +00:00
|
|
|
foreach(c nvme log lvol env_dpdk util)
|
2017-11-15 12:54:46 +00:00
|
|
|
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
|
2017-11-28 10:00:37 +00:00
|
|
|
INTERFACE_LINK_LIBRARIES "${DPDK_LIBRARIES};rt")
|
2018-06-14 01:32:08 +00:00
|
|
|
set_target_properties(spdk::lvol PROPERTIES
|
|
|
|
INTERFACE_LINK_LIBRARIES spdk::util)
|
|
|
|
set_target_properties(spdk::util PROPERTIES
|
|
|
|
INTERFACE_LINK_LIBRARIES ${UUID_LIBRARIES})
|
2017-11-15 12:54:46 +00:00
|
|
|
set(SPDK_INCLUDE_DIR "${source_dir}/include")
|
|
|
|
unset(source_dir)
|
|
|
|
endmacro()
|