Skip to content

Commit d9d3d6d

Browse files
Add advanced details about using CMake file-api
1 parent 236d66c commit d9d3d6d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/build/cmake-projects-in-visual-studio.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ When you open an existing CMake cache file (*CMakeCache.txt*), Visual Studio doe
6363

6464
You can add an existing CMake cache to an open project. It's done the same way you'd add a new configuration. For more information, see our blog post on [opening an existing cache in Visual Studio](https://devblogs.microsoft.com/cppblog/open-existing-cmake-caches-in-visual-studio/).
6565

66+
### Advanced CMake cache troubleshooting
67+
68+
As described in our blog post on [multi-root workspaces and file-based API](https://devblogs.microsoft.com/cppblog/visual-studio-code-cmake-tools-extension-multi-root-workspaces-and-file-based-api/), Visual Studio uses CMake's [file-based API](https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html) for CMake versions >= 3.14 to populate the editor with information specific to your project structure. It may be necessary for your custom or preferred tools to populate a **query.json** file before generating the CMake cache. In your build output folder (the one containing **CMakeCache.txt**), create a query file named **.cmake/api/v1/query/client-MicrosoftVS/query.json** with the contents:
69+
```
70+
{"requests":[{"kind":"cache","version":2},{"kind":"cmakeFiles","version":1},{"kind":"codemodel","version":2}]}
71+
```
72+
73+
When your custom or preferred tools generate your cache, CMake will place files under .cmake/api/v1/response that Visual Studio will use to populate the editor with information specific to your project structure.
74+
6675
## Building CMake projects
6776

6877
To build a CMake project, you have these choices:

0 commit comments

Comments
 (0)