1 Author: Luca Boccassi <bluca@debian.org>
2 Description: use dependency() instead of find_library()
3 Whenever possible (if the library ships a pkg-config file) use meson's
4 dependency() function to look for it, as it will automatically add it
5 to the Requires.private list if needed, to allow for static builds to
6 succeed for reverse dependencies of DPDK. Otherwise the recursive
7 dependencies are not parsed, and users doing static builds have to
8 resolve them manually by themselves.
9 When using this API avoid additional checks that are superfluous and
10 take extra time, and avoid adding the linker flag manually which causes
12 Origin: https://patches.dpdk.org/patch/49996/
13 --- a/drivers/crypto/ccp/meson.build
14 +++ b/drivers/crypto/ccp/meson.build
15 @@ -18,4 +18,3 @@ sources = files('rte_ccp_pmd.c',
19 -pkgconfig_extra_libs += '-lcrypto'
20 --- a/drivers/crypto/openssl/meson.build
21 +++ b/drivers/crypto/openssl/meson.build
24 sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
26 -pkgconfig_extra_libs += '-lcrypto'
27 --- a/drivers/crypto/qat/meson.build
28 +++ b/drivers/crypto/qat/meson.build
29 @@ -13,6 +13,5 @@ if dep.found()
33 - pkgconfig_extra_libs += '-lcrypto'
34 qat_cflags += '-DBUILD_QAT_SYM'
36 --- a/drivers/meson.build
37 +++ b/drivers/meson.build
38 @@ -46,10 +46,11 @@ foreach class:driver_classes
39 # set up internal deps. Drivers can append/override as necessary
41 # ext_deps: Stores external library dependency got
42 - # using dependency() or cc.find_library(). For most cases, we
43 - # probably also need to specify the "-l" flags in
44 - # pkgconfig_extra_libs variable too, so that it can be reflected
45 - # in the pkgconfig output for static builds
46 + # using dependency() (preferred) or find_library().
47 + # For the find_library() case (but not with dependency()) we also
48 + # need to specify the "-l" flags in pkgconfig_extra_libs variable
49 + # too, so that it can be reflected in the pkgconfig output for
52 pkgconfig_extra_libs = []
54 --- a/drivers/net/bnx2x/meson.build
55 +++ b/drivers/net/bnx2x/meson.build
57 # SPDX-License-Identifier: BSD-3-Clause
58 # Copyright(c) 2018 Intel Corporation
60 -dep = cc.find_library('z', required: false)
61 +dep = dependency('zlib', required: false)
64 cflags += '-DZLIB_CONST'
65 --- a/drivers/net/mlx4/meson.build
66 +++ b/drivers/net/mlx4/meson.build
67 @@ -14,9 +14,9 @@ if pmd_dlopen
71 - cc.find_library('mnl', required:false),
72 - cc.find_library('mlx4', required:false),
73 - cc.find_library('ibverbs', required:false),
74 + dependency('libmnl', required:false),
75 + dependency('libmlx4', required:false),
76 + dependency('libibverbs', required:false),
80 --- a/drivers/net/mlx5/meson.build
81 +++ b/drivers/net/mlx5/meson.build
82 @@ -14,9 +14,9 @@ if pmd_dlopen
86 - cc.find_library('mnl', required:false),
87 - cc.find_library('mlx5', required:false),
88 - cc.find_library('ibverbs', required:false),
89 + dependency('libmnl', required:false),
90 + dependency('libmlx5', required:false),
91 + dependency('libibverbs', required:false),
95 --- a/drivers/net/pcap/meson.build
96 +++ b/drivers/net/pcap/meson.build
98 # SPDX-License-Identifier: BSD-3-Clause
99 # Copyright(c) 2017 Intel Corporation
101 -pcap_dep = cc.find_library('pcap', required: false)
102 -if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
103 +pcap_dep = dependency('pcap', required: false)
109 sources = files('rte_eth_pcap.c')
111 -pkgconfig_extra_libs += '-lpcap'
112 --- a/lib/librte_bpf/meson.build
113 +++ b/lib/librte_bpf/meson.build
114 @@ -18,8 +18,8 @@ install_headers = files('bpf_def.h',
116 deps += ['mbuf', 'net', 'ethdev']
118 -dep = cc.find_library('elf', required: false)
119 -if dep.found() == true and cc.has_header('libelf.h', dependencies: dep)
120 +dep = dependency('libelf', required: false)
122 sources += files('bpf_load_elf.c')
125 --- a/lib/librte_telemetry/meson.build
126 +++ b/lib/librte_telemetry/meson.build
127 @@ -6,7 +6,7 @@ headers = files('rte_telemetry.h', 'rte_
128 deps += ['metrics', 'ethdev']
129 cflags += '-DALLOW_EXPERIMENTAL_API'
131 -jansson = cc.find_library('jansson', required: false)
132 +jansson = dependency('jansson', required: false)
135 dpdk_app_link_libraries += ['telemetry']
136 --- a/drivers/compress/zlib/meson.build
137 +++ b/drivers/compress/zlib/meson.build
138 @@ -9,6 +9,5 @@ endif
140 sources = files('zlib_pmd.c', 'zlib_pmd_ops.c')
142 -pkgconfig_extra_libs += '-lz'
144 allow_experimental_apis = true