cmake-file-api(7)

簡介

CMake 提供一個基於檔案的 API,客戶端可以使用它來獲取關於 CMake 產生的建置系統的語義資訊。客戶端可以通過寫入查詢檔案到建置樹中的特定位置來使用 API,以請求零個或多個物件種類。當 CMake 在該建置樹中產生建置系統時,它將讀取查詢檔案並寫入回覆檔案供客戶端讀取。

基於檔案的 API 使用建置樹頂層的 <build>/.cmake/api/ 目錄。API 已版本化,以支援 API 目錄內檔案佈局的變更。API 檔案佈局版本控制與回覆中使用的物件種類的版本控制是正交的。此 CMake 版本僅支援一個 API 版本,API v1

3.27 版本新增: 專案也可以使用 cmake_file_api() 命令,為當前執行提交查詢。

API v1

API v1 位於 <build>/.cmake/api/v1/ 目錄中。它具有以下子目錄

query/

存放客戶端寫入的查詢檔案。這些可能是v1 共用無狀態查詢檔案v1 客戶端無狀態查詢檔案v1 客戶端有狀態查詢檔案

reply/

存放 CMake 每次執行以產生建置系統時寫入的回覆檔案。這些檔案由v1 回覆索引檔案索引,該檔案可能會參考其他v1 回覆檔案。CMake 擁有所有回覆檔案。客戶端絕不能移除它們。

客戶端可以隨時尋找並讀取回覆索引檔案。客戶端可以選擇性地隨時建立 reply/ 目錄,並監控它以查看新回覆索引檔案的出現。

3.31 版本新增: 使用者可以將查詢檔案新增到 api/v1/query 內部的 CMAKE_CONFIG_DIR 中,以為所有 CMake 專案建立使用者範圍的查詢。

v1 共用無狀態查詢檔案

共用無狀態查詢檔案允許客戶端共用對物件種類主要版本的請求,並取得運行的 CMake 識別的所有請求版本。

客戶端可以通過在 v1/query/ 目錄中建立空檔案來建立共用請求。格式為

<build>/.cmake/api/v1/query/<kind>-v<major>

其中 <kind>物件種類之一,-v 是字面值,而 <major> 是主要版本號。

此格式的檔案是無狀態共用查詢,不屬於任何特定客戶端。一旦建立,在沒有外部客戶端協調或人為干預的情況下,不應移除它們。

v1 客戶端無狀態查詢檔案

客戶端無狀態查詢檔案允許客戶端建立擁有的物件種類主要版本的請求,並取得運行的 CMake 識別的所有請求版本。

客戶端可以通過在客戶端特定的查詢子目錄中建立空檔案來建立擁有的請求。格式為

<build>/.cmake/api/v1/query/client-<client>/<kind>-v<major>

其中 client- 是字面值,<client> 是唯一識別客戶端的字串,<kind>物件種類之一,-v 是字面值,而 <major> 是主要版本號。每個客戶端都必須通過自己的方式選擇唯一的 <client> 識別碼。

此格式的檔案是由客戶端 <client> 擁有的無狀態查詢。擁有客戶端可以隨時移除它們。

v1 客戶端有狀態查詢檔案

有狀態查詢檔案允許客戶端請求每個物件種類的版本列表,並僅取得運行的 CMake 識別的最新版本。

客戶端可以通過在客戶端特定的查詢子目錄中建立 query.json 檔案來建立擁有的有狀態查詢。格式為

<build>/.cmake/api/v1/query/client-<client>/query.json

其中 client- 是字面值,<client> 是唯一識別客戶端的字串,而 query.json 是字面值。每個客戶端都必須通過自己的方式選擇唯一的 <client> 識別碼。

query.json 檔案是由客戶端 <client> 擁有的有狀態查詢。擁有客戶端可以隨時更新或移除它們。當給定的客戶端安裝更新時,它可以更新它寫入建置樹的有狀態查詢,以請求更新的物件版本。這可以用於避免不必要地要求 CMake 產生多個物件版本。

query.json 檔案必須包含一個 JSON 物件

{
  "requests": [
    { "kind": "<kind>" , "version": 1 },
    { "kind": "<kind>" , "version": { "major": 1, "minor": 2 } },
    { "kind": "<kind>" , "version": [2, 1] },
    { "kind": "<kind>" , "version": [2, { "major": 1, "minor": 2 }] },
    { "kind": "<kind>" , "version": 1, "client": {} },
    { "kind": "..." }
  ],
  "client": {}
}

成員為

requests

一個 JSON 陣列,包含零個或多個請求。每個請求都是一個 JSON 物件,其成員為

kind

指定要包含在回覆中的物件種類之一。

version

指示客戶端理解的物件種類的版本。版本具有遵循語義版本慣例的主要和次要組件。值必須是

  • 指定(非負)主要版本號的 JSON 整數,或

  • 包含 major 和(可選)minor 成員的 JSON 物件,這些成員指定非負整數版本組件,或

  • 一個 JSON 陣列,其元素是上述的其中之一。

client

保留供客戶端使用的可選成員。此值保留在為客戶端寫入的v1 回覆索引檔案中,但在其他方面被忽略。客戶端可以使用它將自訂資訊與請求一起傳遞到其回覆。

對於每個請求的物件種類,CMake 將從請求中列出的版本中選擇它識別為該種類的第一個版本。回應將使用選定的主要版本,以及運行的 CMake 已知的該主要版本的最高次要版本。因此,客戶端應按優先順序列出所有支援的主要版本,以及每個主要版本所需的最小次要版本。

client

保留供客戶端使用的可選成員。此值保留在為客戶端寫入的v1 回覆索引檔案中,但在其他方面被忽略。客戶端可以使用它將自訂資訊與查詢一起傳遞到其回覆。

其他 query.json 頂層成員保留供將來使用。如果存在,為了向前相容性,它們將被忽略。

v1 回覆索引檔案

每當 CMake 運行以產生建置系統時,它都會將 index-*.json 檔案寫入 v1/reply/ 目錄。客戶端必須首先讀取回覆索引檔案,並且只能通過追蹤參考來讀取其他v1 回覆檔案。回覆索引檔案名稱的格式為

<build>/.cmake/api/v1/reply/index-<unspecified>.json

其中 index- 是字面值,而 <unspecified> 是 CMake 選擇的未指定名稱。每當產生新的索引檔案時,都會給它一個新名稱,並刪除任何舊的索引檔案。在這些步驟之間的短暫時間內,可能會存在多個索引檔案;按字典順序名稱最大的那個是當前的索引檔案。

回覆索引檔案包含一個 JSON 物件

{
  "cmake": {
    "version": {
      "major": 3, "minor": 14, "patch": 0, "suffix": "",
      "string": "3.14.0", "isDirty": false
    },
    "paths": {
      "cmake": "/prefix/bin/cmake",
      "ctest": "/prefix/bin/ctest",
      "cpack": "/prefix/bin/cpack",
      "root": "/prefix/share/cmake-3.14"
    },
    "generator": {
      "multiConfig": false,
      "name": "Unix Makefiles"
    }
  },
  "objects": [
    { "kind": "<kind>",
      "version": { "major": 1, "minor": 0 },
      "jsonFile": "<file>" },
    { "...": "..." }
  ],
  "reply": {
    "<kind>-v<major>": { "kind": "<kind>",
                         "version": { "major": 1, "minor": 0 },
                         "jsonFile": "<file>" },
    "<unknown>": { "error": "unknown query file" },
    "...": {},
    "client-<client>": {
      "<kind>-v<major>": { "kind": "<kind>",
                           "version": { "major": 1, "minor": 0 },
                           "jsonFile": "<file>" },
      "<unknown>": { "error": "unknown query file" },
      "...": {},
      "query.json": {
        "requests": [ {}, {}, {} ],
        "responses": [
          { "kind": "<kind>",
            "version": { "major": 1, "minor": 0 },
            "jsonFile": "<file>" },
          { "error": "unknown query file" },
          { "...": {} }
        ],
        "client": {}
      }
    }
  }
}

成員為

cmake

一個 JSON 物件,包含關於產生回覆的 CMake 實例的資訊。它包含成員

version

version

一個 JSON 物件,指定 CMake 的版本,其成員為

majorminorpatch

指定主要、次要和修補程式版本組件的整數值。

suffix

一個字串,指定版本後綴(如果有的話),例如 g0abc3

string

一個字串,以 <major>.<minor>.<patch>[-<suffix>] 格式指定完整版本。

isDirty

一個布林值,指示版本是否是從具有本地修改的版本控制原始碼樹建置的。

paths

一個 JSON 物件,指定 CMake 附帶的工具的路徑。它具有 cmakectestcpack 的成員,它們的值是 JSON 字串,指定每個工具的絕對路徑,以正斜線表示。它還有一個 root 成員,用於包含 CMake 資源(如 Modules/ 目錄)的目錄的絕對路徑(請參閱 CMAKE_ROOT)。

generator

一個 JSON 物件,描述用於建置的 CMake 產生器。它具有成員

multiConfig

一個布林值,指定產生器是否支援多個輸出組態。

name

一個字串,指定產生器的名稱。

platform

如果產生器支援 CMAKE_GENERATOR_PLATFORM,則這是一個字串,指定產生器平台名稱。

objects

一個 JSON 陣列,列出作為回覆一部分產生的所有物件種類的所有版本。每個陣列條目都是一個v1 回覆檔案參考

reply

一個 JSON 物件,鏡像 CMake 載入以產生回覆的 query/ 目錄的內容。成員格式為

<kind>-v<major>

對於 CMake 識別為請求物件種類 <kind> 且主要版本為 <major> 的每個v1 共用無狀態查詢檔案,都會出現這種格式的成員。值是一個v1 回覆檔案參考,指向該物件種類和版本的相應回覆檔案。

<unknown>

對於 CMake 無法識別的每個v1 共用無狀態查詢檔案,都會出現這種格式的成員。值是一個 JSON 物件,其中包含一個 error 成員,其中包含一個錯誤訊息,指示查詢檔案未知。

client-<client>

一個 JSON 物件,鏡像 CMake 載入以產生回覆的 query/ 目錄的內容。成員格式為

對於每個持有v1 客戶端無狀態查詢檔案的客戶端擁有的目錄,都會出現這種格式的成員。值是一個 JSON 物件,鏡像 query/client-<client>/ 目錄的內容。成員格式為

對於 CMake 識別為請求物件種類 <kind> 且主要版本為 <major> 的每個v1 共用無狀態查詢檔案,都會出現這種格式的成員。值是一個v1 回覆檔案參考,指向該物件種類和版本的相應回覆檔案。

對於 CMake 識別為請求物件種類 <kind> 且主要版本為 <major> 的每個v1 客戶端無狀態查詢檔案,都會出現這種格式的成員。值是一個v1 回覆檔案參考,指向該物件種類和版本的相應回覆檔案。

對於 CMake 無法識別的每個v1 客戶端無狀態查詢檔案,都會出現這種格式的成員。值是一個 JSON 物件,其中包含一個 error 成員,其中包含一個錯誤訊息,指示查詢檔案未知。

query.json

client

此成員針對使用v1 客戶端有狀態查詢檔案的客戶端出現。如果 query.json 檔案讀取或解析為 JSON 物件失敗,則此成員是一個 JSON 物件,其中包含一個 error 成員,其中包含一個錯誤訊息。否則,此成員是一個 JSON 物件,鏡像 query.json 檔案的內容。成員為

requests

client

如果存在,則為 query.json 檔案 client 成員的副本。

requests

  • 如果存在,則為 query.json 檔案 requests 成員的副本。

  • responses

如果 query.json 檔案 requests 成員遺失或無效,則此成員是一個 JSON 物件,其中包含一個 error 成員,其中包含一個錯誤訊息。否則,此成員包含一個 JSON 陣列,其中包含 requests 陣列的每個條目的回應,順序相同。每個回應都是

一個 JSON 物件,其中包含一個 error 成員,其中包含一個錯誤訊息,或

一個v1 回覆檔案參考,指向請求的物件種類和選定版本的相應回覆檔案。

kind

在讀取回覆索引檔案後,客戶端可以讀取它參考的其他v1 回覆檔案

version

v1 回覆檔案參考

回覆索引檔案使用具有成員的 JSON 物件來表示對另一個回覆檔案的每個參考

kind

一個字串,指定物件種類之一。

version

一個 JSON 物件,其成員為 majorminor,指定物件種類的整數版本組件。

jsonFile

一個 JSON 字串,指定相對於回覆索引檔案的路徑,指向包含物件的另一個 JSON 檔案。

{
  "kind": "<kind>",
  "version": { "major": 1, "minor": 0 },
  "...": {}
}

v1 回覆檔案

包含特定物件種類的回覆檔案由 CMake 寫入。這些檔案的名稱未指定,客戶端不得解釋。客戶端必須首先讀取v1 回覆索引檔案,並追蹤對所需回應物件名稱的參考。

回覆檔案(包括索引檔案)永遠不會被具有相同名稱但不同內容的檔案取代。這允許客戶端與可能產生新回覆的正在運行的 CMake 同時讀取檔案。但是,在產生新的回覆後,CMake 將嘗試移除先前運行中它沒有剛寫入的回覆檔案。如果客戶端嘗試讀取索引參考的回覆檔案,但發現檔案遺失,則表示並行的 CMake 已產生新的回覆。客戶端可以簡單地重新開始,讀取新的回覆索引檔案。

物件種類

CMake 基於檔案的 API 使用以下 JSON 物件種類報告關於建置系統的語義資訊。每種物件種類都使用具有主要和次要組件的語義版本控制獨立地進行版本控制。每種物件種類都具有以下格式

The kind member is a string specifying the object kind name. The version member is a JSON object with major and minor members specifying integer components of the object kind's version. Additional top-level members are specific to each object kind.

{
  "kind": "codemodel",
  "version": { "major": 2, "minor": 8 },
  "paths": {
    "source": "/path/to/top-level-source-dir",
    "build": "/path/to/top-level-build-dir"
  },
  "configurations": [
    {
      "name": "Debug",
      "directories": [
        {
          "source": ".",
          "build": ".",
          "childIndexes": [ 1 ],
          "projectIndex": 0,
          "targetIndexes": [ 0 ],
          "hasInstallRule": true,
          "minimumCMakeVersion": {
            "string": "3.14"
          },
          "jsonFile": "<file>"
        },
        {
          "source": "sub",
          "build": "sub",
          "parentIndex": 0,
          "projectIndex": 0,
          "targetIndexes": [ 1 ],
          "minimumCMakeVersion": {
            "string": "3.14"
          },
          "jsonFile": "<file>"
        }
      ],
      "projects": [
        {
          "name": "MyProject",
          "directoryIndexes": [ 0, 1 ],
          "targetIndexes": [ 0, 1 ]
        }
      ],
      "targets": [
        {
          "name": "MyExecutable",
          "directoryIndex": 0,
          "projectIndex": 0,
          "jsonFile": "<file>"
        },
        {
          "name": "MyLibrary",
          "directoryIndex": 1,
          "projectIndex": 0,
          "jsonFile": "<file>"
        }
      ]
    }
  ]
}

物件種類 "codemodel"

一個布林值,指示版本是否是從具有本地修改的版本控制原始碼樹建置的。

The codemodel object kind describes the build system structure as modeled by CMake.

There is only one codemodel object major version, version 2. Version 1 does not exist to avoid confusion with that from cmake-server(7) mode.

"codemodel" 版本 2

codemodel object version 2 is a JSON object

The members specific to codemodel objects are

configuraitons

A JSON array of entries corresponding to available build configurations. On single-configuration generators there is one entry for the value of the CMAKE_BUILD_TYPE variable. For multi-configuration generators there is an entry for each configuration listed in the CMAKE_CONFIGURATION_TYPES variable. Each entry is a JSON object containing members

一個布林值,指定產生器是否支援多個輸出組態。

name

A string specifying the name of the configuration, e.g. Debug.

directories

There is only one codemodel object major version, version 2. Version 1 does not exist to avoid confusion with that from cmake-server(7) mode.

A JSON array of entries each corresponding to a build system directory whose source directory contains a CMakeLists.txt file. The first entry corresponds to the top-level directory. Each entry is a JSON object containing members

codemodel object version 2 is a JSON object

sourceFile

A string specifying the path to the source directory, represented with forward slashes. If the directory is inside the top-level source directory then the path is specified relative to that directory (with . for the top-level source directory itself). Otherwise the path is absolute.

buildFile

A string specifying the path to the build directory, represented with forward slashes. If the directory is inside the top-level build directory then the path is specified relative to that directory (with . for the top-level build directory itself). Otherwise the path is absolute.

parentIndex

Optional member that is present when the directory is not top-level. The value is an unsigned integer 0-based index of another entry in the main directories array that corresponds to the parent directory that added this directory as a subdirectory.

childIndexes

Optional member that is present when the directory has subdirectories. The value is a JSON array of entries corresponding to child directories created by the add_subdirectory() or subdirs() command. Each entry is an unsigned integer 0-based index of another entry in the main directories array.

projectIndex

An unsigned integer 0-based index into the main projects array indicating the build system project to which the this directory belongs.

targetIndexes

一個字串,指定版本後綴(如果有的話),例如 g0abc3

Optional member that is present when the directory itself has targets, excluding those belonging to subdirectories. The value is a JSON array of entries corresponding to the targets. Each entry is an unsigned integer 0-based index into the main targets array.

<major>.<minor>[.<patch>[.<tweak>]][<suffix>]

minimumCMakeVersion

Optional member present when a minimum required version of CMake is known for the directory. This is the <min> version given to the most local call to the cmake_minimum_required(VERSION) command in the directory itself or one of its ancestors. The value is a JSON object with one member

string

回覆索引檔案使用具有成員的 JSON 物件來表示對另一個回覆檔案的每個參考

A string specifying the minimum required version in the format

Each component is an unsigned integer and the suffix may be an arbitrary string.

hasInstallRule

Optional member that is present with boolean value true when the directory or one of its subdirectories contains any install() rules, i.e. whether a make install or equivalent rule is available.

directoryFile

一個布林值,指定產生器是否支援多個輸出組態。

A JSON string specifying a path relative to the codemodel file to another JSON file containing a "codemodel" version 2 "directory" object.

A string specifying the path to the source directory, represented with forward slashes. If the directory is inside the top-level source directory then the path is specified relative to that directory (with . for the top-level source directory itself). Otherwise the path is absolute.

This field was added in codemodel version 2.3.

A string specifying the path to the build directory, represented with forward slashes. If the directory is inside the top-level build directory then the path is specified relative to that directory (with . for the top-level build directory itself). Otherwise the path is absolute.

projects

A JSON array of entries corresponding to the top-level project and sub-projects defined in the build system. Each (sub-)project corresponds to a source directory whose CMakeLists.txt file calls the project() command with a project name different from its parent directory. The first entry corresponds to the top-level project.

Each entry is a JSON object containing members

Optional member that is present when the directory has subdirectories. The value is a JSON array of entries corresponding to child directories created by the add_subdirectory() or subdirs() command. Each entry is an unsigned integer 0-based index of another entry in the main directories array.

name

A string specifying the name given to the project() command.

parentIndex

一個布林值,指定產生器是否支援多個輸出組態。

Optional member that is present when the project is not top-level. The value is an unsigned integer 0-based index of another entry in the main projects array that corresponds to the parent project that added this project as a sub-project.

childIndexes

Optional member that is present when the project has sub-projects. The value is a JSON array of entries corresponding to the sub-projects. Each entry is an unsigned integer 0-based index of another entry in the main projects array.

directoryIndexes

A JSON array of entries corresponding to build system directories that are part of the project. The first entry corresponds to the top-level directory of the project. Each entry is an unsigned integer 0-based index into the main directories array.

Optional member that is present when the directory is not top-level. The value is an unsigned integer 0-based index of another entry in the main directories array that corresponds to the parent directory that added this directory as a subdirectory.

targetIndexes

回覆索引檔案使用具有成員的 JSON 物件來表示對另一個回覆檔案的每個參考

Optional member that is present when the project itself has targets, excluding those belonging to sub-projects. The value is a JSON array of entries corresponding to the targets. Each entry is an unsigned integer 0-based index into the main targets array.

targets

A JSON array of entries corresponding to the build system targets. Such targets are created by calls to add_executable(), add_library(), and add_custom_target(), excluding imported targets and interface libraries (which do not generate any build rules). Each entry is a JSON object containing members

一個布林值,指示版本是否是從具有本地修改的版本控制原始碼樹建置的。

The codemodel object kind describes the build system structure as modeled by CMake.

There is only one codemodel object major version, version 2. Version 1 does not exist to avoid confusion with that from cmake-server(7) mode.

A JSON array of entries each corresponding to a build system directory whose source directory contains a CMakeLists.txt file. The first entry corresponds to the top-level directory. Each entry is a JSON object containing members

codemodel object version 2 is a JSON object

sourceFile

name

A string specifying the target name.

id

A string uniquely identifying the target. This matches the id field in the file referenced by jsonFile.

directoryIndex

An unsigned integer 0-based index into the main directories array indicating the build system directory in which the target is defined.

一個布林值,指示版本是否是從具有本地修改的版本控制原始碼樹建置的。

projectIndex

A JSON array of entries corresponding to install() rules. Each entry is a JSON object containing members

component

A string specifying the component selected by the corresponding install() command invocation.

destination

Optional member that is present for specific type values below. The value is a string specifying the install destination path. The path may be absolute or relative to the install prefix.

paths

Optional member that is present for specific type values below. The value is a JSON array of entries corresponding to the paths (files or directories) to be installed. Each entry is one of

目標

一個 install(TARGETS) 呼叫。 destinationpaths 成員會被填充,路徑在頂層建置目錄下表示為相對於它。isOptional 成員可能存在。此類型具有額外的成員 targetIdtargetIndextargetIsImportLibrarytargetInstallNamelink

export

一個 install(EXPORT) 呼叫。 destinationpaths 成員會被填充,路徑在頂層建置目錄下表示為相對於它。paths 條目指的是 CMake 自動產生用於安裝的檔案,其實際值被視為私有實作細節。此類型具有額外的成員 exportNameexportTargets

script

一個 install(SCRIPT) 呼叫。此類型具有額外成員 scriptFile

code

一個 install(CODE) 呼叫。此類型沒有額外的成員。

importedRuntimeArtifacts

一個 install(IMPORTED_RUNTIME_ARTIFACTS) 呼叫。destination 成員會被填充。isOptional 成員可能存在。此類型沒有額外的成員。

runtimeDependencySet

一個 install(RUNTIME_DEPENDENCY_SET) 呼叫或一個 install(TARGETS) 呼叫並帶有 RUNTIME_DEPENDENCIESdestination 成員會被填充。此類型具有額外的成員 runtimeDependencySetNameruntimeDependencySetType

fileSet

一個 install(TARGETS) 呼叫並帶有 FILE_SETdestinationpaths 成員會被填充。isOptional 成員可能存在。此類型具有額外的成員 fileSetNamefileSetTypefileSetDirectoriesfileSetTarget

此類型在 codemodel 版本 2.4 中新增。

isExcludeFromAll

選用成員,當 install() 呼叫時帶有布林值 true,且使用了 EXCLUDE_FROM_ALL 選項時存在。

isForAllComponents

選用成員,當 install(SCRIPT|CODE) 呼叫時帶有布林值 true,且使用了 ALL_COMPONENTS 選項時存在。

isOptional

選用成員,當 install() 呼叫時帶有布林值 true,且使用了 OPTIONAL 選項時存在。當 typefiledirectorytarget 時允許使用。

targetId

選用成員,當 typetarget 時存在。該值是一個字串,唯一識別要安裝的目標。這與主要 "codemodel" 物件的 targets 陣列中的目標的 id 成員匹配。

targetIndex

選用成員,當 typetarget 時存在。該值是一個無號整數,從 0 開始的索引,指向主要 "codemodel" 物件的 targets 陣列中要安裝的目標。

targetIsImportLibrary

選用成員,當 typetarget 且安裝程式用於 Windows DLL 匯入函式庫檔案或 AIX 連結器匯入檔案時存在。如果存在,則其布林值為 true

targetInstallNamelink

選用成員,當 typetarget 且安裝程式對應於可能使用符號連結來實作 VERSIONSOVERSION 目標屬性的目標時存在。該值是一個字串,指示安裝程式應如何處理符號連結:skip 表示安裝程式應跳過符號連結,僅安裝真實檔案,而 only 表示安裝程式應僅安裝符號連結,而不安裝真實檔案。在所有情況下,paths 成員列出實際安裝的內容。

exportName

選用成員,當 typeexport 時存在。該值是一個字串,指定匯出的名稱。

exportTargets

選用成員,當 typeexport 時存在。該值是一個 JSON 陣列,其中包含與匯出中包含的目標相對應的條目。每個條目都是一個 JSON 物件,包含成員

childIndexes

一個字串,唯一識別目標。這與主要 "codemodel" 物件的 targets 陣列中的目標的 id 成員匹配。

索引

一個無號整數,從 0 開始的索引,指向主要 "codemodel" 物件的 targets 陣列中要安裝的目標。

runtimeDependencySetName

選用成員,當 typeruntimeDependencySet 且安裝程式由 install(RUNTIME_DEPENDENCY_SET) 呼叫建立時存在。該值是一個字串,指定已安裝的執行時期相依性集合的名稱。

runtimeDependencySetType

選用成員,當 typeruntimeDependencySet 時存在。該值是一個字串,具有以下值之一

library

表示此安裝程式安裝的相依性不是 macOS 框架。

framework

表示此安裝程式安裝的相依性是 macOS 框架。

fileSetName

選用成員,當 typefileSet 時存在。該值是一個字串,表示檔案集合的名稱。

此欄位在 codemodel 版本 2.4 中新增。

fileSetType

選用成員,當 typefileSet 時存在。該值是一個字串,表示檔案集合的類型。

此欄位在 codemodel 版本 2.4 中新增。

fileSetDirectories

選用成員,當 typefileSet 時存在。該值是一個字串列表,其中包含檔案集合的基礎目錄(由 HEADER_DIRSHEADER_DIRS_<NAME> 的 genex 評估決定)。

此欄位在 codemodel 版本 2.4 中新增。

fileSetTarget

選用成員,當 typefileSet 時存在。該值是一個 JSON 物件,包含成員

childIndexes

一個字串,唯一識別目標。這與主要 "codemodel" 物件的 targets 陣列中的目標的 id 成員匹配。

索引

一個無號整數,從 0 開始的索引,指向主要 "codemodel" 物件的 targets 陣列中要安裝的目標。

此欄位在 codemodel 版本 2.4 中新增。

scriptFile

選用成員,當 typescript 時存在。該值是一個字串,指定磁碟上腳本檔案的路徑,以正斜線表示。如果檔案位於頂層原始碼目錄中,則路徑是相對於該目錄指定的。否則,路徑是絕對路徑。

backtrace

選用成員,當 CMake 語言回溯追蹤到 install() 或其他新增此安裝程式的命令調用可用時存在。該值是一個無號整數,從 0 開始的索引,指向 backtraceGraph 成員的 nodes 陣列。

backtraceGraph

一個 "codemodel" 版本 2 "回溯追蹤圖",其節點從此 "directory" 物件中其他位置的 backtrace 成員引用。

"codemodel" 版本 2 「目標」物件

codemodel "target" 物件由 "codemodel" 版本 2 物件的 targets 陣列引用。每個 "target" 物件都是一個 JSON 物件,包含成員

一個布林值,指定產生器是否支援多個輸出組態。

一個字串,指定目標的邏輯名稱。

childIndexes

一個字串,唯一識別目標。格式未指定,客戶端不應解讀。

component

一個字串,指定目標的類型。值為 EXECUTABLESTATIC_LIBRARYSHARED_LIBRARYMODULE_LIBRARYOBJECT_LIBRARYINTERFACE_LIBRARYUTILITY 之一。

backtrace

選用成員,當 CMake 語言回溯追蹤到原始碼中建立目標的命令可用時存在。該值是一個無號整數,從 0 開始的索引,指向 backtraceGraph 成員的 nodes 陣列。

folder

選用成員,當設定了 FOLDER 目標屬性時存在。該值是一個 JSON 物件,包含一個成員

一個布林值,指定產生器是否支援多個輸出組態。

一個字串,指定目標資料夾的名稱。

一個布林值,指示版本是否是從具有本地修改的版本控制原始碼樹建置的。

The codemodel object kind describes the build system structure as modeled by CMake.

There is only one codemodel object major version, version 2. Version 1 does not exist to avoid confusion with that from cmake-server(7) mode.

一個字串,指定目標原始碼目錄的路徑,以正斜線表示。如果目錄位於頂層原始碼目錄中,則路徑是相對於該目錄指定的(頂層原始碼目錄本身使用 .)。否則,路徑是絕對路徑。

codemodel object version 2 is a JSON object

一個字串,指定目標建置目錄的路徑,以正斜線表示。如果目錄位於頂層建置目錄中,則路徑是相對於該目錄指定的(頂層建置目錄本身使用 .)。否則,路徑是絕對路徑。

nameOnDisk

可執行檔和函式庫目標的選用成員,這些目標連結或封存到單個主要產物中。該值是一個字串,指定該產物在磁碟上的檔案名稱。

artifacts

可執行檔和函式庫目標的選用成員,這些目標產生磁碟上的產物,供相依項使用。該值是一個 JSON 陣列,其中包含與產物相對應的條目。每個條目都是一個 JSON 物件,包含一個成員

path

一個字串,指定磁碟上檔案的路徑,以正斜線表示。如果檔案位於頂層建置目錄中,則路徑是相對於該目錄指定的。否則,路徑是絕對路徑。

isGeneratorProvided

選用成員,如果目標是由 CMake 的建置系統產生器而不是原始碼中的命令提供,則布林值為 true 時存在。

install

選用成員,當目標具有 install() 規則時存在。該值是一個 JSON 物件,包含成員

prefix

一個 JSON 物件,指定安裝前綴。它有一個成員

path

一個字串,指定 CMAKE_INSTALL_PREFIX 的值。

destinations

一個 JSON 陣列,其中包含指定安裝目的地路徑的條目。每個條目都是一個 JSON 物件,包含成員

path

一個字串,指定安裝目的地路徑。路徑可以是絕對路徑,也可以是相對於安裝前綴的路徑。

backtrace

選用成員,當 CMake 語言回溯追蹤到指定此目的地的 install() 命令調用可用時存在。該值是一個無號整數,從 0 開始的索引,指向 backtraceGraph 成員的 nodes 陣列。

launchers

可執行檔目標的選用成員,這些目標具有專案指定的至少一個啟動器。該值是一個 JSON 陣列,其中包含與指定的啟動器相對應的條目。每個條目都是一個 JSON 物件,包含成員

command

一個字串,指定磁碟上啟動器的路徑,以正斜線表示。如果檔案位於頂層原始碼目錄中,則路徑是相對於該目錄指定的。

arguments

選用成員,當啟動器命令具有在要啟動的可執行檔之前的引數時存在。該值是一個字串陣列,表示引數。

component

一個字串,指定啟動器的類型。值為以下之一

emulator

跨編譯時目標平台的模擬器。請參閱 CROSSCOMPILING_EMULATOR 目標屬性。

test

用於執行測試的啟動程式。請參閱 TEST_LAUNCHER 目標屬性。

此欄位在 codemodel 版本 2.7 中新增。

link

可執行檔和共享函式庫目標的選用成員,這些目標連結到執行時期二進制檔案中。該值是一個 JSON 物件,其中包含描述連結步驟的成員

language

一個字串,指定用於調用連結器的工具鏈的語言(例如 CCXXFortran)。

commandFragments

選用成員,當連結命令列調用的片段可用時存在。該值是一個 JSON 陣列,其中包含指定有序片段的條目。每個條目都是一個 JSON 物件,包含成員

fragment

一個字串,指定連結命令列調用的片段。該值以建置系統的原生 shell 格式編碼。

role

一個字串,指定片段內容的角色

  • flags:連結旗標。

  • libraries:連結函式庫檔案路徑或旗標。

  • libraryPath:函式庫搜尋路徑旗標。

  • frameworkPath:macOS framework 搜尋路徑旗標。

lto

選用成員,當啟用連結時間最佳化(又稱跨程序最佳化或連結時間程式碼生成)時,布林值為 true 時存在。

sysroot

選用成員,當定義了 CMAKE_SYSROOT_LINKCMAKE_SYSROOT 變數時存在。該值是一個 JSON 物件,包含一個成員

path

一個字串,指定 sysroot 的絕對路徑,以正斜線表示。

archive

靜態函式庫目標的選用成員。該值是一個 JSON 物件,其中包含描述封存步驟的成員

commandFragments

選用成員,當封存器命令列調用的片段可用時存在。該值是一個 JSON 陣列,其中包含指定片段的條目。每個條目都是一個 JSON 物件,包含成員

fragment

一個字串,指定封存器命令列調用的片段。該值以建置系統的原生 shell 格式編碼。

role

一個字串,指定片段內容的角色

  • flags:封存器旗標。

lto

選用成員,當啟用連結時間最佳化(又稱跨程序最佳化或連結時間程式碼生成)時,布林值為 true 時存在。

debugger

選用成員,當目標設定了以下欄位之一時存在。該值是一個 JSON 物件,其中包含與設定的除錯器特定值相對應的條目。

此欄位在 codemodel 版本 2.8 中新增。

workingDirectory

選用成員,當設定了 DEBUGGER_WORKING_DIRECTORY 目標屬性時存在。當設定了 VS_DEBUGGER_WORKING_DIRECTORY 時,該成員也將在 Visual Studio Generator 情境中存在。

此欄位在 codemodel 版本 2.8 中新增。

dependencies

選用成員,當目標相依於其他目標時存在。該值是一個 JSON 陣列,其中包含與相依性相對應的條目。每個條目都是一個 JSON 物件,包含成員

childIndexes

一個字串,唯一識別此目標所相依的目標。這與另一個目標的主要 id 成員匹配。

backtrace

選用成員,當 CMake 語言回溯追蹤到建立此相依性的 add_dependencies()target_link_libraries() 或其他命令調用可用時存在。該值是一個無號整數,從 0 開始的索引,指向 backtraceGraph 成員的 nodes 陣列。

fileSets

一個 JSON 陣列,其中包含與目標的檔案集合相對應的條目。每個條目都是一個 JSON 物件,包含成員

一個布林值,指定產生器是否支援多個輸出組態。

一個字串,指定檔案集合的名稱。

component

一個字串,指定檔案集合的類型。請參閱 target_sources() 支援的檔案集合類型。

visibility

一個字串,指定檔案集合的可見性;PUBLICPRIVATEINTERFACE 之一。

baseDirectories

一個字串陣列,每個字串指定包含檔案集合中來源的基礎目錄。如果目錄位於頂層原始碼目錄中,則路徑是相對於該目錄指定的。否則,路徑是絕對路徑。

此欄位在 codemodel 版本 2.5 中新增。

sources

一個 JSON 陣列,其中包含與目標的原始碼檔案相對應的條目。每個條目都是一個 JSON 物件,包含成員

path

一個字串,指定磁碟上原始碼檔案的路徑,以正斜線表示。如果檔案位於頂層原始碼目錄中,則路徑是相對於該目錄指定的。否則,路徑是絕對路徑。

compileGroupIndex

選用成員,當原始碼被編譯時存在。該值是一個無號整數,從 0 開始的索引,指向 compileGroups 陣列。

sourceGroupIndex

選用成員,當原始碼透過 source_group() 命令或預設成為來源群組的一部分時存在。該值是一個無號整數,從 0 開始的索引,指向 sourceGroups 陣列。

isGenerated

選用成員,如果原始碼為 GENERATED,則布林值為 true 時存在。

fileSetIndex

選用成員,當原始碼為檔案集合的一部分時存在。該值是一個無號整數,從 0 開始的索引,指向 fileSets 陣列。

此欄位在 codemodel 版本 2.5 中新增。

backtrace

選用成員,當 CMake 語言回溯追蹤到 target_sources()add_executable()add_library()add_custom_target() 或其他將此原始碼新增至目標的命令調用可用時存在。該值是一個無號整數,從 0 開始的索引,指向 backtraceGraph 成員的 nodes 陣列。

sourceGroups

選用成員,當來源透過 source_group() 命令或預設分組在一起時存在。該值是一個 JSON 陣列,其中包含與群組相對應的條目。每個條目都是一個 JSON 物件,包含成員

一個布林值,指定產生器是否支援多個輸出組態。

一個字串,指定來源群組的名稱。

sourceIndexes

一個 JSON 陣列,列出屬於該群組的來源。每個條目都是一個無號整數,從 0 開始的索引,指向目標的主要 sources 陣列。

compileGroups

選用成員,當目標具有編譯的來源時存在。該值是一個 JSON 陣列,其中包含與所有使用相同設定編譯的來源群組相對應的條目。每個條目都是一個 JSON 物件,包含成員

sourceIndexes

一個 JSON 陣列,列出屬於該群組的來源。每個條目都是一個無號整數,從 0 開始的索引,指向目標的主要 sources 陣列。

language

一個字串,指定用於編譯原始碼檔案的工具鏈的語言(例如 CCXXFortran)。

languageStandard

選用成員,當語言標準被明確設定(例如透過 CXX_STANDARD)或由編譯功能隱含設定時存在。每個條目都是一個 JSON 物件,包含兩個成員

backtraces

可選成員,當 CMake 語言回溯追蹤到 <LANG>_STANDARD 設定可用時存在。如果語言標準是由編譯特性隱含設定的,則這些編譯特性會被用作回溯追蹤。多個編譯特性可能需要相同的語言標準,因此可能存在多個回溯追蹤。該值是一個 JSON 陣列,每個條目都是一個無符號整數,從 0 開始索引到 backtraceGraph 成員的 nodes 陣列中。

standard

表示語言標準的字串。

此欄位在 codemodel 版本 2.2 中新增。

compileCommandFragments

可選成員,當編譯器命令列調用片段可用時存在。該值是一個 JSON 陣列,其中包含指定順序片段的條目。每個條目都是一個 JSON 物件,帶有一個成員

fragment

一個字串,指定編譯器命令列調用的片段。該值以建置系統的原生 shell 格式編碼。

includes

可選成員,當存在包含目錄時存在。該值是一個 JSON 陣列,每個目錄都有一個條目。每個條目都是一個 JSON 物件,帶有成員

path

一個字串,指定包含目錄的路徑,以正斜線表示。

isSystem

可選成員,當包含目錄被標記為系統包含目錄時,其布林值為 true 時存在。

backtrace

可選成員,當 CMake 語言回溯追蹤到 target_include_directories() 或其他新增此包含目錄的命令調用可用時存在。該值是一個無符號整數,從 0 開始索引到 backtraceGraph 成員的 nodes 陣列中。

frameworks

可選成員,在 Apple 平台上,當存在框架時存在。該值是一個 JSON 陣列,每個目錄都有一個條目。每個條目都是一個 JSON 物件,帶有成員

path

一個字串,指定框架目錄的路徑,以正斜線表示。

isSystem

可選成員,當框架被標記為系統框架時,其布林值為 true 時存在。

backtrace

可選成員,當 CMake 語言回溯追蹤到 target_link_libraries() 或其他新增此框架的命令調用可用時存在。該值是一個無符號整數,從 0 開始索引到 backtraceGraph 成員的 nodes 陣列中。

此欄位在 codemodel 版本 2.6 中新增。

precompileHeaders

可選成員,當 target_precompile_headers() 或其他命令調用設定目標上的 PRECOMPILE_HEADERS 時存在。該值是一個 JSON 陣列,每個標頭都有一個條目。每個條目都是一個 JSON 物件,帶有成員

header

預編譯標頭檔案的完整路徑。

backtrace

可選成員,當 CMake 語言回溯追蹤到 target_precompile_headers() 或其他新增此預編譯標頭的命令調用可用時存在。該值是一個無符號整數,從 0 開始索引到 backtraceGraph 成員的 nodes 陣列中。

此欄位在 codemodel 版本 2.1 中新增。

defines

可選成員,當存在預處理器定義時存在。該值是一個 JSON 陣列,每個定義都有一個條目。每個條目都是一個 JSON 物件,帶有成員

define

一個字串,以 <name>[=<value>] 格式指定預處理器定義,例如 DEFDEF=1

backtrace

可選成員,當 CMake 語言回溯追蹤到 target_compile_definitions() 或其他新增此預處理器定義的命令調用可用時存在。該值是一個無符號整數,從 0 開始索引到 backtraceGraph 成員的 nodes 陣列中。

sysroot

可選成員,當定義了 CMAKE_SYSROOT_COMPILECMAKE_SYSROOT 變數時存在。該值是一個 JSON 物件,帶有一個成員

path

一個字串,指定 sysroot 的絕對路徑,以正斜線表示。

backtraceGraph

一個 "codemodel" 版本 2 "回溯追蹤圖",其節點從此 "target" 物件中其他地方的 backtrace 成員引用。

"codemodel" 版本 2 "回溯追蹤圖"

"codemodel" 版本 2 "目錄" 物件"codemodel" 版本 2 "目標" 物件backtraceGraph 成員是一個 JSON 物件,描述回溯追蹤的圖。其節點從包含物件中其他地方的 backtrace 成員引用。回溯追蹤圖物件成員為

nodes

一個 JSON 陣列,列出回溯追蹤圖中的節點。每個條目都是一個 JSON 物件,帶有成員

destination

一個無符號整數,從 0 開始索引到回溯追蹤 files 陣列中。

line

一個可選成員,當節點表示檔案中的一行時存在。該值是一個無符號整數,從 1 開始的行號。

command

一個可選成員,當節點表示檔案中的命令調用時存在。該值是一個無符號整數,從 0 開始索引到回溯追蹤 commands 陣列中。

parent

一個可選成員,當節點不是呼叫堆疊的底部時存在。該值是回溯追蹤 nodes 陣列中另一個條目的無符號整數,從 0 開始索引。

commands

一個 JSON 陣列,列出回溯追蹤節點引用的命令名稱。每個條目都是一個字串,指定命令名稱。

files

一個 JSON 陣列,列出回溯追蹤節點引用的 CMake 語言檔案。每個條目都是一個字串,指定檔案的路徑,以正斜線表示。如果檔案位於頂層原始碼目錄中,則路徑相對於該目錄指定。否則,路徑是絕對路徑。

物件種類 "configureLog"

在版本 3.26 中新增。

configureLog 物件種類描述 cmake-configure-log(7) 檔案的位置和內容。

只有一個 configureLog 物件主要版本,版本 1。

"configureLog" 版本 1

configureLog 物件版本 1 是一個 JSON 物件

{
  "kind": "configureLog",
  "version": { "major": 1, "minor": 0 },
  "path": "/path/to/top-level-build-dir/CMakeFiles/CMakeConfigureLog.yaml",
  "eventKindNames": [ "try_compile-v1", "try_run-v1" ]
}

特定於 configureLog 物件的成員是

path

一個字串,指定設定日誌檔案的路徑。客戶端必須從此路徑讀取日誌檔案,這可能與 cmake-configure-log(7) 記錄的路徑不同。如果沒有記錄任何事件,則日誌檔案可能不存在。

eventKindNames

一個 JSON 陣列,其條目都是 JSON 字串,命名 cmake-configure-log(7) 版本化的事件種類之一。每個設定日誌事件種類最多列出一個版本。雖然設定日誌可能包含其他(版本化的)事件種類,但客戶端必須忽略此欄位中未列出的種類。

物件種類 "cache"

cache 物件種類列出快取條目。這些是儲存在建置樹的持久快取 (CMakeCache.txt) 中的 變數

只有一個 cache 物件主要版本,版本 2。版本 1 不存在,以避免與 cmake-server(7) 模式中的版本混淆。

"cache" 版本 2

cache 物件版本 2 是一個 JSON 物件

{
  "kind": "cache",
  "version": { "major": 2, "minor": 0 },
  "entries": [
    {
      "name": "BUILD_SHARED_LIBS",
      "value": "ON",
      "type": "BOOL",
      "properties": [
        {
          "name": "HELPSTRING",
          "value": "Build shared libraries"
        }
      ]
    },
    {
      "name": "CMAKE_GENERATOR",
      "value": "Unix Makefiles",
      "type": "INTERNAL",
      "properties": [
        {
          "name": "HELPSTRING",
          "value": "Name of generator."
        }
      ]
    }
  ]
}

特定於 cache 物件的成員是

entries

一個 JSON 陣列,其條目都是 JSON 物件,指定一個快取條目。每個條目的成員是

一個布林值,指定產生器是否支援多個輸出組態。

一個字串,指定條目的名稱。

value

一個字串,指定條目的值。

component

一個字串,指定 cmake-gui(1) 用於選擇編輯 widget 的條目類型。

properties

一個 JSON 陣列,其中包含指定相關聯的 快取條目屬性 的條目。每個條目都是一個 JSON 物件,包含成員

一個布林值,指定產生器是否支援多個輸出組態。

一個字串,指定快取條目屬性的名稱。

value

一個字串,指定快取條目屬性的值。

物件種類 "cmakeFiles"

cmakeFiles 物件種類列出 CMake 在設定和產生建置系統時使用的檔案。這些檔案包括 CMakeLists.txt 檔案以及包含的 .cmake 檔案。

只有一個 cmakeFiles 物件主要版本,版本 1。

"cmakeFiles" 版本 1

cmakeFiles 物件版本 1 是一個 JSON 物件

{
  "kind": "cmakeFiles",
  "version": { "major": 1, "minor": 1 },
  "paths": {
    "build": "/path/to/top-level-build-dir",
    "source": "/path/to/top-level-source-dir"
  },
  "inputs": [
    {
      "path": "CMakeLists.txt"
    },
    {
      "isGenerated": true,
      "path": "/path/to/top-level-build-dir/.../CMakeSystem.cmake"
    },
    {
      "isExternal": true,
      "path": "/path/to/external/third-party/module.cmake"
    },
    {
      "isCMake": true,
      "isExternal": true,
      "path": "/path/to/cmake/Modules/CMakeGenericSystem.cmake"
    }
  ],
  "globsDependent": [
    {
      "expression": "src/*.cxx",
      "recurse": true,
      "files": [
        "src/foo.cxx",
        "src/bar.cxx"
      ]
    }
  ]
}

特定於 cmakeFiles 物件的成員是

一個布林值,指示版本是否是從具有本地修改的版本控制原始碼樹建置的。

The codemodel object kind describes the build system structure as modeled by CMake.

There is only one codemodel object major version, version 2. Version 1 does not exist to avoid confusion with that from cmake-server(7) mode.

"codemodel" 版本 2

codemodel object version 2 is a JSON object

The members specific to codemodel objects are

inputs

一個 JSON 陣列,其條目都是 JSON 物件,指定 CMake 在設定和產生建置系統時使用的輸入檔案。每個條目的成員是

path

一個字串,指定 CMake 輸入檔案的路徑,以正斜線表示。如果檔案位於頂層原始碼目錄中,則路徑相對於該目錄指定。否則,路徑是絕對路徑。

isGenerated

可選成員,當路徑指定一個位於頂層建置目錄下的檔案,並且建置是 out-of-source 建置時,其布林值為 true 時存在。此成員在 in-source 建置中不可用。

isExternal

可選成員,當路徑指定一個不在頂層原始碼或建置目錄下的檔案時,其布林值為 true 時存在。

isCMake

可選成員,當路徑指定 CMake 安裝中的檔案時,其布林值為 true 時存在。

globsDependent

可選成員,當專案呼叫帶有 CONFIGURE_DEPENDS 選項的 file(GLOB)file(GLOB_RECURSE) 時存在。該值是一個 JSON 物件陣列,每個物件指定一個 glob 運算式及其匹配的路徑列表。如果 glob 運算式不再匹配相同的路徑列表,則 CMake 認為建置系統已過時。

此欄位在 cmakeFiles 版本 1.1 中新增。

每個條目的成員是

expression

一個字串,指定 glob 運算式。

recurse

可選成員,當條目對應於 file(GLOB_RECURSE) 呼叫時,其布林值為 true 時存在。否則,條目對應於 file(GLOB) 呼叫。

listDirectories

可選成員,當呼叫 file(GLOB) 時沒有 LIST_DIRECTORIES false 或呼叫 file(GLOB_RECURSE) 時帶有 LIST_DIRECTORIES true 時,其布林值為 true 時存在。

followSymlinks

可選成員,當呼叫 file(GLOB) 時帶有 FOLLOW_SYMLINKS 選項時,其布林值為 true 時存在。

relative

可選成員,如果呼叫 file(GLOB) 時帶有 RELATIVE <path> 選項則存在。該值是一個字串,包含給定的 <path>

一個布林值,指示版本是否是從具有本地修改的版本控制原始碼樹建置的。

一個 JSON 字串陣列,指定呼叫 file(GLOB)file(GLOB_RECURSE) 匹配的路徑。

物件種類 "toolchains"

toolchains 物件種類列出建置期間使用的工具鏈的屬性。這些屬性包括語言、編譯器路徑、ID 和版本。

只有一個 toolchains 物件主要版本,版本 1。

"toolchains" 版本 1

toolchains 物件版本 1 是一個 JSON 物件

{
  "kind": "toolchains",
  "version": { "major": 1, "minor": 0 },
  "toolchains": [
    {
      "language": "C",
      "compiler": {
        "path": "/usr/bin/cc",
        "id": "GNU",
        "version": "9.3.0",
        "implicit": {
          "includeDirectories": [
            "/usr/lib/gcc/x86_64-linux-gnu/9/include",
            "/usr/local/include",
            "/usr/include/x86_64-linux-gnu",
            "/usr/include"
          ],
          "linkDirectories": [
            "/usr/lib/gcc/x86_64-linux-gnu/9",
            "/usr/lib/x86_64-linux-gnu",
            "/usr/lib",
            "/lib/x86_64-linux-gnu",
            "/lib"
          ],
          "linkFrameworkDirectories": [],
          "linkLibraries": [ "gcc", "gcc_s", "c", "gcc", "gcc_s" ]
        }
      },
      "sourceFileExtensions": [ "c", "m" ]
    },
    {
      "language": "CXX",
      "compiler": {
        "path": "/usr/bin/c++",
        "id": "GNU",
        "version": "9.3.0",
        "implicit": {
          "includeDirectories": [
            "/usr/include/c++/9",
            "/usr/include/x86_64-linux-gnu/c++/9",
            "/usr/include/c++/9/backward",
            "/usr/lib/gcc/x86_64-linux-gnu/9/include",
            "/usr/local/include",
            "/usr/include/x86_64-linux-gnu",
            "/usr/include"
          ],
          "linkDirectories": [
            "/usr/lib/gcc/x86_64-linux-gnu/9",
            "/usr/lib/x86_64-linux-gnu",
            "/usr/lib",
            "/lib/x86_64-linux-gnu",
            "/lib"
          ],
          "linkFrameworkDirectories": [],
          "linkLibraries": [
            "stdc++", "m", "gcc_s", "gcc", "c", "gcc_s", "gcc"
          ]
        }
      },
      "sourceFileExtensions": [
        "C", "M", "c++", "cc", "cpp", "cxx", "mm", "CPP"
      ]
    }
  ]
}

特定於 toolchains 物件的成員是

toolchains

一個 JSON 陣列,其條目都是 JSON 物件,指定與特定語言相關聯的工具鏈。每個條目的成員是

language

一個 JSON 字串,指定工具鏈語言,例如 C 或 CXX。語言名稱與可以傳遞給 project() 命令的語言名稱相同。由於 CMake 每個語言僅支援單個工具鏈,因此此欄位可以用作鍵。

compiler

The codemodel object kind describes the build system structure as modeled by CMake.

path

可選成員,當為當前語言定義了 CMAKE_<LANG>_COMPILER 變數時存在。其值是一個 JSON 字串,包含編譯器的路徑。

childIndexes

可選成員,當為當前語言定義了 CMAKE_<LANG>_COMPILER_ID 變數時存在。其值是一個 JSON 字串,包含編譯器的 ID(GNU、MSVC 等)。

version

可選成員,當為當前語言定義了 CMAKE_<LANG>_COMPILER_VERSION 變數時存在。其值是一個 JSON 字串,包含編譯器的版本。

目標

可選成員,當為當前語言定義了 CMAKE_<LANG>_COMPILER_TARGET 變數時存在。其值是一個 JSON 字串,包含編譯器的交叉編譯目標。

implicit

The codemodel object kind describes the build system structure as modeled by CMake.

includeDirectories

可選成員,當為當前語言定義了 CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES 變數時存在。其值是一個 JSON 字串陣列,其中每個字串包含編譯器的隱含包含目錄的路徑。

linkDirectories

可選成員,當為當前語言定義了 CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES 變數時存在。其值是一個 JSON 字串陣列,其中每個字串包含編譯器的隱含連結目錄的路徑。

linkFrameworkDirectories

可選成員,當為當前語言定義了 CMAKE_<LANG>_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES 變數時存在。其值是一個 JSON 字串陣列,其中每個字串包含編譯器的隱含連結框架目錄的路徑。

linkLibraries

可選成員,當為當前語言定義了 CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES 變數時存在。其值是一個 JSON 字串陣列,其中每個字串包含編譯器的隱含連結程式庫的路徑。

sourceFileExtensions

可選成員,當為當前語言定義了 CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS 變數時存在。其值是一個 JSON 字串陣列,其中每個字串包含語言的檔案副檔名(不帶前導點)。