Skip to content

Commit 45dd392

Browse files
authored
Add section on CMake partial activation
1 parent bda91ef commit 45dd392

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ When you **open a folder** containing a *`CMakeLists.txt`* file, the following t
3838

3939
- In the background, Visual Studio starts to index the source files to enable IntelliSense, browsing information, refactoring, and so on. As you work, Visual Studio monitors changes in the editor and also on disk to keep its index in sync with the sources.
4040

41+
> [!NOTE]
42+
> Starting in Visual Studio 17.1 Preview 2 if your folder does not contain a root `CMakeLists.txt` then you will be prompted whether you'd like to enable CMake integration or not. For more information, see [CMake Partial Activation](#cmake-partial-activation).
43+
4144
Once CMake cache generation has succeeded, you can also view your projects organized logically by targets. Choose **Targets view** from the dropdown in the **Solution Explorer** toolbar:
4245

4346
![CMake targets view button.](media/cmake-targets-view.png)
@@ -144,6 +147,15 @@ Visual Studio allows you to debug a process running on a remote Linux system or
144147

145148
![A screenshot of the Attach to Process menu](media/attach-to-process.png)
146149

150+
## <a name="cmake-partial-activation"></a> CMake Partial Activation
151+
Starting in Visual Studio 17.1 Preview 2, CMake functionality will not automatically enable if your root folder does not contain a `CMakeLists.txt`. Instead, a dialog will prompt you on whether you'd like to enable CMake functionality for your project. If you decline, CMake cache generation will not start and CMake configurations (from `CMakeSettings.json` or `CMakePresets.json`) will not appear in the configuration dropdown. If you accept, you will be taken to a workspace-level configuration file, `CMakeWorkspaceSettings.json` (stored in the `.vs` directory), to specify the folders you'd like to enable CMake for (these folders contain your root `CMakeLists.txt`files). The accepted properties are
152+
| Property | Description |
153+
|--|--|
154+
| `enableCMake` | Enable Visual Studio's integration for this workspace. |
155+
| `sourceDirectory` | A string or array of strings specifying the directory or directories with `CMakeLists.txt`. Macros (such as `${workspaceRoot}`) are allowed and relative paths are relative to the workspace root. Note that directories outside of the current workspace will be ignored. |
156+
157+
At any time you can reach `CMakeWorkspaceSettings.json` through the `Project > CMake WorkspaceSettings` menu command (even if CMake functionality is currently disabled).
158+
147159
## Open an existing cache
148160

149161
When you open an existing CMake cache file (*`CMakeCache.txt`*), Visual Studio doesn't try to manage your cache and build tree for you. Your custom or preferred tools have complete control over how CMake configures your project.

0 commit comments

Comments
 (0)