diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf
index a26f1258d8c394042c77cbd7d6e8121cca1b5aa9..c9bd65b03ee6351683f8c1bff80313312b207d15 100644
--- a/mkspecs/features/functions.prf
+++ b/mkspecs/features/functions.prf
@@ -127,3 +127,12 @@ defineReplace(pkgConfigHostExecutable) {
     export(QMAKE_DISTCLEAN)
     return($$system_quote($$system_path($$wrapper_name)))
 }
+
+defineTest(hasX11Dependencies) {
+    for(package, $$list("libdrm xcomposite xcursor xi xrandr xtst")) {
+        !qtConfig(webengine-system-$$package) {
+            return(false)
+        }
+    }
+    return(true)
+}
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index 7f634472db6e64a49c37fe67f2de55c4e771349f..eb8bb7bb0644674ccd55f9a6043d6b186a0053df 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -24,7 +24,7 @@ qtConfig(webengine-embedded-build) {
     !use_gold_linker: gn_args += use_gold=false
 }
 
-qtConfig(webengine-system-x11) {
+qtConfig(webengine-system-x11): hasX11Dependencies() {
    gn_args += ozone_platform_x11=true
 }