[v1] meson: Add options to control drm, sdl2, jpeg dependencies of `cam`
diff mbox series

Message ID 20260130111133.1576210-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1] meson: Add options to control drm, sdl2, jpeg dependencies of `cam`
Related show

Commit Message

Barnabás Pőcze Jan. 30, 2026, 11:11 a.m. UTC
Previously it was not possible to control these dependencies, they were
always used if found. Furthermore, libjpeg was unnecessarily added as a
dependency even if sdl2 was not found. Fix that by introducing three
options to control the dependencies.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 meson_options.txt        | 15 +++++++++++++++
 src/apps/cam/meson.build | 36 ++++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 14 deletions(-)

Comments

Milan Zamazal Jan. 30, 2026, 1:59 p.m. UTC | #1
Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:

> Previously it was not possible to control these dependencies, they were
> always used if found. Furthermore, libjpeg was unnecessarily added as a
> dependency even if sdl2 was not found. Fix that by introducing three
> options to control the dependencies.

If it is useful:

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  meson_options.txt        | 15 +++++++++++++++
>  src/apps/cam/meson.build | 36 ++++++++++++++++++++++--------------
>  2 files changed, 37 insertions(+), 14 deletions(-)
>
> diff --git a/meson_options.txt b/meson_options.txt
> index 8121cf5d2..58cf52ad1 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -16,6 +16,21 @@ option('cam',
>          value : 'auto',
>          description : 'Compile the cam test application')
>  
> +option('cam-output-kms',
> +        type : 'feature',
> +        value : 'auto',
> +        description : 'Enable KMS output in the cam application')
> +
> +option('cam-output-sdl2',
> +        type : 'feature',
> +        value : 'auto',
> +        description : 'Enable SDL2 output in the cam application')
> +
> +option('cam-output-sdl2-jpeg',
> +        type : 'feature',
> +        value : 'auto',
> +        description : 'Enable JPEG support in the SDL2 output in the cam application')
> +
>  option('documentation',
>          type : 'feature',
>          value : 'auto',
> diff --git a/src/apps/cam/meson.build b/src/apps/cam/meson.build
> index cd7f120f9..c73c0f5d9 100644
> --- a/src/apps/cam/meson.build
> +++ b/src/apps/cam/meson.build
> @@ -17,9 +17,18 @@ cam_sources = files([
>  
>  cam_cpp_args = [apps_cpp_args]
>  
> -libdrm = dependency('libdrm', required : false)
> -libjpeg = dependency('libjpeg', required : false)
> -libsdl2 = dependency('SDL2', required : false)
> +cam_deps = [
> +    libatomic,
> +    libcamera_public,
> +    libevent,
> +    libthreads,
> +    libyaml,
> +    libtiff,
> +]
> +
> +libdrm = dependency('libdrm', required : get_option('cam-output-kms'))
> +libsdl2 = dependency('SDL2', required : get_option('cam-output-sdl2'))
> +libjpeg = dependency('libjpeg', required : get_option('cam-output-sdl2-jpeg'))
>  
>  if libdrm.found()
>      cam_cpp_args += [ '-DHAVE_KMS' ]
> @@ -27,6 +36,9 @@ if libdrm.found()
>          'drm.cpp',
>          'kms_sink.cpp'
>      ])
> +    cam_deps += [
> +        libdrm,
> +    ]
>  endif
>  
>  if libsdl2.found()
> @@ -37,28 +49,24 @@ if libsdl2.found()
>          'sdl_texture_1plane.cpp',
>          'sdl_texture_yuv.cpp',
>      ])
> +    cam_deps += [
> +        libsdl2,
> +    ]
>  
>      if libjpeg.found()
>          cam_cpp_args += ['-DHAVE_LIBJPEG']
>          cam_sources += files([
>              'sdl_texture_mjpg.cpp'
>          ])
> +        cam_deps += [
> +            libjpeg,
> +        ]
>      endif
>  endif
>  
>  cam  = executable('cam', cam_sources,
>                    link_with : apps_lib,
> -                  dependencies : [
> -                      libatomic,
> -                      libcamera_public,
> -                      libdrm,
> -                      libevent,
> -                      libjpeg,
> -                      libsdl2,
> -                      libtiff,
> -                      libthreads,
> -                      libyaml,
> -                  ],
> +                  dependencies : cam_deps,
>                    cpp_args : cam_cpp_args,
>                    install : true,
>                    install_tag : 'bin')
Laurent Pinchart Feb. 6, 2026, 12:55 a.m. UTC | #2
On Fri, Jan 30, 2026 at 12:11:33PM +0100, Barnabás Pőcze wrote:
> Previously it was not possible to control these dependencies, they were
> always used if found. Furthermore, libjpeg was unnecessarily added as a
> dependency even if sdl2 was not found. Fix that by introducing three
> options to control the dependencies.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  meson_options.txt        | 15 +++++++++++++++
>  src/apps/cam/meson.build | 36 ++++++++++++++++++++++--------------
>  2 files changed, 37 insertions(+), 14 deletions(-)
> 
> diff --git a/meson_options.txt b/meson_options.txt
> index 8121cf5d2..58cf52ad1 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -16,6 +16,21 @@ option('cam',
>          value : 'auto',
>          description : 'Compile the cam test application')
>  
> +option('cam-output-kms',
> +        type : 'feature',
> +        value : 'auto',
> +        description : 'Enable KMS output in the cam application')
> +
> +option('cam-output-sdl2',
> +        type : 'feature',
> +        value : 'auto',
> +        description : 'Enable SDL2 output in the cam application')
> +
> +option('cam-output-sdl2-jpeg',
> +        type : 'feature',
> +        value : 'auto',
> +        description : 'Enable JPEG support in the SDL2 output in the cam application')
> +
>  option('documentation',
>          type : 'feature',
>          value : 'auto',
> diff --git a/src/apps/cam/meson.build b/src/apps/cam/meson.build
> index cd7f120f9..c73c0f5d9 100644
> --- a/src/apps/cam/meson.build
> +++ b/src/apps/cam/meson.build
> @@ -17,9 +17,18 @@ cam_sources = files([
>  
>  cam_cpp_args = [apps_cpp_args]
>  
> -libdrm = dependency('libdrm', required : false)
> -libjpeg = dependency('libjpeg', required : false)
> -libsdl2 = dependency('SDL2', required : false)
> +cam_deps = [
> +    libatomic,
> +    libcamera_public,
> +    libevent,
> +    libthreads,
> +    libyaml,
> +    libtiff,
> +]
> +
> +libdrm = dependency('libdrm', required : get_option('cam-output-kms'))
> +libsdl2 = dependency('SDL2', required : get_option('cam-output-sdl2'))
> +libjpeg = dependency('libjpeg', required : get_option('cam-output-sdl2-jpeg'))

I wonder if we could combine the cam-output-sdl2 and
cam-output-sdl2-jpeg options here to avoid looking up libjpeg if SDL2 is
disabled, but it's probably not worth it.

Actually, I think we should support JPEG decompression with the KMS
output as well, in which case the option would become cam-jpeg (or
something similar). We could already name it like that, to avoid
renaming it later.

With that,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  
>  if libdrm.found()
>      cam_cpp_args += [ '-DHAVE_KMS' ]
> @@ -27,6 +36,9 @@ if libdrm.found()
>          'drm.cpp',
>          'kms_sink.cpp'
>      ])
> +    cam_deps += [
> +        libdrm,
> +    ]
>  endif
>  
>  if libsdl2.found()
> @@ -37,28 +49,24 @@ if libsdl2.found()
>          'sdl_texture_1plane.cpp',
>          'sdl_texture_yuv.cpp',
>      ])
> +    cam_deps += [
> +        libsdl2,
> +    ]
>  
>      if libjpeg.found()
>          cam_cpp_args += ['-DHAVE_LIBJPEG']
>          cam_sources += files([
>              'sdl_texture_mjpg.cpp'
>          ])
> +        cam_deps += [
> +            libjpeg,
> +        ]
>      endif
>  endif
>  
>  cam  = executable('cam', cam_sources,
>                    link_with : apps_lib,
> -                  dependencies : [
> -                      libatomic,
> -                      libcamera_public,
> -                      libdrm,
> -                      libevent,
> -                      libjpeg,
> -                      libsdl2,
> -                      libtiff,
> -                      libthreads,
> -                      libyaml,
> -                  ],
> +                  dependencies : cam_deps,
>                    cpp_args : cam_cpp_args,
>                    install : true,
>                    install_tag : 'bin')
Kieran Bingham Feb. 6, 2026, 1:04 a.m. UTC | #3
Quoting Laurent Pinchart (2026-02-06 00:55:02)
> On Fri, Jan 30, 2026 at 12:11:33PM +0100, Barnabás Pőcze wrote:
> > Previously it was not possible to control these dependencies, they were
> > always used if found. Furthermore, libjpeg was unnecessarily added as a
> > dependency even if sdl2 was not found. Fix that by introducing three
> > options to control the dependencies.
> > 
> > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > ---
> >  meson_options.txt        | 15 +++++++++++++++
> >  src/apps/cam/meson.build | 36 ++++++++++++++++++++++--------------
> >  2 files changed, 37 insertions(+), 14 deletions(-)
> > 
> > diff --git a/meson_options.txt b/meson_options.txt
> > index 8121cf5d2..58cf52ad1 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -16,6 +16,21 @@ option('cam',
> >          value : 'auto',
> >          description : 'Compile the cam test application')
> >  
> > +option('cam-output-kms',
> > +        type : 'feature',
> > +        value : 'auto',
> > +        description : 'Enable KMS output in the cam application')
> > +
> > +option('cam-output-sdl2',
> > +        type : 'feature',
> > +        value : 'auto',
> > +        description : 'Enable SDL2 output in the cam application')
> > +
> > +option('cam-output-sdl2-jpeg',
> > +        type : 'feature',
> > +        value : 'auto',
> > +        description : 'Enable JPEG support in the SDL2 output in the cam application')
> > +
> >  option('documentation',
> >          type : 'feature',
> >          value : 'auto',
> > diff --git a/src/apps/cam/meson.build b/src/apps/cam/meson.build
> > index cd7f120f9..c73c0f5d9 100644
> > --- a/src/apps/cam/meson.build
> > +++ b/src/apps/cam/meson.build
> > @@ -17,9 +17,18 @@ cam_sources = files([
> >  
> >  cam_cpp_args = [apps_cpp_args]
> >  
> > -libdrm = dependency('libdrm', required : false)
> > -libjpeg = dependency('libjpeg', required : false)
> > -libsdl2 = dependency('SDL2', required : false)
> > +cam_deps = [
> > +    libatomic,
> > +    libcamera_public,
> > +    libevent,
> > +    libthreads,
> > +    libyaml,
> > +    libtiff,
> > +]
> > +
> > +libdrm = dependency('libdrm', required : get_option('cam-output-kms'))
> > +libsdl2 = dependency('SDL2', required : get_option('cam-output-sdl2'))
> > +libjpeg = dependency('libjpeg', required : get_option('cam-output-sdl2-jpeg'))
> 
> I wonder if we could combine the cam-output-sdl2 and
> cam-output-sdl2-jpeg options here to avoid looking up libjpeg if SDL2 is
> disabled, but it's probably not worth it.
> 
> Actually, I think we should support JPEG decompression with the KMS
> output as well, in which case the option would become cam-jpeg (or
> something similar). We could already name it like that, to avoid
> renaming it later.

Why not call these options more direct matches? We also have libjpeg
usage in the virtual pipeline handler:

  -Dlibjpeg=enabled -DSDL2=enabled -Dlibdrm=disabled

and EGL might have a hidden dependency on libdrm:

src/libcamera/egl.cpp:#include <libdrm/drm_fourcc.h>


> 
> With that,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

I won't object to these though! Above is only a thought/comment.

> 
> >  
> >  if libdrm.found()
> >      cam_cpp_args += [ '-DHAVE_KMS' ]
> > @@ -27,6 +36,9 @@ if libdrm.found()
> >          'drm.cpp',
> >          'kms_sink.cpp'
> >      ])
> > +    cam_deps += [
> > +        libdrm,
> > +    ]
> >  endif
> >  
> >  if libsdl2.found()
> > @@ -37,28 +49,24 @@ if libsdl2.found()
> >          'sdl_texture_1plane.cpp',
> >          'sdl_texture_yuv.cpp',
> >      ])
> > +    cam_deps += [
> > +        libsdl2,
> > +    ]
> >  
> >      if libjpeg.found()
> >          cam_cpp_args += ['-DHAVE_LIBJPEG']
> >          cam_sources += files([
> >              'sdl_texture_mjpg.cpp'
> >          ])
> > +        cam_deps += [
> > +            libjpeg,
> > +        ]
> >      endif
> >  endif
> >  
> >  cam  = executable('cam', cam_sources,
> >                    link_with : apps_lib,
> > -                  dependencies : [
> > -                      libatomic,
> > -                      libcamera_public,
> > -                      libdrm,
> > -                      libevent,
> > -                      libjpeg,
> > -                      libsdl2,
> > -                      libtiff,
> > -                      libthreads,
> > -                      libyaml,
> > -                  ],
> > +                  dependencies : cam_deps,
> >                    cpp_args : cam_cpp_args,
> >                    install : true,
> >                    install_tag : 'bin')
> 
> -- 
> Regards,
> 
> Laurent Pinchart
Laurent Pinchart Feb. 6, 2026, 1:14 a.m. UTC | #4
On Fri, Feb 06, 2026 at 01:04:29AM +0000, Kieran Bingham wrote:
> Quoting Laurent Pinchart (2026-02-06 00:55:02)
> > On Fri, Jan 30, 2026 at 12:11:33PM +0100, Barnabás Pőcze wrote:
> > > Previously it was not possible to control these dependencies, they were
> > > always used if found. Furthermore, libjpeg was unnecessarily added as a
> > > dependency even if sdl2 was not found. Fix that by introducing three
> > > options to control the dependencies.
> > > 
> > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > > ---
> > >  meson_options.txt        | 15 +++++++++++++++
> > >  src/apps/cam/meson.build | 36 ++++++++++++++++++++++--------------
> > >  2 files changed, 37 insertions(+), 14 deletions(-)
> > > 
> > > diff --git a/meson_options.txt b/meson_options.txt
> > > index 8121cf5d2..58cf52ad1 100644
> > > --- a/meson_options.txt
> > > +++ b/meson_options.txt
> > > @@ -16,6 +16,21 @@ option('cam',
> > >          value : 'auto',
> > >          description : 'Compile the cam test application')
> > >  
> > > +option('cam-output-kms',
> > > +        type : 'feature',
> > > +        value : 'auto',
> > > +        description : 'Enable KMS output in the cam application')
> > > +
> > > +option('cam-output-sdl2',
> > > +        type : 'feature',
> > > +        value : 'auto',
> > > +        description : 'Enable SDL2 output in the cam application')
> > > +
> > > +option('cam-output-sdl2-jpeg',
> > > +        type : 'feature',
> > > +        value : 'auto',
> > > +        description : 'Enable JPEG support in the SDL2 output in the cam application')
> > > +
> > >  option('documentation',
> > >          type : 'feature',
> > >          value : 'auto',
> > > diff --git a/src/apps/cam/meson.build b/src/apps/cam/meson.build
> > > index cd7f120f9..c73c0f5d9 100644
> > > --- a/src/apps/cam/meson.build
> > > +++ b/src/apps/cam/meson.build
> > > @@ -17,9 +17,18 @@ cam_sources = files([
> > >  
> > >  cam_cpp_args = [apps_cpp_args]
> > >  
> > > -libdrm = dependency('libdrm', required : false)
> > > -libjpeg = dependency('libjpeg', required : false)
> > > -libsdl2 = dependency('SDL2', required : false)
> > > +cam_deps = [
> > > +    libatomic,
> > > +    libcamera_public,
> > > +    libevent,
> > > +    libthreads,
> > > +    libyaml,
> > > +    libtiff,
> > > +]
> > > +
> > > +libdrm = dependency('libdrm', required : get_option('cam-output-kms'))
> > > +libsdl2 = dependency('SDL2', required : get_option('cam-output-sdl2'))
> > > +libjpeg = dependency('libjpeg', required : get_option('cam-output-sdl2-jpeg'))
> > 
> > I wonder if we could combine the cam-output-sdl2 and
> > cam-output-sdl2-jpeg options here to avoid looking up libjpeg if SDL2 is
> > disabled, but it's probably not worth it.
> > 
> > Actually, I think we should support JPEG decompression with the KMS
> > output as well, in which case the option would become cam-jpeg (or
> > something similar). We could already name it like that, to avoid
> > renaming it later.
> 
> Why not call these options more direct matches? We also have libjpeg
> usage in the virtual pipeline handler:
> 
>   -Dlibjpeg=enabled -DSDL2=enabled -Dlibdrm=disabled

We may want to for instance enable JPEG support in cam but not in the
virtual pipeline handler. I think focussing on the features we enable
instead of the dependency is clearer for the user (but I could be
wrong).

> and EGL might have a hidden dependency on libdrm:
> 
> src/libcamera/egl.cpp:#include <libdrm/drm_fourcc.h>

The main problem with hidden dependencies is linking to shared library,
so this one is likely not an issue in practice. This being said, we
could use our own copy of drm_fourcc.h.

> > With that,
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> I won't object to these though! Above is only a thought/comment.
> 
> > >  
> > >  if libdrm.found()
> > >      cam_cpp_args += [ '-DHAVE_KMS' ]
> > > @@ -27,6 +36,9 @@ if libdrm.found()
> > >          'drm.cpp',
> > >          'kms_sink.cpp'
> > >      ])
> > > +    cam_deps += [
> > > +        libdrm,
> > > +    ]
> > >  endif
> > >  
> > >  if libsdl2.found()
> > > @@ -37,28 +49,24 @@ if libsdl2.found()
> > >          'sdl_texture_1plane.cpp',
> > >          'sdl_texture_yuv.cpp',
> > >      ])
> > > +    cam_deps += [
> > > +        libsdl2,
> > > +    ]
> > >  
> > >      if libjpeg.found()
> > >          cam_cpp_args += ['-DHAVE_LIBJPEG']
> > >          cam_sources += files([
> > >              'sdl_texture_mjpg.cpp'
> > >          ])
> > > +        cam_deps += [
> > > +            libjpeg,
> > > +        ]
> > >      endif
> > >  endif
> > >  
> > >  cam  = executable('cam', cam_sources,
> > >                    link_with : apps_lib,
> > > -                  dependencies : [
> > > -                      libatomic,
> > > -                      libcamera_public,
> > > -                      libdrm,
> > > -                      libevent,
> > > -                      libjpeg,
> > > -                      libsdl2,
> > > -                      libtiff,
> > > -                      libthreads,
> > > -                      libyaml,
> > > -                  ],
> > > +                  dependencies : cam_deps,
> > >                    cpp_args : cam_cpp_args,
> > >                    install : true,
> > >                    install_tag : 'bin')
Barnabás Pőcze Feb. 6, 2026, 8:06 a.m. UTC | #5
2026. 02. 06. 2:14 keltezéssel, Laurent Pinchart írta:
> On Fri, Feb 06, 2026 at 01:04:29AM +0000, Kieran Bingham wrote:
>> Quoting Laurent Pinchart (2026-02-06 00:55:02)
>>> On Fri, Jan 30, 2026 at 12:11:33PM +0100, Barnabás Pőcze wrote:
>>>> Previously it was not possible to control these dependencies, they were
>>>> always used if found. Furthermore, libjpeg was unnecessarily added as a
>>>> dependency even if sdl2 was not found. Fix that by introducing three
>>>> options to control the dependencies.
>>>>
>>>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
>>>> ---
>>>>   meson_options.txt        | 15 +++++++++++++++
>>>>   src/apps/cam/meson.build | 36 ++++++++++++++++++++++--------------
>>>>   2 files changed, 37 insertions(+), 14 deletions(-)
>>>>
>>>> diff --git a/meson_options.txt b/meson_options.txt
>>>> index 8121cf5d2..58cf52ad1 100644
>>>> --- a/meson_options.txt
>>>> +++ b/meson_options.txt
>>>> @@ -16,6 +16,21 @@ option('cam',
>>>>           value : 'auto',
>>>>           description : 'Compile the cam test application')
>>>>   
>>>> +option('cam-output-kms',
>>>> +        type : 'feature',
>>>> +        value : 'auto',
>>>> +        description : 'Enable KMS output in the cam application')
>>>> +
>>>> +option('cam-output-sdl2',
>>>> +        type : 'feature',
>>>> +        value : 'auto',
>>>> +        description : 'Enable SDL2 output in the cam application')
>>>> +
>>>> +option('cam-output-sdl2-jpeg',
>>>> +        type : 'feature',
>>>> +        value : 'auto',
>>>> +        description : 'Enable JPEG support in the SDL2 output in the cam application')
>>>> +
>>>>   option('documentation',
>>>>           type : 'feature',
>>>>           value : 'auto',
>>>> diff --git a/src/apps/cam/meson.build b/src/apps/cam/meson.build
>>>> index cd7f120f9..c73c0f5d9 100644
>>>> --- a/src/apps/cam/meson.build
>>>> +++ b/src/apps/cam/meson.build
>>>> @@ -17,9 +17,18 @@ cam_sources = files([
>>>>   
>>>>   cam_cpp_args = [apps_cpp_args]
>>>>   
>>>> -libdrm = dependency('libdrm', required : false)
>>>> -libjpeg = dependency('libjpeg', required : false)
>>>> -libsdl2 = dependency('SDL2', required : false)
>>>> +cam_deps = [
>>>> +    libatomic,
>>>> +    libcamera_public,
>>>> +    libevent,
>>>> +    libthreads,
>>>> +    libyaml,
>>>> +    libtiff,
>>>> +]
>>>> +
>>>> +libdrm = dependency('libdrm', required : get_option('cam-output-kms'))
>>>> +libsdl2 = dependency('SDL2', required : get_option('cam-output-sdl2'))
>>>> +libjpeg = dependency('libjpeg', required : get_option('cam-output-sdl2-jpeg'))
>>>
>>> I wonder if we could combine the cam-output-sdl2 and
>>> cam-output-sdl2-jpeg options here to avoid looking up libjpeg if SDL2 is
>>> disabled, but it's probably not worth it.
>>>
>>> Actually, I think we should support JPEG decompression with the KMS
>>> output as well, in which case the option would become cam-jpeg (or
>>> something similar). We could already name it like that, to avoid
>>> renaming it later.
>>
>> Why not call these options more direct matches? We also have libjpeg
>> usage in the virtual pipeline handler:
>>
>>    -Dlibjpeg=enabled -DSDL2=enabled -Dlibdrm=disabled
> 
> We may want to for instance enable JPEG support in cam but not in the
> virtual pipeline handler. I think focussing on the features we enable
> instead of the dependency is clearer for the user (but I could be
> wrong).

This is indeed the motivation. I also think it is more useful to be
able to say "I want this feature of this component" instead of having
to list a (potentially changing) list of dependency names (that might
also enable some other unwanted things).

Although admittedly it results in a somewhat more complicated dependency
management than having a single global switch for each.

Thoughts? Should we go with "feature options control features components"
or "feature options control specific dependencies"?


> 
>> and EGL might have a hidden dependency on libdrm:
>>
>> src/libcamera/egl.cpp:#include <libdrm/drm_fourcc.h>
> 
> The main problem with hidden dependencies is linking to shared library,
> so this one is likely not an issue in practice. This being said, we
> could use our own copy of drm_fourcc.h.
> 
>>> With that,
>>>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>
>> I won't object to these though! Above is only a thought/comment.
>>
>>>>   
>>>>   if libdrm.found()
>>>>       cam_cpp_args += [ '-DHAVE_KMS' ]
>>>> @@ -27,6 +36,9 @@ if libdrm.found()
>>>>           'drm.cpp',
>>>>           'kms_sink.cpp'
>>>>       ])
>>>> +    cam_deps += [
>>>> +        libdrm,
>>>> +    ]
>>>>   endif
>>>>   
>>>>   if libsdl2.found()
>>>> @@ -37,28 +49,24 @@ if libsdl2.found()
>>>>           'sdl_texture_1plane.cpp',
>>>>           'sdl_texture_yuv.cpp',
>>>>       ])
>>>> +    cam_deps += [
>>>> +        libsdl2,
>>>> +    ]
>>>>   
>>>>       if libjpeg.found()
>>>>           cam_cpp_args += ['-DHAVE_LIBJPEG']
>>>>           cam_sources += files([
>>>>               'sdl_texture_mjpg.cpp'
>>>>           ])
>>>> +        cam_deps += [
>>>> +            libjpeg,
>>>> +        ]
>>>>       endif
>>>>   endif
>>>>   
>>>>   cam  = executable('cam', cam_sources,
>>>>                     link_with : apps_lib,
>>>> -                  dependencies : [
>>>> -                      libatomic,
>>>> -                      libcamera_public,
>>>> -                      libdrm,
>>>> -                      libevent,
>>>> -                      libjpeg,
>>>> -                      libsdl2,
>>>> -                      libtiff,
>>>> -                      libthreads,
>>>> -                      libyaml,
>>>> -                  ],
>>>> +                  dependencies : cam_deps,
>>>>                     cpp_args : cam_cpp_args,
>>>>                     install : true,
>>>>                     install_tag : 'bin')
>

Patch
diff mbox series

diff --git a/meson_options.txt b/meson_options.txt
index 8121cf5d2..58cf52ad1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -16,6 +16,21 @@  option('cam',
         value : 'auto',
         description : 'Compile the cam test application')
 
+option('cam-output-kms',
+        type : 'feature',
+        value : 'auto',
+        description : 'Enable KMS output in the cam application')
+
+option('cam-output-sdl2',
+        type : 'feature',
+        value : 'auto',
+        description : 'Enable SDL2 output in the cam application')
+
+option('cam-output-sdl2-jpeg',
+        type : 'feature',
+        value : 'auto',
+        description : 'Enable JPEG support in the SDL2 output in the cam application')
+
 option('documentation',
         type : 'feature',
         value : 'auto',
diff --git a/src/apps/cam/meson.build b/src/apps/cam/meson.build
index cd7f120f9..c73c0f5d9 100644
--- a/src/apps/cam/meson.build
+++ b/src/apps/cam/meson.build
@@ -17,9 +17,18 @@  cam_sources = files([
 
 cam_cpp_args = [apps_cpp_args]
 
-libdrm = dependency('libdrm', required : false)
-libjpeg = dependency('libjpeg', required : false)
-libsdl2 = dependency('SDL2', required : false)
+cam_deps = [
+    libatomic,
+    libcamera_public,
+    libevent,
+    libthreads,
+    libyaml,
+    libtiff,
+]
+
+libdrm = dependency('libdrm', required : get_option('cam-output-kms'))
+libsdl2 = dependency('SDL2', required : get_option('cam-output-sdl2'))
+libjpeg = dependency('libjpeg', required : get_option('cam-output-sdl2-jpeg'))
 
 if libdrm.found()
     cam_cpp_args += [ '-DHAVE_KMS' ]
@@ -27,6 +36,9 @@  if libdrm.found()
         'drm.cpp',
         'kms_sink.cpp'
     ])
+    cam_deps += [
+        libdrm,
+    ]
 endif
 
 if libsdl2.found()
@@ -37,28 +49,24 @@  if libsdl2.found()
         'sdl_texture_1plane.cpp',
         'sdl_texture_yuv.cpp',
     ])
+    cam_deps += [
+        libsdl2,
+    ]
 
     if libjpeg.found()
         cam_cpp_args += ['-DHAVE_LIBJPEG']
         cam_sources += files([
             'sdl_texture_mjpg.cpp'
         ])
+        cam_deps += [
+            libjpeg,
+        ]
     endif
 endif
 
 cam  = executable('cam', cam_sources,
                   link_with : apps_lib,
-                  dependencies : [
-                      libatomic,
-                      libcamera_public,
-                      libdrm,
-                      libevent,
-                      libjpeg,
-                      libsdl2,
-                      libtiff,
-                      libthreads,
-                      libyaml,
-                  ],
+                  dependencies : cam_deps,
                   cpp_args : cam_cpp_args,
                   install : true,
                   install_tag : 'bin')