microsoft / microsoft/vscode-cmake-tools

"ms-vscode.cmake-tools" C/CPP configuration provider unable to find headers from nuget package

Open
#2,982 2 comments 0 reactions 0 assignees View on GitHub
bug Feature: cpptools integration investigation needed
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

The CMake VS_PACKAGE_REFERENCES target property can be used to make C++ nuget packages (such as C++/WinRT, WIL, and the Windows App SDK) available to CMake projects.

This works fine if I use Visual Studio to open the CMake-produced vcxproj and friends, but VS Code is unable to locate these headers, and in turn, this makes intellisense not usable for files including headers from nuget packages.

### CMake Tools Diagnostics

```shell
{
"os": "win32",
"vscodeVersion": "1.74.3",
"cmtVersion": "1.13.43",
"configurations": [
{
"folder": "c:\\Users\\Fred\\code\\openkneeboard",
"cmakeVersion": "3.25.1",
"configured": true,
"generator": "Visual Studio 17 2022",
"usesPresets": false,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug",
"Release",
"MinSizeRel",
"RelWithDebInfo"
],
"requests": [
"file:///c%3A/Users/Fred/code/openkneeboard/src/app/app-winui3/MainWindow.xaml.cpp"
],
"responses": [
{
"uri": "file:///c%3A/Users/Fred/code/openkneeboard/src/app/app-winui3/MainWindow.xaml.cpp",
"configuration": {
"includePath": [
"c:/users/fred/code/openkneeboard/src/app/app-winui3",
"c:/users/fred/code/openkneeboard/build/third-party/cppwinrtnuget-prefix/src/cppwinrtnuget-build/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/gameslist/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/pagesource/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/tab/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/tabslist/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/toolbaritems/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/uilayers/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/userinput/include",
"c:/users/fred/code/openkneeboard/src/app/app-common/include",
"c:/users/fred/code/openkneeboard/build/third-party/jsonfetch-prefix/include",
"c:/users/fred/code/openkneeboard/src/lib/include",
"c:/users/fred/code/openkneeboard/build/src/lib/include",
"c:/users/fred/code/openkneeboard/src/games/include",
"c:/users/fred/code/openkneeboard/third-party/out_ptr/include",
"c:/users/fred/code/openkneeboard/build/third-party/semverbuild-prefix/src/semverbuild/include"
],
"defines": [
"BUILD_CONFIG=\"Debug\"",
"DEBUG",
"DIRECTINPUT_VERSION=0x0800",
"DISABLE_XAML_GENERATED_MAIN=1",
"NOMINMAX=1",
"OPENKNEEBOARD_BREAK=__debugbreak()",
"OPENKNEEBOARD_JSON_SERIALIZE=1",
"OPENKNEEBOARD_UNREACHABLE=__assume(false)",
"UNICODE=1",
"WIN32_LEAN_AND_MEAN=1",
"_UNICODE=1"
],
"compilerPath": "c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.34.31933/bin/hostx64/x64/cl.exe",
"compilerArgs": [],
"compilerFragments": [
"/DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -MTd",
"/EHsc",
"/await:strict",
"/FS",
"/diagnostics:caret",
"/Zc:__cplusplus",
"/utf-8",
"/WX",
"/wd4996",
"/wd4250",
"/wd4297",
"/FIC:/Users/Fred/code/openkneeboard/build/src/app/app-winui3/CMakeFiles/OpenKneeboard-App-WinUI3.dir/Debug/cmake_pch.hxx",
"-std:c++20",
"/YuC:/Users/Fred/code/openkneeboard/build/src/app/app-winui3/CMakeFiles/OpenKneeboard-App-WinUI3.dir/Debug/cmake_pch.hxx /FpC:/Users/Fred/code/openkneeboard/build/src/app/app-winui3/OpenKneeboard-App-WinUI3.dir/Debug/cmake_pch.pch /FIC:/Users/Fred/code/openkneeboard/build/src/app/app-winui3/CMakeFiles/OpenKneeboard-App-WinUI3.dir/Debug/cmake_pch.hxx"
]
}
}
],
"partialMatches": [],
"targetCount": 126,
"executablesCount": 25,
"librariesCount": 49,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
```

### Debug Log

_No response_

### Additional Information

Example projects:
- https://github.com/fredemmott/cmake-cpp-winrt-winui3 - toy example
- https://github.com/OpenKneeboard/OpenKneeboard - real-world example. Most files work fine, but the `.xaml.cpp` files in `src/app/app-winui3` in particular have this problem, e.g. `src/app/app-winui3/MainWindow.xaml.cpp`. One symptom of this is to type `this->` then press ctrl+space. This works fine in Visual Studio, but with CMake Tools as the intellisense configuration provider, finds no results.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the reported cmake-cpp-winrt-winui3 example and inspect the CMake Tools diagnostics for MainWindow.xaml.cpp. Trace how the configuration provider handles VS_PACKAGE_REFERENCES and compare its includePath with the NuGet package headers. Done means headers from the NuGet packages resolve in VS Code IntelliSense and completion works for the example files.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, typescript, vscode
Domain
build-system, developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.