fileapi: user-wide default queries in xdg config directory
The file-api query directory is in <build>/.cmake/api/v1/query/
within a build tree. This allows IDEs to request that CMake generate semantic information about the generated build system. The workflow is natural when the IDE handles creating the build tree and running CMake. However, if a user wishes to use their IDE to open a CMake build directory it has not previously seen, the IDE has to run CMake at least once after writing its queries.
In order to help users that want to use their IDE to open any CMake build tree, we could offer them a way to opt-in to user-wide configuration to enable file-api queries for all build trees by default. One approach is to have user-wide file-api queries configured under $XDG_CONFIG_HOME/cmake/api/v1/query
(e.g. ~/.config/cmake/api/v1/query
). When CMake configures a build tree for the first time (e.g. needs to create CMakeCache.txt
) it could check if a .cmake/api/v1/query
directory exists in it already. If not, then CMake would copy the query from the user-wide configuration to initialize the build tree.
With this approach, IDEs could offer an option to write their queries to $XDG_CONFIG_HOME/cmake/api/v1/query
. Once a user enables this option, the IDE will always be able to find replies in CMake build trees even if they are created externally by the user.