[v2,1/2] pipeline: virtual: Move libjpeg requirement to libyuv subproject
diff mbox series

Message ID 20260626092847.289764-2-robert.mader@collabora.com
State New
Headers show
Series
  • meson: Build virtual pipeline by default
Related show

Commit Message

Robert Mader June 26, 2026, 9:28 a.m. UTC
libyuv already depends on libjpeg. The requirement for the later is only
needed if libyuv is build from the subproject fallback, thus move the
requirement accordingly. This allows the virtual pipeline to be build
with only libyuv development files installed - and without libjpeg ones.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
---
 src/libcamera/pipeline/virtual/meson.build | 3 ---
 src/meson.build                            | 4 +++-
 2 files changed, 3 insertions(+), 4 deletions(-)

Comments

Kieran Bingham June 26, 2026, 10:02 a.m. UTC | #1
Quoting Robert Mader (2026-06-26 10:28:46)
> libyuv already depends on libjpeg. The requirement for the later is only
> needed if libyuv is build from the subproject fallback, thus move the
> requirement accordingly. This allows the virtual pipeline to be build
> with only libyuv development files installed - and without libjpeg ones.
> 
> Signed-off-by: Robert Mader <robert.mader@collabora.com>

Looks good to me.


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

> ---
>  src/libcamera/pipeline/virtual/meson.build | 3 ---
>  src/meson.build                            | 4 +++-
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/virtual/meson.build b/src/libcamera/pipeline/virtual/meson.build
> index c84345936..19fde9cf8 100644
> --- a/src/libcamera/pipeline/virtual/meson.build
> +++ b/src/libcamera/pipeline/virtual/meson.build
> @@ -7,9 +7,6 @@ libcamera_internal_sources += files([
>      'virtual.cpp',
>  ])
>  
> -libjpeg = dependency('libjpeg', required : true)
> -
>  libcamera_deps += [libyuv_dep]
> -libcamera_deps += [libjpeg]
>  
>  subdir('data')
> diff --git a/src/meson.build b/src/meson.build
> index 9b63c8e84..8e23d40c3 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -46,6 +46,8 @@ if (pipelines.contains('virtual') or get_option('android').allowed()) and \
>     not libyuv_dep.found()
>      cmake = import('cmake')
>  
> +    libjpeg = dependency('libjpeg', required : true)
> +
>      libyuv_vars = cmake.subproject_options()
>      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
>      libyuv_vars.set_override_option('cpp_std', 'c++17')
> @@ -64,7 +66,7 @@ if (pipelines.contains('virtual') or get_option('android').allowed()) and \
>      # Work around the issue by wrapping the libyuv static library into another
>      # static library with 'pic' set to true.
>      libyuv_static = static_library('libyuv-static',
> -                                   dependencies : libyuv.dependency('yuv'),
> +                                   dependencies : [libyuv.dependency('yuv'), libjpeg],
>                                     pic : true,
>                                     install : false)
>      libyuv_include = libyuv.include_directories('yuv')
> -- 
> 2.54.0
>
Laurent Pinchart June 26, 2026, 10:48 a.m. UTC | #2
On Fri, Jun 26, 2026 at 11:28:46AM +0200, Robert Mader wrote:
> libyuv already depends on libjpeg. The requirement for the later is only
> needed if libyuv is build from the subproject fallback, thus move the
> requirement accordingly. This allows the virtual pipeline to be build
> with only libyuv development files installed - and without libjpeg ones.
> 
> Signed-off-by: Robert Mader <robert.mader@collabora.com>
> ---
>  src/libcamera/pipeline/virtual/meson.build | 3 ---
>  src/meson.build                            | 4 +++-
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/virtual/meson.build b/src/libcamera/pipeline/virtual/meson.build
> index c84345936..19fde9cf8 100644
> --- a/src/libcamera/pipeline/virtual/meson.build
> +++ b/src/libcamera/pipeline/virtual/meson.build
> @@ -7,9 +7,6 @@ libcamera_internal_sources += files([
>      'virtual.cpp',
>  ])
>  
> -libjpeg = dependency('libjpeg', required : true)
> -
>  libcamera_deps += [libyuv_dep]
> -libcamera_deps += [libjpeg]
>  
>  subdir('data')
> diff --git a/src/meson.build b/src/meson.build
> index 9b63c8e84..8e23d40c3 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -46,6 +46,8 @@ if (pipelines.contains('virtual') or get_option('android').allowed()) and \
>     not libyuv_dep.found()
>      cmake = import('cmake')
>  
> +    libjpeg = dependency('libjpeg', required : true)
> +
>      libyuv_vars = cmake.subproject_options()
>      libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
>      libyuv_vars.set_override_option('cpp_std', 'c++17')
> @@ -64,7 +66,7 @@ if (pipelines.contains('virtual') or get_option('android').allowed()) and \
>      # Work around the issue by wrapping the libyuv static library into another
>      # static library with 'pic' set to true.
>      libyuv_static = static_library('libyuv-static',
> -                                   dependencies : libyuv.dependency('yuv'),
> +                                   dependencies : [libyuv.dependency('yuv'), libjpeg],

The meson.build generated in the libyuv subproject contains the
following:

yuv = static_library(
  'yuv',
  yuv_src,
  build_by_default : true,
  link_args : ['-ljpeg'],
  link_with : [],
  include_directories : yuv_inc,
  install : true,
  override_options : ['cpp_std=c++17'],
  objects : [
    yuv_common_objects.extract_all_objects(),
    yuv_neon.extract_all_objects()
  ],
  install_dir : 'lib',
  c_args : [],
  pic : false
)
yuv_dep = declare_dependency(
  link_with : yuv,
  compile_args : [],
  include_directories : yuv_inc,
  link_args : []
)

We then wrap yuv_dep into another static library. The -ljpeg link flag
is lost somewhere along the way. I wonder if that's a bug in meson.

For the time being this seems a proper workaround. The commit message
could be improved though.

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

>                                     pic : true,
>                                     install : false)
>      libyuv_include = libyuv.include_directories('yuv')
Barnabás Pőcze June 26, 2026, 11:27 a.m. UTC | #3
2026. 06. 26. 12:48 keltezéssel, Laurent Pinchart írta:
> On Fri, Jun 26, 2026 at 11:28:46AM +0200, Robert Mader wrote:
>> libyuv already depends on libjpeg. The requirement for the later is only
>> needed if libyuv is build from the subproject fallback, thus move the
>> requirement accordingly. This allows the virtual pipeline to be build
>> with only libyuv development files installed - and without libjpeg ones.
>>
>> Signed-off-by: Robert Mader <robert.mader@collabora.com>
>> ---
>>   src/libcamera/pipeline/virtual/meson.build | 3 ---
>>   src/meson.build                            | 4 +++-
>>   2 files changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/libcamera/pipeline/virtual/meson.build b/src/libcamera/pipeline/virtual/meson.build
>> index c84345936..19fde9cf8 100644
>> --- a/src/libcamera/pipeline/virtual/meson.build
>> +++ b/src/libcamera/pipeline/virtual/meson.build
>> @@ -7,9 +7,6 @@ libcamera_internal_sources += files([
>>       'virtual.cpp',
>>   ])
>>   
>> -libjpeg = dependency('libjpeg', required : true)
>> -
>>   libcamera_deps += [libyuv_dep]
>> -libcamera_deps += [libjpeg]
>>   
>>   subdir('data')
>> diff --git a/src/meson.build b/src/meson.build
>> index 9b63c8e84..8e23d40c3 100644
>> --- a/src/meson.build
>> +++ b/src/meson.build
>> @@ -46,6 +46,8 @@ if (pipelines.contains('virtual') or get_option('android').allowed()) and \
>>      not libyuv_dep.found()
>>       cmake = import('cmake')
>>   
>> +    libjpeg = dependency('libjpeg', required : true)
>> +
>>       libyuv_vars = cmake.subproject_options()
>>       libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
>>       libyuv_vars.set_override_option('cpp_std', 'c++17')
>> @@ -64,7 +66,7 @@ if (pipelines.contains('virtual') or get_option('android').allowed()) and \
>>       # Work around the issue by wrapping the libyuv static library into another
>>       # static library with 'pic' set to true.
>>       libyuv_static = static_library('libyuv-static',
>> -                                   dependencies : libyuv.dependency('yuv'),
>> +                                   dependencies : [libyuv.dependency('yuv'), libjpeg],
> 
> The meson.build generated in the libyuv subproject contains the
> following:
> 
> yuv = static_library(
>    'yuv',
>    yuv_src,
>    build_by_default : true,
>    link_args : ['-ljpeg'],
>    link_with : [],
>    include_directories : yuv_inc,
>    install : true,
>    override_options : ['cpp_std=c++17'],
>    objects : [
>      yuv_common_objects.extract_all_objects(),
>      yuv_neon.extract_all_objects()
>    ],
>    install_dir : 'lib',
>    c_args : [],
>    pic : false
> )
> yuv_dep = declare_dependency(
>    link_with : yuv,
>    compile_args : [],
>    include_directories : yuv_inc,
>    link_args : []
> )
> 
> We then wrap yuv_dep into another static library. The -ljpeg link flag
> is lost somewhere along the way. I wonder if that's a bug in meson.

The upstream cmake files does not seem to mention libjpeg at all, so probably not. It's
not entirely surprising given that there files for n+1 build systems in the upstream project.


> 
> For the time being this seems a proper workaround. The commit message
> could be improved though.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>>                                      pic : true,
>>                                      install : false)
>>       libyuv_include = libyuv.include_directories('yuv')
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/virtual/meson.build b/src/libcamera/pipeline/virtual/meson.build
index c84345936..19fde9cf8 100644
--- a/src/libcamera/pipeline/virtual/meson.build
+++ b/src/libcamera/pipeline/virtual/meson.build
@@ -7,9 +7,6 @@  libcamera_internal_sources += files([
     'virtual.cpp',
 ])
 
-libjpeg = dependency('libjpeg', required : true)
-
 libcamera_deps += [libyuv_dep]
-libcamera_deps += [libjpeg]
 
 subdir('data')
diff --git a/src/meson.build b/src/meson.build
index 9b63c8e84..8e23d40c3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -46,6 +46,8 @@  if (pipelines.contains('virtual') or get_option('android').allowed()) and \
    not libyuv_dep.found()
     cmake = import('cmake')
 
+    libjpeg = dependency('libjpeg', required : true)
+
     libyuv_vars = cmake.subproject_options()
     libyuv_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
     libyuv_vars.set_override_option('cpp_std', 'c++17')
@@ -64,7 +66,7 @@  if (pipelines.contains('virtual') or get_option('android').allowed()) and \
     # Work around the issue by wrapping the libyuv static library into another
     # static library with 'pic' set to true.
     libyuv_static = static_library('libyuv-static',
-                                   dependencies : libyuv.dependency('yuv'),
+                                   dependencies : [libyuv.dependency('yuv'), libjpeg],
                                    pic : true,
                                    install : false)
     libyuv_include = libyuv.include_directories('yuv')