[libcamera-devel] [PATCH] meson: Use dependency() instead of find_library() where possible

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sun Aug 14 21:11:09 CEST 2022


Usage of find_library() to find dependencies that libcamera needs to
compile against can lead to the library being found even if the
corresponding headers are not installed. This will then result in a
compilation failure. Switch to dependency() for libdw, libunwind and
lttng-ust to fix this, all three libraries come with a pkgconfig file
that is usually installed by the distribution package that contains the
library headers.

Reported-by: Christian Rauch <Rauch.Christian at gmx.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 meson.build                    | 2 +-
 src/libcamera/base/meson.build | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index e8b81ad87a6e..72919102ad55 100644
--- a/meson.build
+++ b/meson.build
@@ -122,7 +122,7 @@ libcamera_includes = include_directories('include')
 py_modules = []
 
 # Libraries used by multiple components
-liblttng = cc.find_library('lttng-ust', required : get_option('tracing'))
+liblttng = dependency('lttng-ust', required : get_option('tracing'))
 
 # Pipeline handlers
 #
diff --git a/src/libcamera/base/meson.build b/src/libcamera/base/meson.build
index 7030ad1f5927..3b9d74efe935 100644
--- a/src/libcamera/base/meson.build
+++ b/src/libcamera/base/meson.build
@@ -22,8 +22,8 @@ libcamera_base_sources = files([
     'utils.cpp',
 ])
 
-libdw = cc.find_library('libdw', required : false)
-libunwind = cc.find_library('libunwind', required : false)
+libdw = dependency('libdw', required : false)
+libunwind = dependency('libunwind', required : false)
 
 if cc.has_header_symbol('execinfo.h', 'backtrace')
     config_h.set('HAVE_BACKTRACE', 1)

base-commit: dfc6d711c9f7f0a9868afa5158aa2089163bded3
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list