|
| 1 | +--- |
| 2 | +title: "CMake predefined configuration reference" |
| 3 | +ms.description: "Visual Studio provides several predefined build configurations for CMake projects on Linux, Windows, ARM, and IoT." |
| 4 | +ms.date: "03/05/2019" |
| 5 | +helpviewer_keywords: ["CMake redefined configurations"] |
| 6 | +--- |
| 7 | + |
| 8 | +# CMake predefined build configurations |
| 9 | + |
| 10 | +In a CMake project, build configurations are stored in a CMakeSettings.json file. When you choose **Manage Configurations** from the build configuration dropdown in the main toolbar, a dialog appears that shows the default CMake configurations available in Visual Studio: |
| 11 | +- x86 Debug |
| 12 | +- x86 Release |
| 13 | +- x64 Debug |
| 14 | +- x64 Release |
| 15 | +- Linux-Debug |
| 16 | +- Linux-Release |
| 17 | +- IoT Debug |
| 18 | +- IoT Release |
| 19 | +- MinGW Debug |
| 20 | +- MinGW Release |
| 21 | + |
| 22 | +When you choose a configuration, it is added to the CMakeSettings.json file in the project's root folder. You can then use it to build your project. |
| 23 | + |
| 24 | + |
| 25 | +## Linux predefined build configurations: |
| 26 | + |
| 27 | +```json |
| 28 | +{ |
| 29 | + "name": "Linux-Debug", |
| 30 | + "generator": "Unix Makefiles", |
| 31 | + "remoteMachineName": "user@host", |
| 32 | + "configurationType": "Debug", |
| 33 | + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", |
| 34 | + "cmakeExecutable": "/usr/local/bin/cmake", |
| 35 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 36 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 37 | + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", |
| 38 | + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", |
| 39 | + "remoteCopySources": true, |
| 40 | + "remoteCopySourcesOutputVerbosity": "Normal", |
| 41 | + "remoteCopySourcesConcurrentCopies": "10", |
| 42 | + "remoteCopySourcesMethod": "rsync", |
| 43 | + "remoteCopySourcesExclusionList": [ |
| 44 | + ".vs", |
| 45 | + ".git" |
| 46 | + ], |
| 47 | + "rsyncCommandArgs": "-t --delete --delete-excluded", |
| 48 | + "remoteCopyBuildOutput": false, |
| 49 | + "cmakeCommandArgs": "", |
| 50 | + "buildCommandArgs": "", |
| 51 | + "ctestCommandArgs": "", |
| 52 | + "inheritEnvironments": [ |
| 53 | + "linux_x64" |
| 54 | + ] |
| 55 | + } |
| 56 | + |
| 57 | +{ |
| 58 | + "name": "Linux-Release", |
| 59 | + "generator": "Unix Makefiles", |
| 60 | + "remoteMachineName": "${defaultRemoteMachineName}", |
| 61 | + "configurationType": "RelWithDebInfo", |
| 62 | + "remoteCMakeListsRoot": "/var/tmp/src/${workspaceHash}/${name}", |
| 63 | + "cmakeExecutable": "/usr/local/bin/cmake", |
| 64 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 65 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 66 | + "remoteBuildRoot": "/var/tmp/build/${workspaceHash}/build/${name}", |
| 67 | + "remoteInstallRoot": "/var/tmp/build/${workspaceHash}/install/${name}", |
| 68 | + "remoteCopySources": true, |
| 69 | + "remoteCopySourcesOutputVerbosity": "Normal", |
| 70 | + "remoteCopySourcesConcurrentCopies": "10", |
| 71 | + "remoteCopySourcesMethod": "rsync", |
| 72 | + "remoteCopySourcesExclusionList": [ |
| 73 | + ".vs", |
| 74 | + ".git" |
| 75 | + ], |
| 76 | + "rsyncCommandArgs": "-t --delete --delete-excluded", |
| 77 | + "remoteCopyBuildOutput": false, |
| 78 | + "cmakeCommandArgs": "", |
| 79 | + "buildCommandArgs": "", |
| 80 | + "ctestCommandArgs": "", |
| 81 | + "inheritEnvironments": [ |
| 82 | + "linux_x64" |
| 83 | + ] |
| 84 | + }, |
| 85 | + ``` |
| 86 | + |
| 87 | + |
| 88 | +You can use these optional settings for more control: |
| 89 | + |
| 90 | +```json |
| 91 | +{ |
| 92 | + "remotePreBuildCommand": "", |
| 93 | + "remotePreGenerateCommand": "", |
| 94 | + "remotePostBuildCommand": "", |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +These options allow you to run commands on the remote system before and after building, and before CMake generation. The values can be any command that is valid on the remote system. The output is piped back to Visual Studio. |
| 99 | + |
| 100 | +## IoT predefined build configurations |
| 101 | + |
| 102 | +```json |
| 103 | +{ |
| 104 | + "name": "IoT-Debug", |
| 105 | + "generator": "Ninja", |
| 106 | + "configurationType": "Debug", |
| 107 | + "inheritEnvironments": [ |
| 108 | + "gcc-arm" |
| 109 | + ], |
| 110 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 111 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 112 | + "cmakeCommandArgs": "", |
| 113 | + "buildCommandArgs": "-v", |
| 114 | + "ctestCommandArgs": "", |
| 115 | + "intelliSenseMode": "linux-gcc-arm", |
| 116 | + "variables": [ |
| 117 | + { |
| 118 | + "name": "CMAKE_C_COMPILER", |
| 119 | + "value": "arm-none-eabi-gcc.exe" |
| 120 | + }, |
| 121 | + { |
| 122 | + "name": "CMAKE_CXX_COMPILER", |
| 123 | + "value": "arm-none-eabi-g++.exe" |
| 124 | + }, |
| 125 | + { |
| 126 | + "name": "CMAKE_C_FLAGS", |
| 127 | + "value": "-nostartfiles" |
| 128 | + }, |
| 129 | + { |
| 130 | + "name": "CMAKE_CXX_FLAGS", |
| 131 | + "value": "-nostartfiles -fno-rtti -fno-exceptions" |
| 132 | + }, |
| 133 | + { |
| 134 | + "name": "CMAKE_CXX_STANDARD", |
| 135 | + "value": "14" |
| 136 | + }, |
| 137 | + { |
| 138 | + "name": "CMAKE_SYSTEM_NAME", |
| 139 | + "value": "Generic" |
| 140 | + }, |
| 141 | + { |
| 142 | + "name": "CMAKE_SYSTEM_PROCESSOR", |
| 143 | + "value": "arm" |
| 144 | + } |
| 145 | + ] |
| 146 | + }, |
| 147 | + { |
| 148 | + "name": "IoT-Release", |
| 149 | + "generator": "Ninja", |
| 150 | + "configurationType": "Release", |
| 151 | + "inheritEnvironments": [ |
| 152 | + "gcc-arm" |
| 153 | + ], |
| 154 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 155 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 156 | + "cmakeCommandArgs": "", |
| 157 | + "buildCommandArgs": "-v", |
| 158 | + "ctestCommandArgs": "", |
| 159 | + "intelliSenseMode": "linux-gcc-arm", |
| 160 | + "variables": [ |
| 161 | + { |
| 162 | + "name": "CMAKE_C_COMPILER", |
| 163 | + "value": "arm-none-eabi-gcc.exe" |
| 164 | + }, |
| 165 | + { |
| 166 | + "name": "CMAKE_CXX_COMPILER", |
| 167 | + "value": "arm-none-eabi-g++.exe" |
| 168 | + }, |
| 169 | + { |
| 170 | + "name": "CMAKE_C_FLAGS", |
| 171 | + "value": "-nostartfiles" |
| 172 | + }, |
| 173 | + { |
| 174 | + "name": "CMAKE_CXX_FLAGS", |
| 175 | + "value": "-nostartfiles -fno-rtti -fno-exceptions" |
| 176 | + }, |
| 177 | + { |
| 178 | + "name": "CMAKE_CXX_STANDARD", |
| 179 | + "value": "14" |
| 180 | + }, |
| 181 | + { |
| 182 | + "name": "CMAKE_SYSTEM_NAME", |
| 183 | + "value": "Generic" |
| 184 | + }, |
| 185 | + { |
| 186 | + "name": "CMAKE_SYSTEM_PROCESSOR", |
| 187 | + "value": "arm" |
| 188 | + } |
| 189 | + ] |
| 190 | + } |
| 191 | +``` |
| 192 | + |
| 193 | +## MinGW predefined build configurations |
| 194 | + |
| 195 | +```json |
| 196 | +{ |
| 197 | + "environments": [ |
| 198 | + { |
| 199 | + "MINGW64_ROOT": "C:\\msys64\\mingw64", |
| 200 | + "BIN_ROOT": "${env.MINGW64_ROOT}\\bin", |
| 201 | + "FLAVOR": "x86_64-w64-mingw32", |
| 202 | + "TOOLSET_VERSION": "7.3.0", |
| 203 | + "PATH": "${env.MINGW64_ROOT}\\bin;${env.MINGW64_ROOT}\\..\\usr\\local\\bin;${env.MINGW64_ROOT}\\..\\usr\\bin;${env.MINGW64_ROOT}\\..\\bin;${env.PATH}", |
| 204 | + "INCLUDE": "${env.INCLUDE};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\tr1;${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\${env.FLAVOR}", |
| 205 | + "environment": "mingw_64" |
| 206 | + } |
| 207 | + ], |
| 208 | + "name": "Mingw64-Debug", |
| 209 | + "generator": "Ninja", |
| 210 | + "configurationType": "Debug", |
| 211 | + "inheritEnvironments": [ |
| 212 | + "mingw_64" |
| 213 | + ], |
| 214 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 215 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 216 | + "cmakeCommandArgs": "", |
| 217 | + "buildCommandArgs": "-v", |
| 218 | + "ctestCommandArgs": "", |
| 219 | + "intelliSenseMode": "linux-gcc-x64", |
| 220 | + "variables": [ |
| 221 | + { |
| 222 | + "name": "CMAKE_C_COMPILER", |
| 223 | + "value": "${env.BIN_ROOT}\\gcc.exe" |
| 224 | + }, |
| 225 | + { |
| 226 | + "name": "CMAKE_CXX_COMPILER", |
| 227 | + "value": "${env.BIN_ROOT}\\g++.exe" |
| 228 | + } |
| 229 | + ] |
| 230 | + } |
| 231 | + |
| 232 | +{ |
| 233 | + "environments": [ |
| 234 | + { |
| 235 | + "MINGW64_ROOT": "C:\\msys64\\mingw64", |
| 236 | + "BIN_ROOT": "${env.MINGW64_ROOT}\\bin", |
| 237 | + "FLAVOR": "x86_64-w64-mingw32", |
| 238 | + "TOOLSET_VERSION": "7.3.0", |
| 239 | + "PATH": "${env.MINGW64_ROOT}\\bin;${env.MINGW64_ROOT}\\..\\usr\\local\\bin;${env.MINGW64_ROOT}\\..\\usr\\bin;${env.MINGW64_ROOT}\\..\\bin;${env.PATH}", |
| 240 | + "INCLUDE": "${env.INCLUDE};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\tr1;${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\${env.FLAVOR}", |
| 241 | + "environment": "mingw_64" |
| 242 | + } |
| 243 | + ], |
| 244 | + "name": "Mingw64-Release", |
| 245 | + "generator": "Ninja", |
| 246 | + "configurationType": "RelWithDebInfo", |
| 247 | + "inheritEnvironments": [ |
| 248 | + "mingw_64" |
| 249 | + ], |
| 250 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 251 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 252 | + "cmakeCommandArgs": "", |
| 253 | + "buildCommandArgs": "-v", |
| 254 | + "ctestCommandArgs": "", |
| 255 | + "intelliSenseMode": "linux-gcc-x64", |
| 256 | + "variables": [ |
| 257 | + { |
| 258 | + "name": "CMAKE_C_COMPILER", |
| 259 | + "value": "${env.BIN_ROOT}\\gcc.exe" |
| 260 | + }, |
| 261 | + { |
| 262 | + "name": "CMAKE_CXX_COMPILER", |
| 263 | + "value": "${env.BIN_ROOT}\\g++.exe" |
| 264 | + } |
| 265 | + ] |
| 266 | + } |
| 267 | +``` |
| 268 | + |
| 269 | +## x86-64 predefined build configurations |
| 270 | + |
| 271 | +```json |
| 272 | + { |
| 273 | + "name": "x86-Debug", |
| 274 | + "generator": "Ninja", |
| 275 | + "configurationType": "Debug", |
| 276 | + "inheritEnvironments": [ |
| 277 | + "msvc_x86" |
| 278 | + ], |
| 279 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 280 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 281 | + "cmakeCommandArgs": "", |
| 282 | + "buildCommandArgs": "-v", |
| 283 | + "ctestCommandArgs": "" |
| 284 | + }, |
| 285 | + { |
| 286 | + "name": "x86-Release", |
| 287 | + "generator": "Ninja", |
| 288 | + "configurationType": "RelWithDebInfo", |
| 289 | + "inheritEnvironments": [ |
| 290 | + "msvc_x86" |
| 291 | + ], |
| 292 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 293 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 294 | + "cmakeCommandArgs": "", |
| 295 | + "buildCommandArgs": "-v", |
| 296 | + "ctestCommandArgs": "" |
| 297 | + }, |
| 298 | + { |
| 299 | + "name": "x64-Debug", |
| 300 | + "generator": "Ninja", |
| 301 | + "configurationType": "Debug", |
| 302 | + "inheritEnvironments": [ |
| 303 | + "msvc_x64_x64" |
| 304 | + ], |
| 305 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 306 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 307 | + "cmakeCommandArgs": "", |
| 308 | + "buildCommandArgs": "-v", |
| 309 | + "ctestCommandArgs": "" |
| 310 | + }, |
| 311 | + { |
| 312 | + "name": "x64-Release", |
| 313 | + "generator": "Ninja", |
| 314 | + "configurationType": "RelWithDebInfo", |
| 315 | + "inheritEnvironments": [ |
| 316 | + "msvc_x64_x64" |
| 317 | + ], |
| 318 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 319 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 320 | + "cmakeCommandArgs": "", |
| 321 | + "buildCommandArgs": "-v", |
| 322 | + "ctestCommandArgs": "" |
| 323 | + }, |
| 324 | + { |
| 325 | + "name": "x86-Release2", |
| 326 | + "generator": "Ninja", |
| 327 | + "configurationType": "RelWithDebInfo", |
| 328 | + "inheritEnvironments": [ |
| 329 | + "msvc_x86" |
| 330 | + ], |
| 331 | + "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", |
| 332 | + "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", |
| 333 | + "cmakeCommandArgs": "", |
| 334 | + "buildCommandArgs": "-v", |
| 335 | + "ctestCommandArgs": "" |
| 336 | + } |
| 337 | + ] |
| 338 | +} |
| 339 | +``` |
| 340 | + |
| 341 | +## See Also |
| 342 | + |
| 343 | +[CMake Tools for Visual C++](../ide/cmake-tools-for-visual-cpp.md)<br/> |
| 344 | +[Configure a Linux CMake project](../linux/cmake-linux-project.md)<br/> |
| 345 | +[Connect to your remote Linux computer](../linux/connect-to-your-remote-linux-computer.md)<br/> |
| 346 | +[Configure CMake debugging sessions](configure-cmake-debugging-sessions.md)<br/> |
| 347 | +[Deploy, run, and debug your Linux project](../linux/deploy-run-and-debug-your-linux-project.md)<br/> |
| 348 | +[CMake predefined configuration reference](cmake-predefined-configuration-reference.md)<br/> |
0 commit comments