]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: refactor dpdk related code
authorKefu Chai <kchai@redhat.com>
Wed, 15 Nov 2017 12:57:56 +0000 (20:57 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 18 Nov 2017 02:43:33 +0000 (10:43 +0800)
* 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>
CMakeLists.txt
src/CMakeLists.txt

index e2c6f3c64c0a2caf75d451d61c8595503ac31f62..2de40f0d7c6d8273a102f3844be3b3a0346e470b 100644 (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()
index 44572cf54fc3af3d4235c43f4fcdfd53c9ef0936..6bb1f5be316ce85b96a552805e5e73d36f20458e 100644 (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})