cmake: refactor dpdk related code

* move the check of `USE_CRYPTOPP` to $top_srcdir/CMakeLists.txt
* remove reference of DPDK_LIBRARY, it's defined nowhere
* move the dpdk code to a single place

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-11-15 20:57:56 +08:00
parent df446f06cb
commit dbe04b4a85
2 changed files with 29 additions and 31 deletions

View File

@ -348,6 +348,9 @@ endif()
option(WITH_DPDK "Enable DPDK messaging" OFF)
if(WITH_DPDK)
if(NOT USE_CRYPTOPP)
message(FATAL_ERROR "CRYPTOPP must be supported when enable DPDK.")
endif()
find_package(dpdk)
set(HAVE_DPDK ${DPDK_FOUND})
endif()

View File

@ -297,15 +297,6 @@ if(HAVE_RDMA)
list(APPEND EXTRALIBS ${RDMA_LIBRARIES} pthread)
endif(HAVE_RDMA)
if(HAVE_DPDK)
set(CMAKE_CXX_FLAGS "-march=native ${CMAKE_CXX_FLAGS} -I${DPDK_INCLUDE_DIR}")
list(APPEND EXTRALIBS ${DPDK_LIBRARY})
if(NOT USE_CRYPTOPP)
message(FATAL_ERROR "CRYPTOPP must be supported when enable DPDK.")
endif(NOT USE_CRYPTOPP)
list(APPEND EXTRALIBS ${DPDK_LIBRARIES})
endif(HAVE_DPDK)
# sort out which allocator to use
if(ALLOCATOR STREQUAL "tcmalloc")
set(ALLOC_LIBS ${GPERFTOOLS_TCMALLOC_LIBRARY})
@ -411,24 +402,6 @@ if(HAVE_RDMA)
msg/async/rdma/RDMAStack.cc)
endif(HAVE_RDMA)
set(dpdk_common_srcs)
if(HAVE_DPDK)
list(APPEND dpdk_common_srcs
msg/async/dpdk/ARP.cc
msg/async/dpdk/DPDK.cc
msg/async/dpdk/dpdk_rte.cc
msg/async/dpdk/DPDKStack.cc
msg/async/dpdk/EventDPDK.cc
msg/async/dpdk/IP.cc
msg/async/dpdk/net.cc
msg/async/dpdk/IPChecksum.cc
msg/async/dpdk/Packet.cc
msg/async/dpdk/TCP.cc
msg/async/dpdk/UserspaceEvent.cc
msg/async/dpdk/ethernet.cc)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${DPDK_INCLUDE_DIR}")
endif(HAVE_DPDK)
add_library(common_buffer_obj OBJECT
common/buffer.cc)
@ -509,7 +482,6 @@ set(libcommon_files
msg/QueueStrategy.cc
${xio_common_srcs}
${async_rdma_common_srcs}
${dpdk_common_srcs}
msg/msg_types.cc
common/reverse.c
common/hobject.cc
@ -670,9 +642,6 @@ set(ceph_common_deps
if(HAVE_RDMA)
list(APPEND ceph_common_deps ${RDMA_LIBRARY})
endif()
if(HAVE_DPDK)
list(APPEND ceph_common_deps ${DPDK_LIBRARIES})
endif()
if(NOT WITH_SYSTEM_BOOST)
list(APPEND ceph_common_deps ${ZLIB_LIBRARIES})
endif()
@ -688,6 +657,32 @@ if(HAVE_ARMV8_CRC)
list(APPEND ceph_common_deps common_crc_aarch64)
endif(HAVE_ARMV8_CRC)
if(WITH_DPDK)
list(APPEND common_async_dpdk_files
msg/async/dpdk/ARP.cc
msg/async/dpdk/DPDK.cc
msg/async/dpdk/dpdk_rte.cc
msg/async/dpdk/DPDKStack.cc
msg/async/dpdk/EventDPDK.cc
msg/async/dpdk/IP.cc
msg/async/dpdk/net.cc
msg/async/dpdk/IPChecksum.cc
msg/async/dpdk/Packet.cc
msg/async/dpdk/TCP.cc
msg/async/dpdk/UserspaceEvent.cc
msg/async/dpdk/ethernet.cc)
add_library(common_async_dpdk STATIC
${common_async_dpdk_files})
# to ready the dpdk header files
add_dependencies(common_async_dpdk
${DPDK_LIBRARIES})
list(APPEND ceph_common_deps common_async_dpdk)
target_link_libraries(common_async_dpdk
${DPDK_LIBRARIES})
set_target_properties(common_async_dpdk PROPERTIES
COMPILE_FLAGS "-march=native -I${DPDK_INCLUDE_DIR}")
endif(WITH_DPDK)
add_library(common STATIC ${ceph_common_objs})
target_link_libraries(common ${ceph_common_deps})