"Fossies" - the Fresh Open Source Software Archive

Member "libpcap-1.10.1/./cmake/Modules/Finddpdk.cmake" (7 Jun 2021, 3153 Bytes) of package /linux/misc/libpcap-1.10.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "Finddpdk.cmake": 1.10.0_vs_1.10.1.

    1 # Try to find dpdk
    2 #
    3 # Once done, this will define
    4 #
    5 # dpdk_FOUND
    6 # dpdk_INCLUDE_DIRS
    7 # dpdk_LIBRARIES
    8 
    9 if(PKG_CONFIG_FOUND)
   10   pkg_check_modules(dpdk QUIET libdpdk)
   11 endif()
   12 message(STATUS "Executing Finddpdk")
   13 if(NOT dpdk_INCLUDE_DIRS)
   14   message(STATUS "Executing find_path")
   15   find_path(dpdk_config_INCLUDE_DIR rte_config.h
   16     HINTS
   17       ENV DPDK_DIR
   18     PATH_SUFFIXES
   19       dpdk
   20       include
   21 )
   22   find_path(dpdk_common_INCLUDE_DIR rte_common.h
   23     HINTS
   24       ENV DPDK_DIR
   25     PATH_SUFFIXES
   26       dpdk
   27       include
   28 )
   29   set(dpdk_INCLUDE_DIRS "${dpdk_config_INCLUDE_DIR}")
   30   if(NOT dpdk_config_INCLUDE_DIR STREQUAL dpdk_common_INCLUDE_DIR)
   31     list(APPEND dpdk_INCLUDE_DIRS "${dpdk_common_INCLUDE_DIR}")
   32   endif()
   33 
   34   set(components
   35     bus_pci
   36     cmdline
   37     eal
   38     ethdev
   39     hash
   40     kvargs
   41     mbuf
   42     mempool
   43     mempool_ring
   44     mempool_stack
   45     pci
   46     pmd_af_packet
   47     pmd_bond
   48     pmd_i40e
   49     pmd_ixgbe
   50     pmd_mlx5
   51     pmd_ring
   52     pmd_vmxnet3_uio
   53     ring)
   54 
   55   set(dpdk_LIBRARIES)
   56 
   57   foreach(c ${components})
   58     find_library(DPDK_rte_${c}_LIBRARY rte_${c}
   59       HINTS
   60         ENV DPDK_DIR
   61         ${dpdk_LIBRARY_DIRS}
   62       PATH_SUFFIXES lib)
   63     if(DPDK_rte_${c}_LIBRARY)
   64       set(dpdk_lib dpdk::${c})
   65       if (NOT TARGET ${dpdk_lib})
   66         add_library(${dpdk_lib} UNKNOWN IMPORTED)
   67         set_target_properties(${dpdk_lib} PROPERTIES
   68           INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}"
   69           IMPORTED_LOCATION "${DPDK_rte_${c}_LIBRARY}")
   70         if(c STREQUAL pmd_mlx5)
   71           find_package(verbs QUIET)
   72           if(verbs_FOUND)
   73             target_link_libraries(${dpdk_lib} INTERFACE IBVerbs::verbs)
   74           endif()
   75         endif()
   76       endif()
   77       list(APPEND dpdk_LIBRARIES ${dpdk_lib})
   78     endif()
   79   endforeach()
   80 
   81   #
   82   # Where the heck did this list come from?  libdpdk on Ubuntu 20.04,
   83   # for example, doesn't even *have* -ldpdk; that's why we go with
   84   # pkg-config, in the hopes that it provides a correct set of flags
   85   # for this tangled mess.
   86   #
   87   list(APPEND dpdk_LIBRARIES dpdk rt m numo dl)
   88 endif()
   89 
   90 mark_as_advanced(dpdk_INCLUDE_DIRS ${dpdk_LIBRARIES})
   91 
   92 include(FindPackageHandleStandardArgs)
   93 find_package_handle_standard_args(dpdk DEFAULT_MSG
   94   dpdk_INCLUDE_DIRS
   95   dpdk_LIBRARIES)
   96 
   97 if(dpdk_FOUND)
   98   if(NOT TARGET dpdk::cflags)
   99      if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
  100       set(rte_cflags "-march=core2")
  101     elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM")
  102       set(rte_cflags "-march=armv7-a")
  103     elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64")
  104       set(rte_cflags "-march=armv8-a+crc")
  105     endif()
  106     add_library(dpdk::cflags INTERFACE IMPORTED)
  107     if (rte_cflags)
  108       set_target_properties(dpdk::cflags PROPERTIES
  109         INTERFACE_COMPILE_OPTIONS "${rte_cflags}")
  110     endif()
  111   endif()
  112 
  113   if(NOT TARGET dpdk::dpdk)
  114     add_library(dpdk::dpdk INTERFACE IMPORTED)
  115     find_package(Threads QUIET)
  116     list(APPEND dpdk_LIBRARIES
  117       Threads::Threads
  118       dpdk::cflags)
  119     set_target_properties(dpdk::dpdk PROPERTIES
  120       INTERFACE_LINK_LIBRARIES "${dpdk_LIBRARIES}"
  121       INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}")
  122   endif()
  123 endif()