fileapi: Allow query to be added during CMake configure
I'm increasingly running into scenarios where it would be useful to define a custom build target which processes replies from the CMake file API. Such scenarios often relate to verification tasks where you want information about the project, which the file API provides in a suitable form. But at the moment, the file API queries are read too early, they are read before the configure phase starts reading any CMakeLists.txt
files. This means by the time the project has a chance to create a query file, it's already too late.
Looking at the implementation, it appears the only reason we need to read the queries so early is because of the need to know what configure log version(s) have been requested. From what I can tell, nothing else about the queries is needed until we actually write the replies at generation time.
I propose we still do an initial read of the queries at the same place we do now, but before writing the replies, we do a check to see if any new queries have been added and we add those new queries to the set. This would allow projects to add their own queries which can then be used by their custom targets to do interesting things at build time. We can make clear in the docs that such late-added queries can't affect the requested configure log versions for the current run.
Right now, if a project wants to create a custom target that processes file API data, you have to run CMake twice, but workflow presets don't let you do that. This means if you want to use workflow presets, you can't reliably use this workaround.