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

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

Commit Message

Barnabás Pőcze March 23, 2026, 7:49 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>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
changes in v2:
  * rename option from `cam-output-sdl2-jpeg` to `cam-jpeg`

v1: https://patchwork.libcamera.org/patch/26055/
---
 meson_options.txt        | 15 +++++++++++++++
 src/apps/cam/meson.build | 36 ++++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 14 deletions(-)

--
2.53.0

Patch
diff mbox series

diff --git a/meson_options.txt b/meson_options.txt
index c27e377ad..8bf6c2bd5 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-jpeg',
+        type : 'feature',
+        value : 'auto',
+        description : 'Enable JPEG support 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..0fd846270 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-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')