summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-03-28 20:54:47 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-03-28 20:59:04 +0000
commit9fd24793a407f2edbdf5c2d3a031bdcf894f0a69 (patch)
tree24ee51e8bd09c577a577fb5359217a7c83ad00e4 /src
parent76b5649d074ab198cbf5737ac76d21649a61bffd (diff)
cmake: add vpp_plugin_find_library macro
Change-Id: I0b996460e05c40e74766563fb2a94c62a65063ce Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmake/plugin.cmake9
-rw-r--r--src/plugins/dpdk/CMakeLists.txt30
-rw-r--r--src/plugins/rdma/CMakeLists.txt20
-rw-r--r--src/plugins/tlsmbedtls/CMakeLists.txt38
4 files changed, 49 insertions, 48 deletions
diff --git a/src/cmake/plugin.cmake b/src/cmake/plugin.cmake
index 47296ed451f..1565170dedf 100644
--- a/src/cmake/plugin.cmake
+++ b/src/cmake/plugin.cmake
@@ -94,3 +94,12 @@ macro(add_vpp_plugin name)
COMPONENT ${PLUGIN_COMPONENT}
)
endmacro()
+
+macro(vpp_plugin_find_library plugin var name)
+ find_library(${var} NAMES ${name} ${ARGN})
+if (NOT ${var})
+ message(WARNING "-- ${name} library not found - ${plugin} plugin disabled")
+ return()
+endif()
+ message(STATUS "${plugin} plugin needs ${name} library - found at ${${var}}")
+endmacro()
diff --git a/src/plugins/dpdk/CMakeLists.txt b/src/plugins/dpdk/CMakeLists.txt
index 0cbb0b46f6b..76b22a9704c 100644
--- a/src/plugins/dpdk/CMakeLists.txt
+++ b/src/plugins/dpdk/CMakeLists.txt
@@ -12,30 +12,18 @@
# limitations under the License.
##############################################################################
-# macros
-##############################################################################
-macro(dpdk_find_library var name)
- find_library(${var} NAMES ${name} ${ARGN})
-if (NOT ${var})
- message(WARNING "-- ${name} library not found - dpdk_plugin disabled")
- return()
-endif()
- message(STATUS "DPDK plugin needs ${name} library - found at ${${var}}")
-endmacro()
-
-##############################################################################
# Find lib and include files
##############################################################################
find_path(DPDK_INCLUDE_DIR PATH_SUFFIXES dpdk NAMES rte_config.h)
-find_library(DPDK_LIB NAMES libdpdk.a)
+vpp_plugin_find_library(dpdk DPDK_LIB "libdpdk.a")
if (NOT DPDK_INCLUDE_DIR)
- message(WARNING "-- DPDK headers not found - dpdk_plugin disabled")
+ message(WARNING "-- DPDK headers not found - dpdk plugin disabled")
return()
endif()
if (NOT DPDK_LIB)
- dpdk_find_library(DPDK_SHLIB "libdpdk.so")
+ vpp_plugin_find_library(dpdk DPDK_SHLIB "libdpdk.so")
set(DPDK_IS_SHARED_LIB 1)
message(WARNING "-- linking dpdk plugin against DPDK shared libs")
endif()
@@ -91,7 +79,7 @@ endif()
##############################################################################
# libnuma
##############################################################################
-dpdk_find_library(NUMA_LIB "numa")
+vpp_plugin_find_library(dpdk NUMA_LIB "numa")
list(APPEND DPDK_LINK_LIBRARIES ${NUMA_LIB})
##############################################################################
@@ -99,10 +87,10 @@ list(APPEND DPDK_LINK_LIBRARIES ${NUMA_LIB})
##############################################################################
if(DPDK_RTE_LIBRTE_PMD_AESNI_MB OR DPDK_RTE_LIBRTE_PMD_AESNI_GCM)
if(DPDK_IS_SHARED_LIB)
- dpdk_find_library(IPSECMB_LIB "libIPSec_MB.so")
+ vpp_plugin_find_library(dpdk IPSECMB_LIB "libIPSec_MB.so")
list(APPEND DPDK_LINK_LIBRARIES "${IPSECMB_LIB}")
else()
- dpdk_find_library(IPSECMB_LIB "libIPSec_MB.a")
+ vpp_plugin_find_library(dpdk IPSECMB_LIB "libIPSec_MB.a")
get_filename_component(IPSECMB_LIB_DIR ${IPSECMB_LIB} DIRECTORY)
string_append(DPDK_LINK_FLAGS "-L${IPSECMB_LIB_DIR}")
string_append(DPDK_LINK_FLAGS "-Wl,--exclude-libs,libIPSec_MB.a,-l:libIPSec_MB.a")
@@ -113,14 +101,14 @@ endif()
# Mellanox libraries
##############################################################################
if(DPDK_RTE_LIBRTE_MLX4_PMD OR DPDK_RTE_LIBRTE_MLX5_PMD)
- dpdk_find_library(MNL_LIB "mnl")
+ vpp_plugin_find_library(MNL_LIB "mnl")
list(APPEND DPDK_LINK_LIBRARIES "${MNL_LIB}")
if (DPDK_RTE_IBVERBS_LINK_DLOPEN)
message(STATUS "DPDK depends on libmnl (Mellanox PMD requirement)")
else()
- dpdk_find_library(IBVERBS_LIB "ibverbs")
+ vpp_plugin_find_library(dpdk IBVERBS_LIB "ibverbs")
list(APPEND DPDK_LINK_LIBRARIES "${IBVERBS_LIB}")
- dpdk_find_library(MLX5_LIB "mlx5")
+ vpp_plugin_find_library(dpdk MLX5_LIB "mlx5")
list(APPEND DPDK_LINK_LIBRARIES "${MLX5_LIB}")
message(STATUS "DPDK depends on libmnl, libibverbs, libmlx5 (Mellanox PMD requirement)")
endif()
diff --git a/src/plugins/rdma/CMakeLists.txt b/src/plugins/rdma/CMakeLists.txt
index 35d43db28a1..7b6b37cc59b 100644
--- a/src/plugins/rdma/CMakeLists.txt
+++ b/src/plugins/rdma/CMakeLists.txt
@@ -11,14 +11,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-message(STATUS "RDMA plugins - looking for ibverbs")
-
find_path(IBVERBS_INCLUDE_DIR NAMES infiniband/verbs.h)
-find_library(IBVERBS_LIB NAMES libibverbs.a)
-find_library(MLX5_LIB NAMES libmlx5.a)
+
+if (NOT IBVERBS_INCLUDE_DIR)
+ message(WARNING "-- rdma headers not found - rdma plugin disabled")
+ return()
+endif()
+
+vpp_plugin_find_library(rdma IBVERBS_LIB libibverbs.a)
+vpp_plugin_find_library(rdma MLX5_LIB libmlx5.a)
if (NOT IBVERBS_LIB OR NOT MLX5_LIB)
- message(WARNING "RDMA plugins - ibverbs not found - rdma_plugin disabled")
+ message(WARNING "rdma plugin - ibverbs not found - rdma plugin disabled")
return()
endif()
@@ -30,14 +34,10 @@ set(CMAKE_REQUIRED_FLAGS "-fPIC -shared ${IBVERBS_LIB} ${RDMA_LINK_FLAGS}")
CHECK_C_SOURCE_COMPILES("" IBVERBS_COMPILES_CHECK)
if (NOT IBVERBS_COMPILES_CHECK)
- message(WARNING "RDMA plugins - no working ibverbs found - rdma_plugin disabled")
+ message(WARNING "rdma plugins - no working ibverbs found - rdma plugin disabled")
return()
endif()
-message(STATUS "RDMA plugins - found ${IBVERBS_INCLUDE_DIR}")
-message(STATUS "RDMA plugins - found ${IBVERBS_LIB}")
-message(STATUS "RDMA plugins - found ${MLX5_LIB}")
-
include_directories(${IBVERBS_INCLUDE_DIR})
add_vpp_plugin(rdma
diff --git a/src/plugins/tlsmbedtls/CMakeLists.txt b/src/plugins/tlsmbedtls/CMakeLists.txt
index 13fa12e5c55..96bc97df3f5 100644
--- a/src/plugins/tlsmbedtls/CMakeLists.txt
+++ b/src/plugins/tlsmbedtls/CMakeLists.txt
@@ -11,25 +11,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-message(STATUS "Looking for mbedTLS")
find_path(MBEDTLS_INCLUDE_DIR NAMES mbedtls/ssl.h)
-find_library(MBEDTLS_LIB1 NAMES mbedtls)
-find_library(MBEDTLS_LIB2 NAMES mbedx509)
-find_library(MBEDTLS_LIB3 NAMES mbedcrypto)
-set (MBEDTLS_LIB ${MBEDTLS_LIB1} ${MBEDTLS_LIB2} ${MBEDTLS_LIB3})
+if (NOT MBEDTLS_INCLUDE_DIR)
+ message(WARNING "-- mbedtls headers not found - tlsmbedtls plugin disabled")
+ return()
+endif()
-if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIB)
- include_directories(${MBEDTLS_INCLUDE_DIR})
- add_vpp_plugin(tlsmbedtls
- SOURCES
- tls_mbedtls.c
+vpp_plugin_find_library(tlsmbedtls MBEDTLS_LIB1 mbedtls)
+vpp_plugin_find_library(tlsmbedtls MBEDTLS_LIB2 mbedx509)
+vpp_plugin_find_library(tlsmbedtls MBEDTLS_LIB3 mbedcrypto)
- LINK_LIBRARIES
- ${MBEDTLS_LIB}
- )
- message(STATUS "Found mbedTLS in ${MBEDTLS_INCLUDE_DIR}")
-else()
- message(WARNING "-- mbedTLS not found - tlsmbedtls_plugin disabled")
-endif()
+if (NOT MBEDTLS_LIB1 AND NOT MBEDTLS_LIB2 AND NOT MBEDTLS_LIB3)
+ message(WARNING "-- mbedtls libraries not found - tlsmbedtls plugin disabled")
+ return()
+endif ()
+
+set (MBEDTLS_LIB ${MBEDTLS_LIB1} ${MBEDTLS_LIB2} ${MBEDTLS_LIB3})
+
+include_directories(${MBEDTLS_INCLUDE_DIR})
+add_vpp_plugin(tlsmbedtls
+ SOURCES
+ tls_mbedtls.c
+ LINK_LIBRARIES
+ ${MBEDTLS_LIB}
+)