[libcamera-devel] qcam: Fix compilation errors with gcc-9 and Qt < 5.13

Message ID 20190913180132.31000-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 304574420d0dd5949e73df9e238eb136a21af1a3
Headers show
Series
  • [libcamera-devel] qcam: Fix compilation errors with gcc-9 and Qt < 5.13
Related show

Commit Message

Laurent Pinchart Sept. 13, 2019, 6:01 p.m. UTC
gcc-9 has introduced a deprecated-copy warning that is triggered by Qt
header files. The issue has been fixed in Qt 5.13. Fix compilation with
earlier Qt versions by disabling the warning. In order to still benefit
from the warning when possible, only disable it for gcc-9 and Qt < 5.13.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/qcam/meson.build | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Niklas Söderlund Sept. 13, 2019, 7:06 p.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2019-09-13 21:01:32 +0300, Laurent Pinchart wrote:
> gcc-9 has introduced a deprecated-copy warning that is triggered by Qt
> header files. The issue has been fixed in Qt 5.13. Fix compilation with
> earlier Qt versions by disabling the warning. In order to still benefit
> from the warning when possible, only disable it for gcc-9 and Qt < 5.13.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/qcam/meson.build | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qcam/meson.build b/src/qcam/meson.build
> index 21f91f25cec0..1e71f20fa15e 100644
> --- a/src/qcam/meson.build
> +++ b/src/qcam/meson.build
> @@ -18,11 +18,23 @@ qt5_dep = dependency('qt5',
>                       required : false)
>  
>  if qt5_dep.found()
> +    qt5_cpp_args = [ '-DQT_NO_KEYWORDS' ]
> +
> +    # gcc 9 introduced a deprecated-copy warning that is triggered by Qt until
> +    # Qt 5.13. Disable it manually.
> +    if cc.get_id() == 'gcc'
> +        gcc_version = cc.version().split('.')
> +        qt5_version = qt5_dep.version().split('.')
> +        if qt5_version[1].to_int() < 13 and gcc_version[0].to_int() >= 9
> +            qt5_cpp_args += [ '-Wno-deprecated-copy' ]
> +        endif
> +    endif
> +
>      moc_files = qt5.preprocess(moc_headers: qcam_moc_headers,
>                                 dependencies: qt5_dep)
>  
>      qcam  = executable('qcam', qcam_sources, moc_files,
>                         install : true,
>                         dependencies : [libcamera_dep, qt5_dep],
> -                       cpp_args : '-DQT_NO_KEYWORDS')
> +                       cpp_args : qt5_cpp_args)
>  endif
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/qcam/meson.build b/src/qcam/meson.build
index 21f91f25cec0..1e71f20fa15e 100644
--- a/src/qcam/meson.build
+++ b/src/qcam/meson.build
@@ -18,11 +18,23 @@  qt5_dep = dependency('qt5',
                      required : false)
 
 if qt5_dep.found()
+    qt5_cpp_args = [ '-DQT_NO_KEYWORDS' ]
+
+    # gcc 9 introduced a deprecated-copy warning that is triggered by Qt until
+    # Qt 5.13. Disable it manually.
+    if cc.get_id() == 'gcc'
+        gcc_version = cc.version().split('.')
+        qt5_version = qt5_dep.version().split('.')
+        if qt5_version[1].to_int() < 13 and gcc_version[0].to_int() >= 9
+            qt5_cpp_args += [ '-Wno-deprecated-copy' ]
+        endif
+    endif
+
     moc_files = qt5.preprocess(moc_headers: qcam_moc_headers,
                                dependencies: qt5_dep)
 
     qcam  = executable('qcam', qcam_sources, moc_files,
                        install : true,
                        dependencies : [libcamera_dep, qt5_dep],
-                       cpp_args : '-DQT_NO_KEYWORDS')
+                       cpp_args : qt5_cpp_args)
 endif