--- a/trace/meson.build
+++ b/trace/meson.build
@@ -2,10 +2,14 @@
specific_ss.add(files('control-target.c'))
trace_events_files = []
-foreach dir : [ '.' ] + trace_events_subdirs
- trace_events_file = meson.project_source_root() / dir / 'trace-events'
+foreach path : [ '.' ] + trace_events_subdirs + qapi_trace_events
+ if path.contains('trace-events')
+ trace_events_file = meson.project_build_root() / 'qapi' / path
Just using "trace_events_file = 'qapi' / path" might work, since the build is nonrecursive.
If it doesn't, use the custom target object, possibly indexing it as ct[index]. You can use a dictionary to store the custom targets and find them from the "path" variable.