microsoft / microsoft/vscode-cmake-tools

Build task isn't colored in terminal

Open
#2,783 5 comments 8 reactions 0 assignees View on GitHub
enhancement Feature: tasks upstream
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

I'm trying to get color output in terminal. Suggested workaround here https://github.com/microsoft/vscode-cmake-tools/issues/478#issuecomment-1081093372 isn't working as expected.

Compiler errors are only colored with `set(CMAKE_CXX_FLAGS -fdiagnostics-color=always)` is in **CMakeList.txt**,
but "Building CXX Object" messages are still in white.

Switching task to shell command shows desired colored output ("Building CXX Object" messages are in green color):
```json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "CMake: build and run",
"command": "cmake --build ${workspaceFolder}/build --config Debug --target ${workspaceFolderBasename} && ${workspaceFolder}/build/${workspaceFolderBasename}",
"group": "build"
}
]
}
```

### CMake Tools Diagnostics

CMake: Log Diagnostics

```shell
{
"os": "linux",
"vscodeVersion": "1.72.0",
"cmtVersion": "1.12.27",
"configurations": [
{
"folder": "/home/serfreeman1337/Dev/tmp-esp32-cv-test",
"cmakeVersion": "3.24.2",
"configured": true,
"generator": "Unix Makefiles",
"usesPresets": false,
"compilers": {
"C": "/usr/bin/gcc",
"CXX": "/usr/bin/g++"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [
"file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/oh.cc",
"file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/tmp-esp32-cv-test.cc"
],
"responses": [
{
"uri": "file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/oh.cc",
"configuration": {
"includePath": [
"/usr/include/opencv4"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"compilerArgs": [],
"compilerFragments": [
"-g",
"-std=gnu++17"
]
}
},
{
"uri": "file:///home/serfreeman1337/Dev/tmp-esp32-cv-test/tmp-esp32-cv-test.cc",
"configuration": {
"includePath": [
"/usr/include/opencv4"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"compilerArgs": [],
"compilerFragments": [
"-g",
"-std=gnu++17"
]
}
}
],
"partialMatches": [],
"targetCount": 1,
"executablesCount": 1,
"librariesCount": 0,
"targets": [
{
"name": "tmp-esp32-cv-test",
"type": "EXECUTABLE"
}
]
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
```

### Debug Log

_No response_

### Additional Information

Screenshots

Workaroud with `set(CMAKE_CXX_FLAGS -fdiagnostics-color=always)`:
![image](https://user-images.githubusercontent.com/2133936/194719375-db38e4ec-73f6-48f5-812b-ce5631103632.png)

Task as shell command without `fdiagnostics-color` flag:
![image](https://user-images.githubusercontent.com/2133936/194719384-f4b230d0-496d-4f93-a220-a600962c3d2e.png)

Contributor guide

Open the contributing guide

Research direction

No repository files, tests, or entry points are named. Start by tracing the CMake build task's terminal output handling and compare it with the shell task behavior described in the issue; done means the built-in build task displays the build messages with the expected colors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, typescript
Domain
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.