diff --git a/include/wayland-protocols/meson.build b/include/wayland-protocols/meson.build
new file mode 100644
index 0000000000000000000000000000000000000000..95af9dea0cff6793167c213657b4ca70b08e0b1b
--- /dev/null
+++ b/include/wayland-protocols/meson.build
@@ -0,0 +1,18 @@
+header_install_dir = get_option('includedir') / 'wayland-protocols'
+foreach protocol_file : protocol_files
+	header_name = fs.name(protocol_file).replace('.xml', '-enum.h')
+	custom_target(
+		header_name,
+		output: header_name,
+		input: '../..' / protocol_file,
+		command: [
+			prog_scanner,
+			'--strict',
+			'enum-header',
+			'@INPUT@',
+			'@OUTPUT@',
+		],
+		install: true,
+		install_dir: header_install_dir,
+	)
+endforeach
diff --git a/meson.build b/meson.build
index c096772b73376c1570f397816ec3e9ce54b8cd0f..6b663a72dd9b34c9fff0f74831a92a08b192f6db 100644
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,6 @@
 project('wayland-protocols',
 	version: '1.37',
-	meson_version: '>= 0.55.0',
+	meson_version: '>= 0.58.0',
 	license: 'MIT/Expat',
 )
 
@@ -8,6 +8,9 @@ wayland_protocols_version = meson.project_version()
 
 fs = import('fs')
 
+dep_scanner = dependency('wayland-scanner', version: '>=1.20.0', native: true, fallback: 'wayland')
+prog_scanner = find_program(dep_scanner.get_variable(pkgconfig: 'wayland_scanner', internal: 'wayland_scanner'))
+
 stable_protocols = {
 	'presentation-time': [''],
 	'viewporter': [''],
@@ -108,6 +111,12 @@ foreach protocol_file : protocol_files
 	)
 endforeach
 
+include_dirs = []
+if dep_scanner.version().version_compare('>=1.22.90')
+	subdir('include/wayland-protocols')
+	include_dirs = ['include']
+endif
+
 wayland_protocols_srcdir = meson.current_source_dir()
 
 pkgconfig_configuration = configuration_data()
@@ -132,6 +141,7 @@ configure_file(
 )
 
 wayland_protocols = declare_dependency(
+	include_directories: include_dirs,
 	variables: {
 		'pkgdatadir': wayland_protocols_srcdir,
 	},
@@ -142,3 +152,7 @@ meson.override_dependency('wayland-protocols', wayland_protocols)
 if get_option('tests')
 	subdir('tests')
 endif
+
+summary({
+	'Headers': include_dirs.length() > 0,
+}, bool_yn: true)
diff --git a/tests/meson.build b/tests/meson.build
index 4f7cdf8d865aa808b205d1e1b193b905896ef4ae..aa216ec2cdc79f91508267e06669589f3ec13a8b 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,6 +1,4 @@
 prog_scan_sh = find_program('scan.sh')
-dep_scanner = dependency('wayland-scanner', version: '>=1.20.0', native: true, fallback: 'wayland')
-prog_scanner = find_program(dep_scanner.get_variable(pkgconfig: 'wayland_scanner', internal: 'wayland_scanner'))
 
 libwayland = [
 	dependency('wayland-client'),