refactor: make cmake.install a first-class operation using cmake --install#4758
Open
refactor: make cmake.install a first-class operation using cmake --install#4758
Conversation
Copilot
AI
changed the title
[WIP] Add CMake: Install Component command
Add Feb 25, 2026
CMake: Install Component command
1f27e5d to
a05c9c1
Compare
7a216a5 to
e4c6e3c
Compare
Copilot
AI
changed the title
Add
Surface cmake --install stderr in Output channel and add permission error hint
Feb 27, 2026
CMake: Install Component commandAdd a new 'CMake: Install Component' command that uses 'cmake --install <dir> --component <name>' to install specific CMake install components. - Add parseInstallComponentsFromContent() to parse cmake_install.cmake - Add getInstallComponents() method on CMakeProject - Add showComponentSelector() with QuickPick and InputBox fallback - Add installComponent() method on CMakeProject and ExtensionManager - Register cmake.installComponent command in package.json - Add unit tests for component parsing - Require CMake >= 3.15 with version guard Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
e4c6e3c to
b9c91f2
Compare
…stall Previously, cmake.install was implemented as `this.build(['install'])`, routing through `cmake --build <dir> --target install`. This didn't match CMake's actual command model where build and install are distinct CLI actions. Now install uses `cmake --install <dir>` (CMake >= 3.15): - Add CMakeDriver.getCMakeInstallCommand() for command construction - Add CMakeDriver.install() as a first-class driver method with its own concurrency gating, telemetry, and output handling - Refactor CMakeProject.install() to use drv.install() with proper progress/cancellation/output UX - Add CMakeTaskProvider.runInstallTask() so install tasks use the new path instead of routing through runBuildTask - Falls back to cmake --build --target install for CMake < 3.15 - Add 6 unit tests for install command construction All existing API surface, telemetry, cancellation, and output behavior is preserved. The install task and command-palette install now use the same coherent code path. Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Remove the installComponent/installUtils code from previous PR iterations. This branch should only contain the install refactor that makes cmake.install a first-class operation. Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
…t docs Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Copilot
AI
changed the title
Surface cmake --install stderr in Output channel and add permission error hint
refactor: make cmake.install a first-class operation using cmake --install
Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change addresses item #4281
This changes visible behavior
cmake.installwas implemented asthis.build(['install']), forcing install throughcmake --build <dir> --target install. This doesn't match CMake's command model where build and install are distinct CLI actions, and blocks future install-specific flags like--component.The following changes are proposed:
CMakeDriver.install()— new first-class driver method usingcmake --install <dir>, with concurrency gating, telemetry, output encoding, and cancellation matching the existingbuild()patternCMakeDriver.getCMakeInstallCommand()— constructs install command with--config(multi-config generators) and--prefix(fromcmake.installPrefix)CMakeProject.install()— refactored from one-linerthis.build(['install'])to proper install flow:ensureConfigured()→drv.install()with progress/cancellation/output UXCMakeTaskProvider.runInstallTask()— install tasks callcmakeDriver.install()directly instead of routing throughrunBuildTask()--installdoesn't exist) automatically falls back tocmake --build --target install--prefix, and version gatingBefore → After:
Other Notes/Information
getCMakeInstallCommand()is public and returns a structured command object — adding--componentin a follow-up is a one-line changeCommandType.installbranch removed fromcorrectTargets()since install no longer flows through build task dispatchOriginal prompt
This section details on the original issue you should resolve
<issue_title>add
CMake: Install Component</issue_title><issue_description>### Brief Issue Summary
This is a feature request for
CMake: Build Targetvia Ctrl+Shift+P.For build I can call
CMake: BuildandCMake: Build Target.For install I can call
CMake: Installbut notCMake: Install Componentbecause its missing. It should work analogously toCMake: Build Target.Additional Information
I use CMake Tools 1.19.52 with VS Code 1.97.2.</issue_description>
<agent_instructions>You are Copilot coding agent acting as a senior maintainer for microsoft/vscode-cmake-tools. You are deeply familiar with CMake, CMake CLI modes (build, install, configure), VS Code extension APIs, and this TypeScript-heavy repo. Resolve the issue below safely, matching existing patterns.
SOURCE OF TRUTH
#4281 — Feature: Add
CMake: Install Componentcommand. The maintainer @gcampbell-msft confirmed this is a "medium" feature that should follow the pattern ofCMake: Build Target. Read the full issue thread including comments.ISSUE CONTEXT
CMake: Installrunscmake --build <dir> --target install, installing all components. CMake supports component-based install viacmake --install <dir> --component <name>(docs). There is no VS Code command to install a specific component.Critical implementation detail:
--componentrequires thecmake --installCLI mode (CMake 3.15+), which is a fundamentally different command thancmake --build --target install. The currentinstall()method delegates tobuild(['install'])— this path cannot support components. A new execution path is needed.KEY CODE LOCATIONS
Current install implementation:
src/cmakeProject.ts~L2543:install()→this.build(['install'], false, false, cancellationToken). No component support via this path.src/extension.ts~L1534-1547:ExtensionManager.install()andinstallAll()— command entry points. Follow this pattern forinstallComponent().src/api.ts~L146-157:CMakeProjectWrapper.install()andinstallWithResult()— API surface. AddinstallComponentvariant.Pattern to follow —
CMake: Build Target:src/cmakeProject.ts~L2258-2274:buildWithTarget(specified_target?)— showsshowTargetSelector()picker if no target specified, then builds. Mirror this forinstallComponent(component?).src/cmakeProject.ts~L2277-2367:showTargetSelector()— quick pick with fallback toshowInputBoxwhen no targets available. Create analogousshowComponentSelector().src/extension.ts~L1579-1591:ExtensionManager.buildWithTarget()— command registration pattern to follow exactly.CMake driver (where cmake is invoked):
src/drivers/cmakeDriver.ts~L1950-2020:generateBuildCommandFromPreset()andgetCMakeBuildCommand()— build command construction. You need a NEW method likerunCMakeInstall(component, config?)that producescmake --install <binaryDir> --component <name> [--config <config>] [--prefix <prefix>]and executes it viaproc.execute.src/drivers/cmakeDriver.ts~L863:binaryDirgetter — the build directory forcmake --install.src/drivers/cmakeDriver.ts~L883:installDirgetter — use for--prefixif configured.src/cmakeExecutable.ts~L49-65:getCMakeExecutableInformation()— version detection. Use to enforce CMake ≥ 3.15.Component discovery:
CodeModelKind.InstallInfo(~src/drivers/cmakeFileApi.tsL140) has destinations/prefix but NOT component names.<buildDir>/cmake_install.cmakeasif(CMAKE_INSTALL_COMPONENT STREQUAL "<name>")blocks. Parse this file with a regex.showInputBox(matching howshowTargetSelectorfalls back whendrv.targets.length === 0).Task provider:
src/cmakeTaskProvider.ts~L21-70:CommandTypeenum andCMakeTaskDefinition. AddinstallComponenttype with optionalcomponentfield.src/cmakeTaskProvider.ts~L422-439:correctTargets()— hardcodestargets = ['install']for install type. New type needs different handling.Command registration:
package.json~L484:cmake.installcommand. Addcmake.installComponentnext to it.package.nls.json~L42:cmake-tools.command.cmake.install.title. AddinstallComponenttitle.i18n/*/package.i18n.json— add translations for the new command.WHAT TO IMPLEMENT
getInstallComponents()method onCMakeProject:<buildDir>/cmake_install.cmakeif(CMAKE_INSTALL_COMPONENT STREQUAL "<name>")patternsCMake: Install Component#4281🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.