最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

visual studio code - VSCode CMake targets - what is it and how to use it? - Stack Overflow

programmeradmin4浏览0评论

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
  • 2 1. 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
Add a comment  | 

1 Answer 1

Reset to default 0

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.

Documentation

  • CMake Targets

Targets represent executables, libraries, and utilities built by CMake. Every add_library, add_executable, and add_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.

发布评论

评论列表(0)

  1. 暂无评论