microsoft / microsoft/vscode-cmake-tools

CMake: Compile Active File command should rely on cmake-file-api instead of compile_commands.json

Open
#2,473 1 comment 3 reactions 0 assignees View on GitHub
enhancement Feature: build help wanted
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### How CMake: Compile Active File works

From the discussion in issue #2180 (now closed), it appears that the CMake: Compile Active File command only works if the `compile_commands.json` file is exported and made available somewhere. However, this poses a limitation, since the only two CMake generators supporting the export of the compile commands file are Makefile and Ninja (Ninja Multi-Config exports one compile commands file with all configurations mixed up and therefore is unusable, though this seems a problem of CMake itself, not this extension).

### Using cmake-file-api

As far as I've understood, [cmake-file-api](https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html) exposes all the information needed to compile and build targets and even single files for any generator (even Visual Studio or Ninja Multi-Config). Relying on this instead of compile commands file should make Compile Active File always work independently from the platform or generator.

Would it be possible/make sense to make this modification? After all, interaction with file APIs is already implemented in this extension as from setting `cmake.cmakeCommunicationMode` and I suppose that is how targets are built from the CMake Project Outline in the Primary Side Bar.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the CMake: Compile Active File command and compare its current compile_commands.json dependency with the existing cmake.cmakeCommunicationMode and CMake Project Outline file-API interactions. Read the cmake-file-api documentation to determine how generator- and configuration-specific compile information could replace the current source, then verify that the command works across the generators described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, typescript
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.