]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: refactor BuildDPDK
authorKefu Chai <kchai@redhat.com>
Thu, 24 Oct 2019 06:07:18 +0000 (14:07 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 24 Oct 2019 07:15:51 +0000 (15:15 +0800)
* extract `do_export_dpdk()` into a separated function
* no need to check for `dpdk-ext` target before calling `build_dpdk()`,
  as the name of this target should be hidden from the caller of this
  function.

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
cmake/modules/BuildDPDK.cmake

index 944addd8c4fa69c3c1ee3c7576b9c5a1af7bde43..57e26e7e50fc6575a46371ff9bb2c77191fd77ec 100644 (file)
@@ -322,7 +322,7 @@ set(CRYPTO_LIBS OpenSSL::Crypto)
 option(WITH_DPDK "Enable DPDK messaging" OFF)
 if(WITH_DPDK)
   find_package(dpdk)
-  if(NOT DPDK_FOUND AND NOT TARGET dpdk-ext)
+  if(NOT DPDK_FOUND)
     include(BuildDPDK)
     build_dpdk(${CMAKE_BINARY_DIR}/src/dpdk)
   endif()
index a14af918fd6e0d53d45d91b84f17031500d80927..cfcfc20ae1e36ded7cd1cb415725f851a97303ea 100644 (file)
@@ -94,8 +94,7 @@ function(do_build_dpdk dpdk_dir)
   ExternalProject_Add_StepTargets(dpdk-ext configure patch-config build)
 endfunction()
 
-function(build_dpdk dpdk_dir)
-  do_build_dpdk(${dpdk_dir})
+function(do_export_dpdk dpdk_dir)
   set(DPDK_INCLUDE_DIR ${dpdk_dir}/include)
   # create the directory so cmake won't complain when looking at the imported
   # target
@@ -145,3 +144,12 @@ function(build_dpdk dpdk_dir)
       INTERFACE_COMPILE_OPTIONS "${dpdk_rte_CFLAGS}")
   endif()
 endfunction()
+
+function(build_dpdk dpdk_dir)
+  if(NOT TARGET dpdk-ext)
+    do_build_dpdk(${dpdk_dir})
+  endif()
+  if(NOT TARGET dpdk::dpdk)
+    do_export_dpdk(${dpdk_dir})
+  endif()
+endfunction()