What's targets
in tasks.json
and how to use it? I have the following in tasks.json
:
{
"type": "cmake",
"label": "CMake: build Console",
"command": "build",
"targets": [
"Console"
],
"options": {
"cwd": "${workspaceRoot}/build"
},
"group": {
"kind": "build",
"isDefault": false
},
"problemMatcher": [],
"detail": "CMake build Console"
},
build task started....
/usr/bin/cmake --build /usr/src/DataStructuresAlgorithms/build --config Debug --target Console --
ninja: error: unknown target 'Console'
build finished with error(s).
I have "CMake Tools" extension installed but I don't see "build target" at the bottom bar at all:
What's targets
in tasks.json
and how to use it? I have the following in tasks.json
:
{
"type": "cmake",
"label": "CMake: build Console",
"command": "build",
"targets": [
"Console"
],
"options": {
"cwd": "${workspaceRoot}/build"
},
"group": {
"kind": "build",
"isDefault": false
},
"problemMatcher": [],
"detail": "CMake build Console"
},
build task started....
/usr/bin/cmake --build /usr/src/DataStructuresAlgorithms/build --config Debug --target Console --
ninja: error: unknown target 'Console'
build finished with error(s).
I have "CMake Tools" extension installed but I don't see "build target" at the bottom bar at all:
Share Improve this question edited yesterday khteh asked 2 days ago khtehkhteh 3,96210 gold badges58 silver badges103 bronze badges 1 |1 Answer
Reset to default 0That is a reference to CMake targets to be later triggered with VSCode Integration with External Tools via Tasks configured by CMake Tools (extension) Task Provider. Seems that CMakeLists.txt
is required to reference existing targets.
Documentation
- CMake Targets
Targets represent executables, libraries, and utilities built by CMake. Every
add_library
,add_executable
, andadd_custom_target
command creates a target.
- CMake Tools VSCode extension adds ability to configure
tasks.json
for building with CMake (build generator) tool. Documentation: https://github/microsoft/vscode-cmake-tools/blob/main/docs/tasks.md
Observation
I am using CMake Tools VSCode extension and at the bottom bar it has "build target" selector from: all, install, project name (executable), linked libraries names. Which is seems to be a GUI analog of tasks.json
.
tasks.json
is a poor build system, better switch to pure CMake, vscode has extension. 2. I am using VSCode CMake extension and at bottom bar it has build target selector from: all, install, `project name_ (executable), linked libraries project names. Answer: seems to be a non-gui json connector to the same CMake thing. Read: github/microsoft/vscode-cmake-tools/blob/main/docs/tasks.md – int main Commented 2 days ago