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

Message ID 20220814191109.31090-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit b954deff2071399ca941ffd719e762968f28feae
Headers show
Series
  • [libcamera-devel] meson: Use dependency() instead of find_library() where possible
Related show

Commit Message

Laurent Pinchart Aug. 14, 2022, 7:11 p.m. UTC
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@gmx.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 meson.build                    | 2 +-
 src/libcamera/base/meson.build | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)


base-commit: dfc6d711c9f7f0a9868afa5158aa2089163bded3

Comments

Kieran Bingham Aug. 14, 2022, 10:36 p.m. UTC | #1
Quoting Laurent Pinchart via libcamera-devel (2022-08-14 20:11:09)
> 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.

Can you clarify (perhaps here in the commit message even) why you
haven't changed the others?

In particular, gnutls does have a pkg-config for me, so I would expect
it to be updated too?

atomic, dl, and libc++ I suspect are special cases?

> Reported-by: Christian Rauch <Rauch.Christian@gmx.de>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@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
>
Laurent Pinchart Aug. 15, 2022, 5:37 a.m. UTC | #2
Hi Kieran,

On Sun, Aug 14, 2022 at 11:36:04PM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-08-14 20:11:09)
> > 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.
> 
> Can you clarify (perhaps here in the commit message even) why you
> haven't changed the others?

Sure, I'll add

libatomic, libdl and libc++ still use find_library(). The former is part
of the gcc API, and the latter two part of the C and C++ standard
libraries. They are system libraries, and corresponding headers are
guaranteed to be available.

> In particular, gnutls does have a pkg-config for me, so I would expect
> it to be updated too?

See commit ea8ff99dca6a (libcamera: meson: Use dependency() to find
gnutls).

> atomic, dl, and libc++ I suspect are special cases?
> 
> > Reported-by: Christian Rauch <Rauch.Christian@gmx.de>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@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
Kieran Bingham Aug. 15, 2022, 8:09 a.m. UTC | #3
Quoting Laurent Pinchart (2022-08-15 06:37:23)
> Hi Kieran,
> 
> On Sun, Aug 14, 2022 at 11:36:04PM +0100, Kieran Bingham wrote:
> > Quoting Laurent Pinchart via libcamera-devel (2022-08-14 20:11:09)
> > > 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.
> > 
> > Can you clarify (perhaps here in the commit message even) why you
> > haven't changed the others?
> 
> Sure, I'll add
> 
> libatomic, libdl and libc++ still use find_library(). The former is part
> of the gcc API, and the latter two part of the C and C++ standard
> libraries. They are system libraries, and corresponding headers are
> guaranteed to be available.
> 
> > In particular, gnutls does have a pkg-config for me, so I would expect
> > it to be updated too?
> 
> See commit ea8ff99dca6a (libcamera: meson: Use dependency() to find
> gnutls).

Aha, I see, that's ok then ;D - it even has by RB, but I must have
grepped for find_library in a tree that wasn't updated yet.

--
Kieran


> 
> > atomic, dl, and libc++ I suspect are special cases?
> > 
> > > Reported-by: Christian Rauch <Rauch.Christian@gmx.de>
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@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
Kieran Bingham Aug. 15, 2022, 8:11 a.m. UTC | #4
Quoting Kieran Bingham (2022-08-15 09:09:27)
> Quoting Laurent Pinchart (2022-08-15 06:37:23)
> > Hi Kieran,
> > 
> > On Sun, Aug 14, 2022 at 11:36:04PM +0100, Kieran Bingham wrote:
> > > Quoting Laurent Pinchart via libcamera-devel (2022-08-14 20:11:09)
> > > > 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.
> > > 
> > > Can you clarify (perhaps here in the commit message even) why you
> > > haven't changed the others?
> > 
> > Sure, I'll add
> > 
> > libatomic, libdl and libc++ still use find_library(). The former is part
> > of the gcc API, and the latter two part of the C and C++ standard
> > libraries. They are system libraries, and corresponding headers are
> > guaranteed to be available.
> > 
> > > In particular, gnutls does have a pkg-config for me, so I would expect
> > > it to be updated too?
> > 
> > See commit ea8ff99dca6a (libcamera: meson: Use dependency() to find
> > gnutls).
> 
> Aha, I see, that's ok then ;D - it even has by RB, but I must have
> grepped for find_library in a tree that wasn't updated yet.
> 

Seems good to me.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> --
> Kieran
> 
> 
> > 
> > > atomic, dl, and libc++ I suspect are special cases?
> > > 
> > > > Reported-by: Christian Rauch <Rauch.Christian@gmx.de>
> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@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
Nicolas Dufresne via libcamera-devel Aug. 16, 2022, 5:48 a.m. UTC | #5
On Mon, Aug 15, 2022 at 08:37:23AM +0300, Laurent Pinchart via libcamera-devel wrote:
> Hi Kieran,
> 
> On Sun, Aug 14, 2022 at 11:36:04PM +0100, Kieran Bingham wrote:
> > Quoting Laurent Pinchart via libcamera-devel (2022-08-14 20:11:09)
> > > 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.
> > 
> > Can you clarify (perhaps here in the commit message even) why you
> > haven't changed the others?
> 
> Sure, I'll add
> 
> libatomic, libdl and libc++ still use find_library(). The former is part
> of the gcc API, and the latter two part of the C and C++ standard
> libraries. They are system libraries, and corresponding headers are
> guaranteed to be available.
> 
> > In particular, gnutls does have a pkg-config for me, so I would expect
> > it to be updated too?
> 
> See commit ea8ff99dca6a (libcamera: meson: Use dependency() to find
> gnutls).
> 

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> > atomic, dl, and libc++ I suspect are special cases?
> > 
> > > Reported-by: Christian Rauch <Rauch.Christian@gmx.de>
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@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

Patch
diff mbox series

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)