microsoft / microsoft/vscode-cmake-tools

cmake.buildTask does not warn when there is no default build task available

Open
#2,417 11 comments 0 reactions 0 assignees View on GitHub
Feature: build quick fix
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

I have just set up VSCode and CMake tools for a relatively complex project (LLVM). When I run "CMake: Build Target" (for any target), I get the following output but nothing is actually built:

```
[main] Building folder: XXX
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build YYY/build --config Debug --target all -j 98 --
[build] Build finished with exit code 0
```

To find out what is happening, I have replaced `/usr/bin/cmake` with a script that records each invocation including its command line parameters to a new file and then calls the original CMake binary with the same parameters:

```bash
#!/usr/bin/bash

stamp=$(date +%M%S%N)

echo -- "$@" > /tmp/cmake-cmd-$stamp
env > /tmp/cmake-env-$stamp

/usr/bin/cmake.bak "$@"
```

In that complex project, **the only calls to cmake have the parameters `-- --version`** -- no actual build is run (which confirms what I observe in the output window). If I run the command that is said is run manually, it build the project as expected. Also, if I use VSCode+CMake tools with a smaller project, everything works fine, including the tracing to my wrapper script (i.e., I observe calls to CMake that invoke the build target).

I do not know how to debug this further.

### CMake Tools Diagnostics

```
{
"os": "linux",
"vscodeVersion": "1.65.0",
"cmtVersion": "1.9.2",
"configurations": [
{
"folder": "XXX",
"cmakeVersion": "3.22.1",
"configured": true,
"generator": "Ninja",
"usesPresets": false,
"compilers": {
"C": "/usr/bin/cc",
"CXX": "/usr/bin/c++"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [
"file:///XXX/AAA/Main.cpp"
],
"responses": [
{
"uri": "file:///XXX/AAA/Main.cpp",
"configuration": {
"defines": [
"BUILD_EXAMPLES",
"GTEST_HAS_RTTI=0",
"_DEBUG",
"_GNU_SOURCE",
"__STDC_CONSTANT_MACROS",
"__STDC_FORMAT_MACROS",
"__STDC_LIMIT_MACROS"
],
"standard": "c++17",
"includePath": [
"ZZZ"
],
"compilerPath": "/usr/bin/c++",
"compilerArgs": [
"-fPIC",
"-fno-semantic-interposition",
"-fvisibility-inlines-hidden",
"-Werror=date-time",
"-Wall",
"-Wextra",
"-Wno-unused-parameter",
"-Wwrite-strings",
"-Wcast-qual",
"-Wno-missing-field-initializers",
"-pedantic",
"-Wno-long-long",
"-Wimplicit-fallthrough",
"-Wno-maybe-uninitialized",
"-Wno-class-memaccess",
"-Wno-redundant-move",
"-Wno-pessimizing-move",
"-Wno-noexcept-type",
"-Wdelete-non-virtual-dtor",
"-Wsuggest-override",
"-Wno-comment",
"-Wmisleading-indentation",
"-fdiagnostics-color",
"-g",
"-fno-exceptions",
"-fno-rtti",
"-std=c++17"
]
}
}
],
"partialMatches": [],
"targetCount": 4450,
"executablesCount": 298,
"librariesCount": 830,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "never",
"configureOnOpen": false
}
]
}
```

### Debug Log

Also with CMake tracing, we see that the command should be called but isn't. (Note that I shortened the output after `Found index files`.)

```
[extension] [4190] cmake.build started
[main] Building folder: iree-llvm-sandbox
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build IteratorsUnitTests
[proc] Executing command: /usr/bin/cmake --build /XXX/build --config Debug --target IteratorsUnitTests -j 98 --
[cmakefileapi-parser] Read reply folder: /XXX/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["very", "very" "long", "list"]
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[cache] Reading CMake cache file /XXX/build/CMakeCache.txt
[cache] Parsing CMake cache string
[build] Build finished with exit code 0
```

Contributor guide

Open the contributing guide

Research direction

Start with the cmake.build and driver build trace, especially the path showing “Run _refreshExpansions” after the build command is logged. Reproduce the behavior with the supplied diagnostics and a complex project, then trace why no effective build occurs despite exit code 0. Done means the missing default build task is detected and the user receives a warning instead of a successful-looking build.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.