Reputation: 3976
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:
Upvotes: 1
Views: 75
Reputation: 81
That 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.
Targets represent executables, libraries, and utilities built by CMake. Every
add_library
,add_executable
, andadd_custom_target
command creates a target.
tasks.json
for building with CMake (build generator) tool. Documentation: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/tasks.mdI 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
.
Upvotes: 0