microsoft / microsoft/vscode-cmake-tools

Feature request: Improve automatic vcpkg integration.

Open
#1,193 4 comments 1 reaction 0 assignees View on GitHub
enhancement Feature: configure stale-exempt
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

Dear @bobbrow, I would like to hear your opinion on the following issue:

Currently, new C++ developers have a tough time figuring out how to use libraries. This extension adds vcpkg integration by providing CMake with the vcpkg toolchain, but the user has still to take case of many things, especially `/MD` `/MTd` etc. flags on Windows.

The default vcpkg toolchain also completely ignores the triplet settings, including `VCPKG_CHAINLOAD_TOOLCHAIN_FILE`.

I've spent quite some time figuring out how to improve usability and the emerging setup is not something I'd expect new users to be able to reproduce in a reasonable amount of time:

1. Create a custom toolchain ([C:\Workspace\vcpkg\triplets\toolchains\res\toolchain.cmake](https://github.com/qis/toolchains/blob/master/res/toolchain.cmake) in my case, but it could be located anywhere else) that wraps the vcpkg one.
2. Scan for VS toolkits in VS Code, then use the `visualStudio` ID to create your own:
```json
[
{
"keep": true,
"name": "x64-windows",
"visualStudio": "c62a5cb9",
"visualStudioArchitecture": "amd64",
"toolchainFile": "${env.VCPKG_ROOT}\\triplets\\toolchains\\res\\toolchain.cmake"
}
]
```
3. Edit the VS Code config to be able to build and debug a target with VS Code:
```json
"cmake.buildDirectory": "${workspaceFolder}/build/windows/debug",
"cmake.installPrefix": "${workspaceFolder}/build/install",
"cmake.cmakeCommunicationMode": "fileApi",
"cmake.configureOnOpen": true,
"cmake.generator": "Ninja",
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "run",
"type": "cppvsdbg",
"request": "launch",
"internalConsoleOptions": "openOnSessionStart",
"program": "${command:cmake.launchTargetPath}",
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"environment": [],
"args": []
}
]
}
```

Everything else I tried requires changes to projects wich are not portable if they are committed as the `.vscode` directory into git.

Please don't get me wrong. I am very happy that it works. Thank you and @vector-of-bool for that. I am just worried about new users are having it more difficult, than it needs to be.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing vcpkg integration, VS toolkit scanning, and CMake configuration paths in vscode-cmake-tools. Reproduce the Windows setup described with the custom toolchain.cmake and vcpkg triplet settings, then define a simpler portable configuration flow whose behavior can be verified for build and debug scenarios.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, typescript
Domain
build-system, developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.