In Makefile, I can write something like below to get the dependencies libs.
LIBS:= $(shell pkg-config --libs $(PKGS))
But in meson.build, I don't know how to write simply like this.
I can use run_command
to get libs like below,
r = run_command('pkg-config', '--cflags', 'gstreamer-1.0 gstreamer-video-1.0')
if r.returncode() != 0
# it failed
errortxt = r.stderr().strip()
message(errortxt)
endif
output = r.stdout().strip().split(' ')
message(output)
foreach inc : output
add_global_arguments(inc, language : 'c')
endforeach
so what is best practice to use pkg-config ?
---- UPDATE ----
Using
dependency('gstreamer-video-1.0', 'pkg-config')
will take all effects on build.ninja
LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group -lm -Wl,-rpath,/opt/nvidia/deepstream/deepstream-5.1/lib:/usr/local/cuda-10.2/lib64 -Wl,-rpath-link,/opt/nvidia/deepstream/deepstream-5.1/lib -Wl,-rpath-link,/usr/local/cuda-10.2/lib64 /opt/nvidia/deepstream/deepstream-5.1/lib/libnvdsgst_meta.so /opt/nvidia/deepstream/deepstream-5.1/lib/libnvds_meta.so /opt/nvidia/deepstream/deepstream-5.1/lib/libnvdsgst_helper.so /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so /usr/lib/aarch64-linux-gnu/libgobject-2.0.so /usr/lib/aarch64-linux-gnu/libglib-2.0.so /usr/lib/gcc/aarch64-linux-gnu/7/../../../aarch64-linux-gnu/libcuda.so /usr/local/cuda-10.2/lib64/libcudart.so /usr/lib/aarch64-linux-gnu/libgstrtspserver-1.0.so /usr/lib/aarch64-linux-gnu/libgstvideo-1.0.so /usr/lib/aarch64-linux-gnu/libgstbase-1.0.so -Wl,--end-group
but not on compile_commands.json
[
{
"directory": "/home/ubuntu/work/deepstream-5.1/sources/apps/sample_apps/test3_meson/build",
"command": "cc -Itest1.p -I. -I.. -I/usr/local/cuda-10.2/include -I../../../../includes -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include -I/usr/include/orc-0.4 -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -DPLATFORM_TEGRA -pthread -MD -MQ test1.p/deepstream_test3_app.c.o -MF test1.p/deepstream_test3_app.c.o.d -o test1.p/deepstream_test3_app.c.o -c ../deepstream_test3_app.c",
"file": "../deepstream_test3_app.c"
}
]
So if changes meson.build, should better see effects in build.ninja
.