Skip to content

Commit 4c8b80f

Browse files
committed
New moniker ranges
1 parent 0fd890e commit 4c8b80f

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

docs/build/customize-cmake-settings.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For Visual Studio 2019 to 2022, select your version by using the version selecto
1717

1818
::: moniker-end
1919

20-
::: moniker range="<=msvc-170"
20+
::: moniker range=">=msvc-160 <=msvc-170"
2121

2222
Visual Studio uses a CMake configuration file to drive CMake generation and build. *`CMakePresets.json`* is supported by Visual Studio 2019 version 16.10 or later and is the recommended CMake configuration file. *`CMakePresets.json`* is supported directly by CMake and can be used to drive CMake generation and build from Visual Studio, from VS Code, in a Continuous Integration pipeline, and from the command line on Windows, Linux, and Mac. For more information on *`CMakePresets.json`*, see [Configure and build with CMake Presets](cmake-presets-vs.md).
2323

@@ -171,6 +171,50 @@ For more information about each of the properties in the file, see [CMakeSetting
171171

172172
::: moniker-end
173173

174+
::: moniker range="<=msvc-150"
175+
176+
Visual Studio 2017 provides several CMake configurations that define how CMake is invoked to create the CMake cache for a given project. To add a new configuration, select the configuration drop-down in the toolbar and choose **Manage Configurations**:
177+
178+
![Screenshot of Manage configurations selected in the drop-down.](media/cmake-manage-configurations.png)
179+
180+
You can choose from the list of predefined configurations:
181+
182+
![Add Configuration to CMake Settings dialog list of predefined configurations.](media/cmake-configurations.png)
183+
184+
The first time you select a configuration, Visual Studio creates a *`CMakeSettings.json`* file in your project's root folder. This file is used to re-create the CMake cache file, for example after a **Clean** operation.
185+
186+
To add another configuration, right-click *`CMakeSettings.json`* and choose **Add Configuration**.
187+
188+
![Screenshot of the shortcut menu with Add configuration selected.](media/cmake-add-configuration.png "CMake Add Configuration")
189+
190+
You can also edit the file using the **CMake Settings Editor**. Right-click on *`CMakeSettings.json`* in **Solution Explorer** and choose **Edit CMake Settings**. Or, select **Manage Configurations** from the configuration drop-down at the top of the editor window.
191+
192+
You can also directly edit *`CMakeSettings.json`* to create custom configurations. The following example shows a sample configuration, which you can use as a starting point:
193+
194+
```json
195+
{
196+
"name": "x86-Debug",
197+
"generator": "Ninja",
198+
"configurationType": "Debug",
199+
"inheritEnvironments": [ "msvc_x86" ],
200+
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
201+
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
202+
"cmakeCommandArgs": "",
203+
"buildCommandArgs": "-v",
204+
"ctestCommandArgs": ""
205+
},
206+
```
207+
208+
JSON IntelliSense helps you edit the *`CMakeSettings.json`* file:
209+
210+
:::image type="complex" source="media/cmake-json-intellisense.png" alt-text="Screenshot of the CMake JSON IntelliSense pop-up in the editor.":::
211+
The JSON IntelliSense pop-up for "configurations" shows buildCommandArgs, buildRoot, cmakeCommandArgs, configurationType, among several others.
212+
:::image-end:::
213+
214+
For more information about each of the properties in the file, see [`CMakeSettings.json` schema reference](cmakesettings-reference.md).
215+
216+
::: moniker-end
217+
174218
## Related content
175219

176220
- [CMake Projects in Visual Studio](cmake-projects-in-visual-studio.md)

0 commit comments

Comments
 (0)