From dbe04b4a85de5d8d68da05f8d1a18af45cacbc78 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 15 Nov 2017 20:57:56 +0800 Subject: [PATCH] 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 --- CMakeLists.txt | 3 +++ src/CMakeLists.txt | 57 +++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2c6f3c64c0..2de40f0d7c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44572cf54fc..6bb1f5be316 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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})