Configure CMake Tools settings

July 1, 2026 · View on GitHub

CMake Tools supports a variety of settings that can be set at the user, or workspace, level via VSCode's settings.json file. This topic covers the available options and how they are used.

Options that support substitution, in the table below, allow variable references to appear in their strings. See variable substitution, below, for more information about variable expansion.

CMake settings

SettingDescriptionDefault valueSupports substitution
cmake.additionalCompilerSearchDirsList of paths to search for additional compilers, like a MinGW installation. This means that GCC does not need to be on your $PATH for it to be found via kit scanning. For example: ["C:\\MinGW\\bin"] (Search in C:\MinGW\bin for a MinGW installation)[]yes
cmake.additionalKitsArray of paths to custom kit files. These are in addition to the default kit files.[]no
cmake.allowCommentsInPresetsFileAllow the use of JSON extensions such as comments in CMakePresets.json. Please note that your CMakePresets.json file may be considered invalid by other IDEs or on the command line if you use non-standard JSON.falseno
cmake.allowUnsupportedPresetsVersionsEnables the use of presets files that are using features from the versions that Cmake Tools extension doesn't currently support. Unknown properties and macros will be ignored.falseno
cmake.automaticReconfigureAutomatically configure CMake project directories when the kit or the configuration preset is changed.trueno
cmake.autoSelectActiveFolderIf 'false', your active folder only changes if you manually run the CMake: Select Active Folder command.trueno
cmake.buildArgsAn array of additional arguments to pass to cmake --build.[] (empty array-no additional arguments)yes
cmake.buildBeforeRunIf true, build the launch/debug target before running the target.trueno
cmake.buildDirectorySpecify the build directory (i.e. the root directory where CMakeCache.txt will be generated.)${workspaceFolder}/buildyes
cmake.buildEnvironmentAn object containing key:value pairs of environment variables, which will be passed only to the compiler.null (no environment variables specified)yes
cmake.buildTaskIf true, generate VS Code tasks for building.falseno
cmake.buildToolArgsAn array of additional arguments to pass to the underlying build tool.[] (empty array-no additional arguments)yes
cmake.cacheInitPath, or list of paths, to cache-initialization files. Passed to CMake via the -C command-line argument.[] (empty array-no cache initializer files)no
cmake.clearOutputBeforeBuildIf true, clear output before building.trueno
cmake.cmakeCommunicationModeSpecifies the protocol for communicating between the extension and CMakeautomaticno
cmake.cmakePathSpecify location of the cmake executable.cmake (causes CMake Tools to search the PATH environment variable, as well as some hard-coded locations.)Supports substitution for workspaceRoot, workspaceFolder, workspaceRootFolderName, userHome, ${command:...} and ${env:...}. Other substitutions result in an empty string.
cmake.configureArgsArguments to CMake that will be passed during the configure process. Prefer to use cmake.configureSettings or CMake variants.
It is not recommended to pass -D arguments using this setting.
[] (empty array-no arguments)yes
cmake.configureEnvironmentAn object containing key:value pairs of environment variables, which will be passed to CMake only when configuring.null (no environment variable pairs)yes
cmake.configureOnEditAutomatically configure CMake project directories when the path in the cmake.sourceDirectory setting is updated or when CMakeLists.txt or *.cmake files are saved.trueno
cmake.configureOnOpenAutomatically configure CMake project directories when they are opened.trueno
cmake.cmakeProviderExtensionsList of VS Code extension IDs that provide or install their own CMake binary. When CMake is not found during automatic configure-on-open and one of these extensions is installed, CMake Tools will briefly poll for CMake availability instead of showing an immediate error. Set to an empty array to disable this behavior.["stmicroelectronics.stm32-vscode-extension", "espressif.esp-idf-extension", "NXPSemiconductors.mcuxpresso", "nordic-semiconductor.nrf-connect"]no
cmake.configureSettingsAn object containing key:value pairs, which will be passed to CMake when configuring. The same as passing -DVAR_NAME=ON via cmake.configureArgs. NOTE: Semicolons (;) in string values are passed through to CMake verbatim, CMake itself decides whether to treat them as list separators (matching how CMake Presets cacheVariables and cmake-kits.json cmakeSettings behave). To pass a CMake list, you can either use array notation (e.g. "MY_LIST": [ "a", "b" ]) or write the list as a string with ; separators (e.g. "MY_LIST": "a;b"). If you genuinely need a literal ; inside a single list element, pre-escape it as \; in your JSON.{} (no values)yes
cmake.copyCompileCommandsIf not null, copies the compile_commands.json file generated by CMake to the path specified by this setting whenever CMake successfully configures.null (do not copy the file)yes
cmake.preConfigureTaskIf not null, the task with this name is executed before CMake configures.null (do not run any task)yes
cmake.postConfigureTaskIf not null, the task with this name is executed whenever CMake successfully configures.null (do not run any task)yes
cmake.coverageInfoFilesLCOV coverage info files to be processed after running tests with coverage using the test explorer.[]yes
cmake.cpackArgsAn array of additional arguments to pass to cpack.[]yes
cmake.cpackEnvironmentAn object containing key:value pairs of environment variables, which will be available when running cpack.{}yes
cmake.cpackPathPath to cpack executable.nullno
cmake.ctest.allowParallelJobsIf true, allow running test jobs in parallel. When false, tests run sequentially in alphabetical order, matching the Test Explorer display order.falseno
cmake.ctest.debugLaunchTargetTarget to debug during CTest execution.nullno
cmake.ctest.parallelJobsSpecify the number of jobs to run in parallel for ctest. Using the value 0 will detect and use the number of CPUs. Using the value 1 will disable test parallelism.0no
cmake.ctest.testExplorerIntegrationEnabledIf true, configure CMake to generate information needed by the test explorer. When false, the automatic CTest discovery that runs after each build is also skipped; the post-configure refresh and the manual cmake.refreshTests command still run.trueno
cmake.ctest.testSuiteDelimiterCharacter(s) that separate test suite name components.nullno
cmake.ctestArgsAn array of additional arguments to pass to CTest. Supports ${testName} for per-test expansion (see Variable substitution).[]yes
cmake.ctestDefaultArgsDefault arguments to pass to CTest. Supports ${testName} for per-test expansion (see Variable substitution).["-T", "test", "--output-on-failure"]no
cmake.ctestPathPath to CTest executable.nullno
cmake.debugConfigThe debug configuration to use when debugging a target. When type is specified, automatic debugger detection is skipped and a custom debug adapter can be used. Additional properties required by the debug adapter can be added freely. See Debug and launch for examples, including Natvis via visualizerFile without a launch.json.null (no values)yes
cmake.defaultActiveFolderThe name of active folder, which be used as default (Only works when cmake.autoSelectActiveFolder is disabled).""no
cmake.defaultVariantsOverride the default set of variants that will be supplied when no variants file is present. See CMake variants.See package.jsonno
cmake.deleteBuildDirOnCleanConfigureIf true, delete build directory during clean configure.falseno
cmake.emscriptenSearchDirsList of paths to search for Emscripten.[]no
cmake.enableAutomaticKitScanEnable automatic kit scanning.trueno
cmake.removeStaleKitsOnScanIf true, a full Scan for Kits run removes compiler-based kits from cmake-tools-kits.json when they are no longer rediscovered. This is useful after compiler upgrades that leave older versions installed outside PATH. Set "keep": true in a kit entry to preserve it. This setting does not affect Scan recursively for kits in specific directories.falseno
cmake.enabledOutputParsersList of enabled output parsers.["cmake", "gcc", "gnuld", "msvc", "ghs", "diab", "iwyu"]no
cmake.additionalBuildProblemMatchersArray of user-defined problem matchers for build output. Each entry has name, regexp, and optional capture group indices (file, line, column, severity, message, code). See Additional Build Problem Matchers below.[]no
cmake.enableLanguageServicesIf true, enable CMake language services.trueno
cmake.languageServerOnlyModeIf true, keep CMake language services enabled while disabling CMake project, build, test, and kit integration.falseno
cmake.enableTraceLoggingIf true, enable trace logging.falseno
cmake.environmentAn object containing key:value pairs of environment variables, which will be available when configuring, building, or testing with CTest.{} (no environment variables)yes
cmake.excludeCMake Tools will ignore the folders defined in this setting.[]yes
cmake.exportCompileCommandsFileIf true, generate the compile_commands.json file.trueno
cmake.generatorSet to a string to override CMake Tools preferred generator logic. If set, CMake will unconditionally use it as the -G CMake generator command line argument.nullno
cmake.ignoreCMakeListsMissingIf true, do not show error when opening a project without CMakeLists.txt.falseno
cmake.ignoreKitEnvIf true, ignore kit environment variables.falseno
cmake.installPrefixIf specified, sets a value for CMAKE_INSTALL_PREFIX when running CMake configure. If not set, no value will be passed.
If CMAKE_INSTALL_PREFIX is set via cmake.configureArgs or cmake.configureSettings, cmake.installPrefix will be ignored.
null (no value specified)yes
cmake.launchBehaviorBehavior when launching a CMake target.reuseTerminalno
cmake.loadCompileCommandsControls whether the extension reads compile_commands.json to enable single file compilation.trueno
cmake.loggingLevelA string setting that specifies how much output CMake Tools produces in its output channel. Set to one of "trace", "debug", "info", "note", "warning", "error", or "fatal". "trace" is the most verbose.

Regardless of the logging level, CMake Tools writes all levels of logging to the CMake Tools log file. This file is useful if you need to troubleshoot CMake Tools
"info"no
cmake.mergedCompileCommandsPath where to create a merged compile_commands.json file.nullno
cmake.mingwSearchDirsDEPRECATED. List of paths to search for MinGW. Use cmake.additionalCompilerSearchDirs instead.[]no
cmake.modifyLists.addNewSourceFilesAdd source files to CMake lists when they are created. "no" disables, "yes" applies automatically, "ask" shows a preview of proposed changes to apply."ask"no
cmake.modifyLists.removeDeletedSourceFilesRemove source files from CMake lists when they are deleted. "no" disables, "yes" applies automatically, "ask" shows a preview of proposed changes to apply."ask"no
cmake.modifyLists.variableSelectionHow to choose which set() or list(APPEND/PREPEND/INSERT) command invocation to edit when adding source files to CMake lists."never"no
cmake.modifyLists.sourceVariablesVariables to add source files to. Variables appearing earlier in this list will be given higher priority. Only used if cmake.modifyLists.variableSelection is not "never". Supports glob patterns.["SRC", "SRCS", "SOURCES", "SOURCE_FILES", "*_SRC", "*_SRCS", "*_SOURCES", "*_SOURCE_FILES"]no
cmake.modifyLists.targetSelectionHow to choose which target to add new source files to when adding source files to CMake lists."askParentSourceDirs"no
cmake.modifyLists.targetCommandInvocationSelectionHow to choose which of a target's source command invocations to edit when adding source files to CMake lists."askParentDirs"no
cmake.modifyLists.targetSourceCommandsCommands to treat as target source commands when adding source files to CMake lists. Commands appearing earlier in this list will be given higher priority. Supports glob patterns.["target_sources", "add_executable", "add_library"]no
cmake.modifyLists.scopeSelectionHow to choose which of a target's visibility scopes, file sets, or source keyword parameters to edit when adding source files to CMake lists."ask"no
cmake.modifyLists.sourceListKeywordsKeyword arguments to user-defined functions and macros which introduce lists of source files. If left empty, all arguments consisting of only upper-case letters and underscores will be considered. Supports glob patterns.[]no
cmake.options.advancedAdvanced options for CMake Tools.See package.jsonno
cmake.options.statusBarVisibilityControls visibility of the status bar.hiddenno
cmake.outputLogEncodingEncoding to use for tool output.autono
cmake.outlineViewTypeProject Outline View`s type.["list", "tree"]no
cmake.parallelJobsSpecify the number of jobs run in parallel during the build. Using the value 0 will detect and use the number of CPUs. Using the value 1 will disable build parallelism.0no
cmake.parseBuildDiagnosticsIf true, parse compiler output for diagnostics.trueno
cmake.pinnedCommandsList of commands pinned to the command palette.["workbench.action.tasks.configureTaskRunner", "workbench.action.tasks.runTask"]no
cmake.platformCMake platform to use.nullno
cmake.postRunCoverageTargetTarget to build after running tests with coverage using the test explorer.nullno
cmake.preferredGeneratorsA list of strings of generator names to try, in order, when configuring a CMake project for the first time.[]no
cmake.preRunCoverageTargetTarget to build before running tests with coverage using the test explorer.nullno
cmake.revealLogControls when the CMake output log should be revealed. Possible values: focus (show the log and move focus to the output channel), always (show the log but do not move focus), never (do not show the log), error (show the log only when an error occurs).alwaysno
cmake.saveBeforeBuildIf true (the default), saves open text documents when build or configure is invoked before running CMake.trueno
cmake.setBuildTargetSameAsLaunchTargetIf true, setting the launch/debug target automatically sets the build target to match.falseno
cmake.setBuildTypeOnMultiConfigIf true, set build type on multi-config generators.falseno
cmake.shellPath to a shell executable to route all CMake/CTest/CPack subprocess invocations through (e.g., Git Bash or MSYS2). Useful for embedded toolchains that require POSIX path translation on Windows. When null, the default system shell behavior is used.nullno
cmake.showConfigureWithDebuggerNotificationIf true, show notification when configure with debugger.trueno
cmake.showNotAllDocumentsSavedQuestionIf true, show not all documents saved question.trueno
cmake.showSystemKitsIf true, show system kits in kit selection.trueno
cmake.skipConfigureIfCachePresentIf true, skip configure if CMake cache is present.nullno
cmake.sourceDirectoryA directory or a list of directories where the root CMakeLists.txts are stored.${workspaceFolder}yes
cmake.autoDetectSourceDirectoryWhen no CMakeLists.txt exists at the workspace root, automatically detect a single CMakeLists.txt in a subdirectory and use its folder as the source directory so CMake Tools activates instead of staying hidden. When several candidates are found, you are prompted to choose. Has no effect when cmake.sourceDirectory is set explicitly.trueyes
cmake.testEnvironmentAn object containing key:value pairs of environment variables, which will be available when debugging, running and testing with CTest.{} (no environment variables)yes
cmake.toolsetCMake toolset to use.nullno
cmake.touchbar.advancedAdvanced options for touchbar.See package.jsonno
cmake.touchbar.visibilityControls visibility of the touchbar.defaultno
cmake.useCMakePresetsControls when to use CMake presets.autono
cmake.useVsDeveloperEnvironmentControls when to use Visual Studio Developer Environment for building.autono

Variable substitution

Some settings support the replacement of special values in their string value by using a ${variable} syntax.

Where substitution works

Use this quick rule to avoid confusion:

  • CMake Tools ${...} variables in this section (for example ${buildKit} and ${generator}) are expanded only when CMake Tools reads supported cmake.* settings from settings.json.
  • Generic VS Code tasks.json and launch.json fields are resolved by VS Code, not by CMake Tools. In those fields, use VS Code variables (for example ${workspaceFolder}) or command substitutions such as ${command:cmake.buildKit}.
  • ${config:cmake.*} in tasks.json/launch.json returns the raw setting value. It does not apply a second CMake Tools substitution pass.

Example:

  • In a shell task command, ${buildKit} and ${generator} are not expanded.
  • In a shell task command, ${command:cmake.buildKit} is expanded.

The following built-in variables are expanded in supported cmake.* settings only. None of these are expanded in generic VS Code shell or process task commands. Use the ${command:cmake.*} forms listed under Command substitution for those contexts.

VariableExpansion
${workspaceRoot}DEPRECATED. The full path to the workspace root directory.
${workspaceFolder}The full path to the workspace root directory.
${sourceDirectory}The full path to the root CMakeLists.txt. (not substituted for cmake.sourceDirectory, cmake.cmakePath, cmake.ctestPath, or in Kits)
${workspaceRootFolderName}The name of the leaf directory in the workspace directory path.
${buildType}The current CMake build type. For example: Debug, Release, MinSizeRel, RelWithDebInfo
${buildKit}The current CMake kit full name. For example: GCC 7.3.0
${buildKitVendor}The current CMake kit vendor name. Possible values: GCC, MSVC, Clang and so on
${buildKitTriple}The current CMake kit target triple. For example: arm-none-eabi
${buildKitVersion}The current CMake kit version. For example: 9.3.0
${buildKitHostOs}The current CMake kit host OS. Possible values: win32, osx, linux and so on, all in lowercase
${buildKitTargetOs}The current CMake kit target OS. Possible values: win32, osx, linux and so on, all in lowercase
${buildKitTargetArch}The current CMake kit target architecture. Possible values: x86, x64, arm, aarch64 and so on, all in lowercase
${buildKitVersionMajor}The current CMake kit major version. For example: 7
${buildKitVersionMinor}The current CMake kit minor version. For example: 3
${generator}The name of the CMake generator. For example: Ninja
${testName}The name of the current CTest test. Only expanded in cmake.ctestArgs and cmake.ctestDefaultArgs when running a single test (non-parallel mode or single-test selection). When multiple tests run in a batch, the variable is not expanded and a warning is logged.
${projectName}DEPRECATED. Expands to the constant string "ProjectName" CMake does not consider there to be just one project name to use. The concept of a single project does not work in CMake. Use ${workspaceRootFolderName}, instead.
${userHome}The full path to the current user's home directory.

Environment variables

Environment variables are expanded using the ${env:VARNAME} and ${env.VARNAME} syntax, where VARNAME is the environment to variable to expand. If the named environment variable is undefined, the expansion is an empty string.

Variant substitution

Variant options are expanded using the ${variant:VARIANTNAME} syntax, where the name of the currently active choice of the provided VARIANTNAME variant option is expanded. If the variant option is undefined, the expansion is an empty string.

Command substitution

CMake Tools can expand VS Code commands. For example, you can expand the path to the launch target by using the syntax ${command:cmake.launchTargetPath}.

This form is the recommended way to get CMake Tools values in generic tasks.json or launch.json fields.

Be careful with long-running commands because it isn't specified when, or how many times, CMake Tools will execute a command for a given expansion.

Supported commands for substitution:

commandsubstitution
cmake.getLaunchTargetPathThe full path to the target executable, including the filename. The existence of the target is not validated.
cmake.getLaunchTargetDirectoryThe full path to the target executable's directory. The existence of the directory is not validated.
cmake.getLaunchTargetFilenameThe name of the target executable file without any path information. The existence of the target is not validated.
cmake.getLaunchTargetNameThe name to the target. The existence of the target is not validated.
cmake.launchTargetPathThe full path to the target executable, including the filename. If cmake.buildBeforeRun is true, invoking this substitution will also start a build.
cmake.launchTargetDirectoryThe full path to the target executable's directory. If cmake.buildBeforeRun is true, invoking this substitution will also start a build.
cmake.launchTargetFilenameThe name of the target executable file without any path information. If cmake.buildBeforeRun is true, invoking this substitution will also start a build.
cmake.launchTargetNameThe name of the target. If cmake.buildBeforeRun is true, invoking this substitution will also start a build.
cmake.buildTargetNameThe current target selected for build.
cmake.buildTypeSame as ${buildType}. The current CMake build type.
cmake.buildKitSame as ${buildKit}. The current CMake kit name.
cmake.buildDirectoryThe full path to the directory where CMake cache files are located.
cmake.tasksBuildCommandThe CMake command used to build your project based on the currently selected Kit + Variant + Target. Suitable for use within tasks.json.
cmake.activeFolderNameThe name of the active folder (e.g. in a multi-root workspace)
cmake.activeFolderPathThe absolute path of the active folder (e.g. in a multi-root workspace)
cmake.activeConfigurePresetNameThe name of the active configure preset.
cmake.activeBuildPresetNameThe name of the active build preset.
cmake.activeTestPresetNameThe name of the active test preset.

Test debug placeholders

The following placeholders are available in launch.json debug configurations used to debug CTest tests from the Test Explorer. See Debugging tests for full examples.

PlaceholderExpansion
${cmake.testProgram}The full path to the test executable.
${cmake.testArgs}The command-line arguments for the test.
${cmake.testWorkingDirectory}The working directory for the test.
${cmake.testEnvironment}The environment variables set via the CTest ENVIRONMENT test property (e.g., from set_tests_properties(... PROPERTIES ENVIRONMENT "A=B;C=D")). Replaced with an array of { "name": "...", "value": "..." } objects suitable for launch.json.

Additional build problem matchers

The cmake.additionalBuildProblemMatchers setting lets you define custom problem matchers that are applied to build output. This is useful when you integrate tools like clang-tidy, PCLint Plus, cppcheck, or custom scripts into your CMake build via add_custom_command or add_custom_target. Diagnostics from these tools will appear in the VS Code Problems pane alongside the standard compiler errors.

Custom matchers run after the built-in parsers (gcc, msvc, gnuld, etc.), so they will not interfere with standard compiler diagnostics.

Each matcher entry has the following properties:

PropertyTypeRequiredDefaultDescription
namestringyesFriendly name shown as the diagnostic source in the Problems pane.
regexpstringyesRegular expression applied to each build output line.
fileintegerno1Capture group index for the file path.
lineintegerno2Capture group index for the line number.
columnintegernoCapture group index for the column number.
severityinteger or stringno"warning"Either a capture group index (integer) that captures "error", "warning", or "info", or a fixed string.
messageintegerno3Capture group index for the diagnostic message.
codeintegernoCapture group index for a diagnostic code.

| cmake.ctest.failurePatterns | Regular expressions for searching CTest output for additional details about failures. All patterns are tried and test failure details from each are collected. Patterns must have at minimum one capture group to match the name of the file where the failure occurred. They can optionally also capture line, message, expected, and actual. For example, to match a failure line like path/to/file:47: text of error message, this pattern matcher could be used: json { "regexp": "(.+):(\\d+): ?(.*)", "file": 1, "line": 2, "message": 3 } | See package.json | no | | cmake.ctest.neverDebugTestsWithLaunchConfiguration | When set to true, always debug tests without a launch configuration, bypassing the quick pick menu. Default is false. | false | no | | cmake.ctest.testSuiteDelimiterMaxOccurrence | Maximum number of times the delimiter may be used to split the name of the test. 0 means no limit. | 0 | no | | cmake.useFolderPropertyInBuildTargetDropdown | Controls if the default build target dropdown is grouped by the CMake folder groups. | false | no | | cmake.showTimestampsInOutput | Show timestamps and log levels in the CMake output channel. Useful for tracking build durations. | false | no |

Examples

clang-tidy (/path/file.cpp:10:5: warning: some message [check-name]):

"cmake.additionalBuildProblemMatchers": [
  {
    "name": "clang-tidy",
    "regexp": "^(.+?):(\\d+):(\\d+):\\s+(warning|error|note):\\s+(.+?)\\s*(?:\\[(.+)\\])?$",
    "file": 1,
    "line": 2,
    "column": 3,
    "severity": 4,
    "message": 5,
    "code": 6
  }
]

cppcheck ([file.cpp:10]: (warning) message):

"cmake.additionalBuildProblemMatchers": [
  {
    "name": "cppcheck",
    "regexp": "^\\[(.+?):(\\d+)\\]:\\s+\\((error|warning|style|performance|portability|information)\\)\\s+(.+)$",
    "file": 1,
    "line": 2,
    "severity": 3,
    "message": 4
  }
]

Custom script with fixed severity (LINT: file.cpp:7: message):

"cmake.additionalBuildProblemMatchers": [
  {
    "name": "my-lint",
    "regexp": "^LINT:\\s+(.+?):(\\d+):\\s+(.+)$",
    "file": 1,
    "line": 2,
    "severity": "error",
    "message": 3
  }
]

Resolving a specific target with ${input:...}

All launch-target commands (cmake.launchTargetPath, cmake.getLaunchTargetPath, and their directory/filename/name variants) accept an optional targetName argument. When targetName is provided, the command resolves that specific executable target without changing the active launch target. This is useful for projects with multiple executables, allowing stable per-target launch.json configurations.

Use VS Code input variables to pass arguments:

{
    "inputs": [
        {
            "id": "serverPath",
            "type": "command",
            "command": "cmake.launchTargetPath",
            "args": { "targetName": "my_server" }
        }
    ]
}

Then reference it in a launch configuration as "program": "${input:serverPath}". See Debugging a specific target for full examples.

Next steps