From: Kefu Chai Date: Thu, 24 Oct 2019 06:07:18 +0000 (+0800) Subject: cmake: refactor BuildDPDK X-Git-Tag: v15.1.0~1167^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d82ea5d738282ad0b418fc30b1179a9cab9bc290;p=ceph.git cmake: refactor BuildDPDK * 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 944addd8c4fa..57e26e7e50fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/cmake/modules/BuildDPDK.cmake b/cmake/modules/BuildDPDK.cmake index a14af918fd6e..cfcfc20ae1e3 100644 --- a/cmake/modules/BuildDPDK.cmake +++ b/cmake/modules/BuildDPDK.cmake @@ -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()