microsoft / microsoft/vscode-cmake-tools

API: wrong target build artifact paths

Open
#3,015 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature: code model investigation needed
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

Brief Issue Summary

The path to the target´s build artifacts returned by the API do not resolve to the actual location of the artifact on the disk when the target is defined in another directory than cmake.sourceDirectory.

cmake.getLaunchTargetPath returns:
C:\work\src\incubator\buildpath\build\src\buildpath.exe
API project.codeModel.configurations[0].projects[0].targets[0].artifacts gives
C:\work\src\incubator\buildpath\build\src\src\buildpath.exe

CMake Tools Diagnostics
{
  "os": "win32",
  "vscodeVersion": "1.75.0",
  "cmtVersion": "1.13.45",
  "configurations": [
    {
      "folder": "c:\\work\\src\\incubator\\buildpath",
      "cmakeVersion": "3.25.1",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "C:/msys64/mingw64/bin/cc.exe",
        "CXX": "C:/msys64/mingw64/bin/c++.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "buildpath",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}
Debug Log

No response

Additional Information

Demo Project: buildpath.zip

Converting the build artifact path to an absolute path is done in different ways.

The API version includes the target's build directory whereas for the launchTargetPath only includes the top-level build directory. According to the cmake documentation the artifacts path is relative to the top-level build directory.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/drivers/cmakeFileApi.ts at the linked locations around lines 376 and 481, and compare how cmake.getLaunchTargetPath and the API convert CMake File API artifact paths. Reproduce the buildpath.zip case, then verify that project.codeModel.configurations[0].projects[0].targets[0].artifacts resolves to the actual artifact location relative to the top-level build directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, typescript
Domain
api, build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.