diff mbox series

[07/34] configure, meson: move OpenGL check to meson

Message ID 20220420153407.73926-8-pbonzini@redhat.com
State New
Headers show
Series Misc meson conversions for QEMU 7.1 | expand

Commit Message

Paolo Bonzini April 20, 2022, 3:33 p.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure                     | 40 -----------------------------------
 meson.build                   | 16 +++++++++-----
 meson_options.txt             |  2 ++
 scripts/meson-buildoptions.sh |  3 +++
 ui/meson.build                | 17 ++++++++-------
 5 files changed, 25 insertions(+), 53 deletions(-)

Comments

Marc-André Lureau April 20, 2022, 4:13 p.m. UTC | #1
Hi

On Wed, Apr 20, 2022 at 7:52 PM Paolo Bonzini <pbonzini@redhat.com> wrote:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  configure                     | 40 -----------------------------------
>  meson.build                   | 16 +++++++++-----
>  meson_options.txt             |  2 ++
>  scripts/meson-buildoptions.sh |  3 +++
>  ui/meson.build                | 17 ++++++++-------
>  5 files changed, 25 insertions(+), 53 deletions(-)
>
> diff --git a/configure b/configure
> index 07053e7b27..c9be6eb04d 100755
> --- a/configure
> +++ b/configure
> @@ -321,7 +321,6 @@ bsd_user=""
>  pkgversion=""
>  pie=""
>  trace_file="trace"
> -opengl="$default_feature"
>  coroutine=""
>  tls_priority="NORMAL"
>  plugins="$default_feature"
> @@ -960,10 +959,6 @@ for opt do
>    ;;
>    --enable-vhost-user-fs) vhost_user_fs="yes"
>    ;;
> -  --disable-opengl) opengl="no"
> -  ;;
> -  --enable-opengl) opengl="yes"
> -  ;;
>    --disable-zlib-test)
>    ;;
>    --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
> @@ -1258,7 +1253,6 @@ cat << EOF
>    vhost-kernel    vhost kernel backend support
>    vhost-user      vhost-user backend support
>    vhost-vdpa      vhost-vdpa kernel backend support
> -  opengl          opengl support
>    gio             libgio support
>
>  NOTE: The object files are built at the place where configure is launched
> @@ -2278,34 +2272,6 @@ case "$fdt" in
>  esac
>
>  ##########################################
> -# opengl probe (for sdl2, gtk)
> -
> -if test "$opengl" != "no" ; then
> -  epoxy=no
> -  if $pkg_config epoxy; then
> -    cat > $TMPC << EOF
> -#include <epoxy/egl.h>
> -int main(void) { return 0; }
> -EOF
> -    if compile_prog "" "" ; then
> -      epoxy=yes
> -    fi
> -  fi
> -
> -  if test "$epoxy" = "yes" ; then
> -    opengl_cflags="$($pkg_config --cflags epoxy)"
> -    opengl_libs="$($pkg_config --libs epoxy)"
> -    opengl=yes
> -  else
> -    if test "$opengl" = "yes" ; then
> -      feature_not_found "opengl" "Please install epoxy with EGL"
> -    fi
> -    opengl_cflags=""
> -    opengl_libs=""
> -    opengl=no
> -  fi
> -fi
> -
>  # check for usbfs
>  have_usbfs=no
>  if test "$linux_user" = "yes"; then
> @@ -2874,12 +2840,6 @@ if test "$vhost_user_fs" = "yes" ; then
>    echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
>  fi
>
> -if test "$opengl" = "yes" ; then
> -  echo "CONFIG_OPENGL=y" >> $config_host_mak
> -  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
> -  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
> -fi
> -
>  # XXX: suppress that
>  if [ "$bsd" = "yes" ] ; then
>    echo "CONFIG_BSD=y" >> $config_host_mak
> diff --git a/meson.build b/meson.build
> index cf3b1b39cf..f53fd66716 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1000,9 +1000,14 @@ if not get_option('coreaudio').auto() or (targetos
> == 'darwin' and have_system)
>  endif
>
>  opengl = not_found
> -if 'CONFIG_OPENGL' in config_host
> -  opengl = declare_dependency(compile_args:
> config_host['OPENGL_CFLAGS'].split(),
> -                              link_args:
> config_host['OPENGL_LIBS'].split())
> +if not get_option('opengl').auto() or have_system or have_vhost_user_gpu
> +  epoxy = dependency('epoxy', method: 'pkg-config',
> +                      required: get_option('opengl'), kwargs:
> static_kwargs)
> +  if cc.has_header('epoxy/egl.h', dependencies: epoxy)
> +    opengl = epoxy
> +  elif get_option('opengl').enabled()
> +    error('epoxy/egl.h not found')
> +  endif
>  endif
>  gbm = not_found
>  if (have_system or have_tools) and (virgl.found() or opengl.found())
> @@ -1544,6 +1549,7 @@ config_host_data.set('CONFIG_LINUX_AIO',
> libaio.found())
>  config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
>  config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
>  config_host_data.set('CONFIG_NUMA', numa.found())
> +config_host_data.set('CONFIG_OPENGL', opengl.found())
>  config_host_data.set('CONFIG_PROFILER', get_option('profiler'))
>  config_host_data.set('CONFIG_RBD', rbd.found())
>  config_host_data.set('CONFIG_SDL', sdl.found())
> @@ -2079,7 +2085,7 @@ host_kconfig = \
>    (have_tpm ? ['CONFIG_TPM=y'] : []) + \
>    (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
>    (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
> -  ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
> +  (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \
>    (x11.found() ? ['CONFIG_X11=y'] : []) + \
>    ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
>    ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
> @@ -3694,7 +3700,7 @@ summary_info += {'smartcard support': cacard}
>  summary_info += {'U2F support':       u2f}
>  summary_info += {'libusb':            libusb}
>  summary_info += {'usb net redir':     usbredir}
> -summary_info += {'OpenGL support':
> config_host.has_key('CONFIG_OPENGL')}
> +summary_info += {'OpenGL support (epoxy)': opengl}
>  summary_info += {'GBM':               gbm}
>  summary_info += {'libiscsi support':  libiscsi}
>  summary_info += {'libnfs support':    libnfs}
> diff --git a/meson_options.txt b/meson_options.txt
> index 52b11cead4..bd8efe4fbf 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -149,6 +149,8 @@ option('lzo', type : 'feature', value : 'auto',
>         description: 'lzo compression support')
>  option('rbd', type : 'feature', value : 'auto',
>         description: 'Ceph block device driver')
> +option('opengl', type : 'feature', value : 'auto',
> +       description: 'OpenGL support')
>  option('gtk', type : 'feature', value : 'auto',
>         description: 'GTK+ user interface')
>  option('sdl', type : 'feature', value : 'auto',
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index 1e26f4571e..f91bd9231b 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -91,6 +91,7 @@ meson_options_help() {
>    printf "%s\n" '  nettle          nettle cryptography support'
>    printf "%s\n" '  numa            libnuma support'
>    printf "%s\n" '  nvmm            NVMM acceleration support'
> +  printf "%s\n" '  opengl          OpenGL support'
>    printf "%s\n" '  oss             OSS sound support'
>    printf "%s\n" '  pa              PulseAudio sound support'
>    printf "%s\n" '  parallels       parallels image format support'
> @@ -271,6 +272,8 @@ _meson_option_parse() {
>      --disable-numa) printf "%s" -Dnuma=disabled ;;
>      --enable-nvmm) printf "%s" -Dnvmm=enabled ;;
>      --disable-nvmm) printf "%s" -Dnvmm=disabled ;;
> +    --enable-opengl) printf "%s" -Dopengl=enabled ;;
> +    --disable-opengl) printf "%s" -Dopengl=disabled ;;
>      --enable-oss) printf "%s" -Doss=enabled ;;
>      --disable-oss) printf "%s" -Doss=disabled ;;
>      --enable-pa) printf "%s" -Dpa=enabled ;;
> diff --git a/ui/meson.build b/ui/meson.build
> index 64286ba150..b21d3d1534 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -1,5 +1,6 @@
>  softmmu_ss.add(pixman)
>  specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: pixman)   # for the
> include path
> +specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)   # for the
> include path
>
>  softmmu_ss.add(files(
>    'clipboard.c',
> @@ -43,7 +44,6 @@ vnc_ss.add(zlib, png, jpeg, gnutls)
>  vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c'))
>  softmmu_ss.add_all(when: vnc, if_true: vnc_ss)
>  softmmu_ss.add(when: vnc, if_false: files('vnc-stubs.c'))
> -specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)
>
>  ui_modules = {}
>
> @@ -53,17 +53,18 @@ if curses.found()
>    ui_modules += {'curses' : curses_ss}
>  endif
>
> -if config_host.has_key('CONFIG_OPENGL')
> +softmmu_ss.add(opengl)
>

I guess this line is superfluous


> +if opengl.found()
>    opengl_ss = ss.source_set()
>    opengl_ss.add(gbm)
> -  opengl_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL'],
> +  opengl_ss.add(when: [opengl, pixman],
>                 if_true: files('shader.c', 'console-gl.c',
> 'egl-helpers.c', 'egl-context.c'))
>    ui_modules += {'opengl' : opengl_ss}
>  endif
>
> -if config_host.has_key('CONFIG_OPENGL') and gbm.found()
> +if opengl.found() and gbm.found()
>    egl_headless_ss = ss.source_set()
> -  egl_headless_ss.add(when: [opengl, gbm, pixman, 'CONFIG_OPENGL'],
> +  egl_headless_ss.add(when: [opengl, gbm, pixman],
>                        if_true: files('egl-headless.c'))
>    ui_modules += {'egl-headless' : egl_headless_ss}
>  endif
> @@ -98,8 +99,8 @@ if gtk.found()
>    gtk_ss = ss.source_set()
>    gtk_ss.add(gtk, vte, pixman, files('gtk.c', 'gtk-clipboard.c'))
>    gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
> -  gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true:
> files('gtk-gl-area.c'))
> -  gtk_ss.add(when: [x11, opengl, 'CONFIG_OPENGL'], if_true:
> files('gtk-egl.c'))
> +  gtk_ss.add(when: opengl, if_true: files('gtk-gl-area.c'))
> +  gtk_ss.add(when: [x11, opengl], if_true: files('gtk-egl.c'))
>    ui_modules += {'gtk' : gtk_ss}
>  endif
>
> @@ -112,7 +113,7 @@ if sdl.found()
>      'sdl2-input.c',
>      'sdl2.c',
>    ))
> -  sdl_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('sdl2-gl.c'))
> +  sdl_ss.add(when: opengl, if_true: files('sdl2-gl.c'))
>    sdl_ss.add(when: x11, if_true: files('x_keymap.c'))
>    ui_modules += {'sdl' : sdl_ss}
>  endif
> --
> 2.35.1
>
>
>
>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Paolo Bonzini April 20, 2022, 7:17 p.m. UTC | #2
Il 20 aprile 2022 18:13:30 CEST, "Marc-André Lureau" <marcandre.lureau@gmail.com> ha scritto:
>> -if config_host.has_key('CONFIG_OPENGL')
>> +softmmu_ss.add(opengl)
>>
>
>I guess this line is superfluous

It's needed for the include path, iirc.

Paolo

>
>
>> +if opengl.found()
>>    opengl_ss = ss.source_set()
>>    opengl_ss.add(gbm)
>> -  opengl_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL'],
>> +  opengl_ss.add(when: [opengl, pixman],
>>                 if_true: files('shader.c', 'console-gl.c',
>> 'egl-helpers.c', 'egl-context.c'))
>>    ui_modules += {'opengl' : opengl_ss}
>>  endif
>>
>> -if config_host.has_key('CONFIG_OPENGL') and gbm.found()
>> +if opengl.found() and gbm.found()
>>    egl_headless_ss = ss.source_set()
>> -  egl_headless_ss.add(when: [opengl, gbm, pixman, 'CONFIG_OPENGL'],
>> +  egl_headless_ss.add(when: [opengl, gbm, pixman],
>>                        if_true: files('egl-headless.c'))
>>    ui_modules += {'egl-headless' : egl_headless_ss}
>>  endif
>> @@ -98,8 +99,8 @@ if gtk.found()
>>    gtk_ss = ss.source_set()
>>    gtk_ss.add(gtk, vte, pixman, files('gtk.c', 'gtk-clipboard.c'))
>>    gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
>> -  gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true:
>> files('gtk-gl-area.c'))
>> -  gtk_ss.add(when: [x11, opengl, 'CONFIG_OPENGL'], if_true:
>> files('gtk-egl.c'))
>> +  gtk_ss.add(when: opengl, if_true: files('gtk-gl-area.c'))
>> +  gtk_ss.add(when: [x11, opengl], if_true: files('gtk-egl.c'))
>>    ui_modules += {'gtk' : gtk_ss}
>>  endif
>>
>> @@ -112,7 +113,7 @@ if sdl.found()
>>      'sdl2-input.c',
>>      'sdl2.c',
>>    ))
>> -  sdl_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('sdl2-gl.c'))
>> +  sdl_ss.add(when: opengl, if_true: files('sdl2-gl.c'))
>>    sdl_ss.add(when: x11, if_true: files('x_keymap.c'))
>>    ui_modules += {'sdl' : sdl_ss}
>>  endif
>> --
>> 2.35.1
>>
>>
>>
>>
>Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
diff mbox series

Patch

diff --git a/configure b/configure
index 07053e7b27..c9be6eb04d 100755
--- a/configure
+++ b/configure
@@ -321,7 +321,6 @@  bsd_user=""
 pkgversion=""
 pie=""
 trace_file="trace"
-opengl="$default_feature"
 coroutine=""
 tls_priority="NORMAL"
 plugins="$default_feature"
@@ -960,10 +959,6 @@  for opt do
   ;;
   --enable-vhost-user-fs) vhost_user_fs="yes"
   ;;
-  --disable-opengl) opengl="no"
-  ;;
-  --enable-opengl) opengl="yes"
-  ;;
   --disable-zlib-test)
   ;;
   --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
@@ -1258,7 +1253,6 @@  cat << EOF
   vhost-kernel    vhost kernel backend support
   vhost-user      vhost-user backend support
   vhost-vdpa      vhost-vdpa kernel backend support
-  opengl          opengl support
   gio             libgio support
 
 NOTE: The object files are built at the place where configure is launched
@@ -2278,34 +2272,6 @@  case "$fdt" in
 esac
 
 ##########################################
-# opengl probe (for sdl2, gtk)
-
-if test "$opengl" != "no" ; then
-  epoxy=no
-  if $pkg_config epoxy; then
-    cat > $TMPC << EOF
-#include <epoxy/egl.h>
-int main(void) { return 0; }
-EOF
-    if compile_prog "" "" ; then
-      epoxy=yes
-    fi
-  fi
-
-  if test "$epoxy" = "yes" ; then
-    opengl_cflags="$($pkg_config --cflags epoxy)"
-    opengl_libs="$($pkg_config --libs epoxy)"
-    opengl=yes
-  else
-    if test "$opengl" = "yes" ; then
-      feature_not_found "opengl" "Please install epoxy with EGL"
-    fi
-    opengl_cflags=""
-    opengl_libs=""
-    opengl=no
-  fi
-fi
-
 # check for usbfs
 have_usbfs=no
 if test "$linux_user" = "yes"; then
@@ -2874,12 +2840,6 @@  if test "$vhost_user_fs" = "yes" ; then
   echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
 fi
 
-if test "$opengl" = "yes" ; then
-  echo "CONFIG_OPENGL=y" >> $config_host_mak
-  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
-  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
-fi
-
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
diff --git a/meson.build b/meson.build
index cf3b1b39cf..f53fd66716 100644
--- a/meson.build
+++ b/meson.build
@@ -1000,9 +1000,14 @@  if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
 endif
 
 opengl = not_found
-if 'CONFIG_OPENGL' in config_host
-  opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
-                              link_args: config_host['OPENGL_LIBS'].split())
+if not get_option('opengl').auto() or have_system or have_vhost_user_gpu
+  epoxy = dependency('epoxy', method: 'pkg-config',
+                      required: get_option('opengl'), kwargs: static_kwargs)
+  if cc.has_header('epoxy/egl.h', dependencies: epoxy)
+    opengl = epoxy
+  elif get_option('opengl').enabled()
+    error('epoxy/egl.h not found')
+  endif
 endif
 gbm = not_found
 if (have_system or have_tools) and (virgl.found() or opengl.found())
@@ -1544,6 +1549,7 @@  config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
 config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
 config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
 config_host_data.set('CONFIG_NUMA', numa.found())
+config_host_data.set('CONFIG_OPENGL', opengl.found())
 config_host_data.set('CONFIG_PROFILER', get_option('profiler'))
 config_host_data.set('CONFIG_RBD', rbd.found())
 config_host_data.set('CONFIG_SDL', sdl.found())
@@ -2079,7 +2085,7 @@  host_kconfig = \
   (have_tpm ? ['CONFIG_TPM=y'] : []) + \
   (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
   (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
-  ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
+  (opengl.found() ? ['CONFIG_OPENGL=y'] : []) + \
   (x11.found() ? ['CONFIG_X11=y'] : []) + \
   ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
   ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
@@ -3694,7 +3700,7 @@  summary_info += {'smartcard support': cacard}
 summary_info += {'U2F support':       u2f}
 summary_info += {'libusb':            libusb}
 summary_info += {'usb net redir':     usbredir}
-summary_info += {'OpenGL support':    config_host.has_key('CONFIG_OPENGL')}
+summary_info += {'OpenGL support (epoxy)': opengl}
 summary_info += {'GBM':               gbm}
 summary_info += {'libiscsi support':  libiscsi}
 summary_info += {'libnfs support':    libnfs}
diff --git a/meson_options.txt b/meson_options.txt
index 52b11cead4..bd8efe4fbf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -149,6 +149,8 @@  option('lzo', type : 'feature', value : 'auto',
        description: 'lzo compression support')
 option('rbd', type : 'feature', value : 'auto',
        description: 'Ceph block device driver')
+option('opengl', type : 'feature', value : 'auto',
+       description: 'OpenGL support')
 option('gtk', type : 'feature', value : 'auto',
        description: 'GTK+ user interface')
 option('sdl', type : 'feature', value : 'auto',
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 1e26f4571e..f91bd9231b 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -91,6 +91,7 @@  meson_options_help() {
   printf "%s\n" '  nettle          nettle cryptography support'
   printf "%s\n" '  numa            libnuma support'
   printf "%s\n" '  nvmm            NVMM acceleration support'
+  printf "%s\n" '  opengl          OpenGL support'
   printf "%s\n" '  oss             OSS sound support'
   printf "%s\n" '  pa              PulseAudio sound support'
   printf "%s\n" '  parallels       parallels image format support'
@@ -271,6 +272,8 @@  _meson_option_parse() {
     --disable-numa) printf "%s" -Dnuma=disabled ;;
     --enable-nvmm) printf "%s" -Dnvmm=enabled ;;
     --disable-nvmm) printf "%s" -Dnvmm=disabled ;;
+    --enable-opengl) printf "%s" -Dopengl=enabled ;;
+    --disable-opengl) printf "%s" -Dopengl=disabled ;;
     --enable-oss) printf "%s" -Doss=enabled ;;
     --disable-oss) printf "%s" -Doss=disabled ;;
     --enable-pa) printf "%s" -Dpa=enabled ;;
diff --git a/ui/meson.build b/ui/meson.build
index 64286ba150..b21d3d1534 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -1,5 +1,6 @@ 
 softmmu_ss.add(pixman)
 specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: pixman)   # for the include path
+specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)   # for the include path
 
 softmmu_ss.add(files(
   'clipboard.c',
@@ -43,7 +44,6 @@  vnc_ss.add(zlib, png, jpeg, gnutls)
 vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c'))
 softmmu_ss.add_all(when: vnc, if_true: vnc_ss)
 softmmu_ss.add(when: vnc, if_false: files('vnc-stubs.c'))
-specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)
 
 ui_modules = {}
 
@@ -53,17 +53,18 @@  if curses.found()
   ui_modules += {'curses' : curses_ss}
 endif
 
-if config_host.has_key('CONFIG_OPENGL')
+softmmu_ss.add(opengl)
+if opengl.found()
   opengl_ss = ss.source_set()
   opengl_ss.add(gbm)
-  opengl_ss.add(when: [opengl, pixman, 'CONFIG_OPENGL'],
+  opengl_ss.add(when: [opengl, pixman],
                if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
   ui_modules += {'opengl' : opengl_ss}
 endif
 
-if config_host.has_key('CONFIG_OPENGL') and gbm.found()
+if opengl.found() and gbm.found()
   egl_headless_ss = ss.source_set()
-  egl_headless_ss.add(when: [opengl, gbm, pixman, 'CONFIG_OPENGL'],
+  egl_headless_ss.add(when: [opengl, gbm, pixman],
                       if_true: files('egl-headless.c'))
   ui_modules += {'egl-headless' : egl_headless_ss}
 endif
@@ -98,8 +99,8 @@  if gtk.found()
   gtk_ss = ss.source_set()
   gtk_ss.add(gtk, vte, pixman, files('gtk.c', 'gtk-clipboard.c'))
   gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
-  gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-gl-area.c'))
-  gtk_ss.add(when: [x11, opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c'))
+  gtk_ss.add(when: opengl, if_true: files('gtk-gl-area.c'))
+  gtk_ss.add(when: [x11, opengl], if_true: files('gtk-egl.c'))
   ui_modules += {'gtk' : gtk_ss}
 endif
 
@@ -112,7 +113,7 @@  if sdl.found()
     'sdl2-input.c',
     'sdl2.c',
   ))
-  sdl_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('sdl2-gl.c'))
+  sdl_ss.add(when: opengl, if_true: files('sdl2-gl.c'))
   sdl_ss.add(when: x11, if_true: files('x_keymap.c'))
   ui_modules += {'sdl' : sdl_ss}
 endif