CMAKE-FILE-API(7)
cmake-file-api ๐ โจ
okay so bestie, welcome to cmake-file-api(7) โ the official CMake File-Based API manual, and honestly it's giving "backstage pass to the build system" energy ๐
๐ธ NAME ๐ธ
cmake-file-api โ the CMake File-Based API ๐ฆ
โจ INTRODUCTION โจ
So CMake ships with a file-based API that clients can use to get semantic info about the buildsystems CMake generates. Here's the whole vibe: a client writes query files into a specific spot in a build tree, asking for zero or more Object Kinds. Then, when CMake generates the buildsystem in that build tree, it reads those query files and writes back reply files for the client to read. Receipts!! ๐ฌ
The file-based API lives in a <build>/.cmake/api/ directory at the top of a build tree. And it's versioned, specifically so the layout of files inside the API directory can change down the line. Important distinction, bestie: this API file layout versioning is orthogonal to the versioning of the Object Kinds used in replies โ two separate things, don't mix them up ๐. This version of CMake supports exactly one API version: API v1.
Added in version 3.27: Projects may also submit queries for the current run using the cmake_file_api() command. cute!!
๐ API V1 ๐
API v1 lives in the <build>/.cmake/api/v1/ directory. It's got these subdirectories:
query/โ holds query files written by clients. These may be v1 Shared Stateless Query Files, v1 Client Stateless Query Files, or v1 Client Stateful Query Files. three flavors, all iconic ๐reply/โ holds reply files written by CMake when it runs to generate a build system. Clients may read reply files only when they're referenced by a reply index:<cyan>index-*.json</cyan>โ a v1 Reply Index File written when CMake generates a build system.<cyan>error-*.json</cyan>โ Added in version 4.1. A v1 Reply Error Index written when CMake fails to generate a build system due to an error. ๐ญ
Clients may look for and read a reply index at any time, fr. Clients may optionally create the reply/ directory at any time and monitor it for the appearance of a new reply index. But heads up: CMake owns all reply files. Clients must never remove them โ not even one, not even a little ๐
Added in version 3.31: Users can add query files toapi/v1/queryinside theCMAKE_CONFIG_DIRenvironment variable to create user-wide queries for all CMake projects. slay.
๐ v1 Shared Stateless Query Files ๐
Shared stateless query files let clients share requests for major versions of the Object Kinds and get back all requested versions that the running CMake recognizes. teamwork!!
Clients may create shared requests by creating empty files in the v1/query/ directory. The form is:
<build>/.cmake/api/v1/query/<kind>-v<major>
where <kind> is one of the Object Kinds, -v is literal, and <major> is the major version number.
Files of this form are stateless shared queries not owned by any specific client. Once created they should not be removed without external client coordination or human intervention. so like, don't just yeet them ok ๐ซถ
๐ฆ v1 Client Stateless Query Files ๐ฆ
Client stateless query files let clients create owned requests for major versions of the Object Kinds and get all requested versions recognized by the CMake that runs.
Clients may create owned requests by creating empty files in client-specific query subdirectories. The form is:
<build>/.cmake/api/v1/query/client-<client>/<kind>-v<major>
where client- is literal, <client> is a string uniquely identifying the client, <kind> is one of the Object Kinds, -v is literal, and <major> is the major version number. Each client must choose a unique <client> identifier via its own means โ no copying someone else's name bestie, that's not the vibe ๐
Files of this form are stateless queries owned by the client <client>. The owning client may remove them at any time. it's yours, do what you want ๐
๐ v1 Client Stateful Query Files ๐
Stateful query files let clients request a list of versions of each of the Object Kinds and get back only the most recent version recognized by the CMake that runs. one answer, freshest one, periodt.
Clients may create owned stateful queries by creating query.json files in client-specific query subdirectories. The form is:
<build>/.cmake/api/v1/query/client-<client>/query.json
where client- is literal, <client> is a string uniquely identifying the client, and query.json is literal. Each client must choose a unique <client> identifier via its own means.
query.json files are stateful queries owned by the client <client>. The owning client may update or remove them at any time. And when a given client installation gets updated, it may then update the stateful query it writes to build trees to request newer object versions. This can be used to avoid asking CMake to generate multiple object versions unnecessarily โ efficiency queen behavior ๐
Added in version 4.1: The query.json file is described in machine-readable form by this JSON schema.
A query.json file must contain a JSON object:
{
"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": {}
}
The members are:
requestsโ a JSON array containing zero or more requests. Each request is a JSON object with members:kindโ specifies one of the Object Kinds to be included in the reply.versionโ indicates the version(s) of the object kind that the client understands. Versions have major and minor components following semantic version conventions. The value must be- a JSON integer specifying a (non-negative) major version number, or
- a JSON object containing
majorand (optionally)minormembers specifying non-negative integer version components, or - a JSON array whose elements are each one of the above.
clientโ optional member reserved for use by the client. This value is preserved in the reply written for the client in the v1 Reply Index File but is otherwise ignored. Clients may use this to pass custom information with a request through to its reply. cute little passthrough ๐
For each requested object kind CMake will choose the first version that it recognizes for that kind among those listed in the request. The response will use the selected major version with the highest minor version known to the running CMake for that major version. Therefore clients should list all supported major versions in preferred order along with the minimal minor version required for each major version. order matters, bestie, read the room ๐
clientโ optional member reserved for use by the client. This value is preserved in the reply written for the client in the v1 Reply Index File but is otherwise ignored. Clients may use this to pass custom information with a query through to its reply.
Other query.json top-level members are reserved for future use. If they're present they are ignored for forward compatibility. future-proofing, we love to see it โจ
โญ v1 Reply Index File โญ
CMake writes an index-*.json file to the v1/reply/ directory when it successfully generates a build system. Clients must read the reply index file first, and may read other v1 Reply Files only by following references. The form of the reply index file name is:
<build>/.cmake/api/v1/reply/index-<unspecified>.json
where index- is literal and <unspecified> is an unspecified name selected by CMake. Whenever a new index file is generated it gets a brand new name and any old one is deleted. During the short time between these steps there may be multiple index files hanging out โ the one with the largest name in lexicographic order is the current index file. iykyk ๐ฅ
Added in version 4.1: The reply index file is described in machine-readable form by this JSON schema.
The reply index file contains a JSON object:
{
"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": {}
}
}
}
}
The members are:
cmakeโ a JSON object containing info about the instance of CMake that generated the reply. It contains members:versionโ a JSON object specifying the version of CMake with members:major,minor,patchโ integer values specifying the major, minor, and patch version components.suffixโ a string specifying the version suffix, if any, e.g.g0abc3.stringโ a string specifying the full version in the format<major>.<minor>.<patch>[-<suffix>].isDirtyโ a boolean indicating whether the version was built from a version controlled source tree with local modifications. ๐
pathsโ a JSON object listing paths to stuff that ships with CMake ๐ซ. It's got members forcmake,ctest, andcpack, and each value is a JSON string holding the absolute path to that tool, written with forward slashes. It also has arootmember: the absolute path to the directory holding CMake resources like theModules/directory (peepCMAKE_ROOT).generatorโ a JSON object describing the CMake generator used for the build ๐ ๏ธ. Members:multiConfigโ a boolean saying whether the generator supports multiple output configurations.nameโ a string with the generator's name.platformโ if the generator supportsCMAKE_GENERATOR_PLATFORM, this is a string with the generator platform name.
objectsโ a JSON array listing all versions of all Object Kinds generated as part of the reply โจ. Each entry in the array is a v1 Reply File Reference.replyโ a JSON object mirroring the content of thequery/directory that CMake loaded to produce the reply ๐ช. Its members look like:<kind>-v<major>โ one of these shows up for each of the v1 Shared Stateless Query Files that CMake recognized as a request for object kind<kind>with major version<major>. The value is either:- a v1 Reply File Reference to the matching reply file for that object kind and version, or
- in a v1 Reply Error Index, a JSON object with a single
errormember holding a string with an error message.
<unknown>โ one of these shows up for each of the v1 Shared Stateless Query Files CMake did not recognize ๐ฌ. The value is a JSON object with a singleerrormember holding a string with an error message saying the query file is unknown.client-<client>โ one of these shows up for each client-owned directory holding v1 Client Stateless Query Files. The value is a JSON object mirroring the content of thequery/client-<client>/directory. Members:<kind>-v<major>โ shows up for each of the v1 Client Stateless Query Files that CMake recognized as a request for object kind<kind>with major version<major>. The value is either:- a v1 Reply File Reference to the matching reply file for that object kind and version, or
- in a v1 Reply Error Index, a JSON object with a single
errormember holding a string with an error message.
<unknown>โ shows up for each of the v1 Client Stateless Query Files CMake did not recognize. The value is a JSON object with a singleerrormember holding a string with an error message saying the query file is unknown.query.jsonโ this one shows up for clients using v1 Client Stateful Query Files ๐ธ. If thequery.jsonfile failed to read or parse as a JSON object, this member is a JSON object with a singleerrormember holding a string with an error message. Otherwise, this member is a JSON object mirroring the content of thequery.jsonfile. Its members:clientโ a copy of thequery.jsonfile'sclientmember, if it exists.requestsโ a copy of thequery.jsonfile'srequestsmember, if it exists.responsesโ if thequery.jsonfile'srequestsmember is missing or invalid, this member is a JSON object with a singleerrormember holding a string with an error message. Otherwise, it's a JSON array with a response for each entry of therequestsarray, in the same order. Each response is either:- a v1 Reply File Reference to the matching reply file for the requested object kind and selected version, or
- a JSON object with a single
errormember holding a string with an error message.
After reading the reply index file, clients may read the other v1 Reply Files it references ๐.
๐ v1 Reply File Reference ๐
The reply index file represents each reference to another reply file using a JSON object with these members:
kindโ a string specifying one of the Object Kinds.versionโ a JSON object with membersmajorandminorspecifying integer version components of the object kind.jsonFileโ a JSON string specifying a path relative to the reply index file, pointing to another JSON file that contains the object.
๐ v1 Reply Error Index ๐
Added in version 4.1.
CMake writes an error-*.json file to the v1/reply/ directory when it fails to generate a build system ๐ญ. This reply error index follows the same naming pattern, syntax, and semantics as a v1 Reply Index File, with these exceptions:
- The
index-prefix gets swapped for anerror-prefix. - When a new error index is generated, old index files are not deleted. If a v1 Reply Index File exists, it indexes replies from the most recent successful run. If multiple
index-*.jsonand/orerror-*.jsonfiles are around, the one with the largest name in lexicographic order โ excluding theindex-orerror-prefix โ is the current index ๐. - Only a subset of Object Kinds get provided:
configureLogโ added in version 4.1.- Index entries for other object kinds contain an error message instead of a v1 Reply File Reference.
๐ฆ v1 Reply Files ๐ฆ
Reply files containing specific Object Kinds are written by CMake. The names of these files are unspecified and must not be interpreted by clients ๐ โโ๏ธ. Clients must first read the v1 Reply Index File and then follow references to the names of the desired response objects.
Reply files (index file included) will never be replaced by files with the same name but different content. That's what lets a client read the files at the same time as a running CMake that might generate a new reply ๐ฅ. BUT โ after generating a new reply, CMake will attempt to remove reply files from previous runs that it didn't just write. So if a client tries to read a reply file referenced by the index and finds it missing, that means a concurrent CMake generated a new reply. No drama: the client can simply start over by reading the new reply index file ๐ซ.
๐ OBJECT KINDS ๐
The CMake file-based API reports semantic information about the build system using the following kinds of JSON objects. Each kind is versioned independently with semantic versioning, using major and minor components. Every kind of object looks like:
{
"kind": "<kind>",
"version": { "major": 1, "minor": 0 },
"...": {}
}
The kind member is a string specifying the object kind name. The version member is a JSON object with major and minor members specifying the integer components of the object kind's version. Any additional top-level members are specific to each object kind.
โญ Object Kind "codemodel" โญ
The codemodel object kind describes the build system structure as modeled by CMake.
There's only one codemodel object major version: version 2๏ธโฃ. Version 1 straight-up does not exist, specifically to avoid confusion with the one from cmake-server(7) mode. iykyk.
Added in version 4.1: The codemodel object kind reply is described in machine-readable form by this JSON schema.
๐ซถ "codemodel" version 2 ๐ซถ
codemodel object version 2 is a JSON object:
{
"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 ],
"abstractTargetIndexes": [ 1 ],
"hasInstallRule": true,
"minimumCMakeVersion": {
"string": "3.14"
},
"jsonFile": "<file>"
},
{
"source": "sub",
"build": "sub",
"parentIndex": 0,
"projectIndex": 0,
"targetIndexes": [ 1 ],
"abstractTargetIndexes": [ 0 ],
"minimumCMakeVersion": {
"string": "3.14"
},
"jsonFile": "<file>"
}
],
"projects": [
{
"name": "MyProject",
"directoryIndexes": [ 0, 1 ],
"targetIndexes": [ 0, 1 ],
"abstractTargetIndexes": [ 0, 1 ],
}
],
"targets": [
{
"name": "MyExecutable",
"directoryIndex": 0,
"projectIndex": 0,
"jsonFile": "<file>"
},
{
"name": "MyLibrary",
"directoryIndex": 1,
"projectIndex": 0,
"jsonFile": "<file>"
}
]
"abstractTargets": [
{
"name": "MyImportedExecutable",
"directoryIndex": 1,
"projectIndex": 0,
"jsonFile": "<file>"
},
{
"name": "MyPureInterfaceLibrary",
"directoryIndex": 0,
"projectIndex": 0,
"jsonFile": "<file>"
}
]
}
]
}
okay so those are the members that are specific to codemodel objects โ like, the ones that only show up here and nowhere else. buckle up bestie, there's a lot ๐
pathsโ a JSON object, and inside it lives:sourceโ a string with the absolute path to the top-level source directory, written with forward slashes (yes, forward โ slashes behaving themselves for once ๐).buildโ a string with the absolute path to the top-level build directory, also with forward slashes.
configurationsโ a JSON array of entries, one for each build configuration that's available. On single-configuration generators there's exactly one entry, and it's the value of theCMAKE_BUILD_TYPEvariable. On multi-configuration generators there's an entry for every configuration listed in theCMAKE_CONFIGURATION_TYPESvariable. each entry is a JSON object with these members:nameโ a string with the configuration's name, likeDebug.directoriesโ a JSON array of entries, each one corresponding to a build system directory whose source directory has aCMakeLists.txtfile in it. the first entry is always the top-level directory, no exceptions ๐ each entry is a JSON object with these members:sourceโ a string with the path to the source directory, forward slashes again. if the directory is inside the top-level source directory, the path is relative to it (with.meaning the top-level source directory itself ๐ซถ). otherwise the path is absolute.buildโ a string with the path to the build directory, forward slashes. if it's inside the top-level build directory, the path is relative to it (and.means the top-level build directory itself). otherwise, absolute.parentIndexโ optional! it only shows up when the directory is not top-level. the value is an unsigned integer, a 0-based index of another entry in the maindirectoriesarray โ the parent directory that added this one as a subdirectory.childIndexesโ optional, present when the directory has subdirectories. the value is a JSON array of entries for the child directories created by theadd_subdirectory()orsubdirs()command. each entry is an unsigned integer 0-based index of another entry in the maindirectoriesarray.projectIndexโ an unsigned integer 0-based index into the mainprojectsarray, telling you which build system project this directory belongs to.targetIndexesโ optional, present when the directory itself has build system targets (and not counting the ones that belong to subdirectories โจ). the value is a JSON array of entries for the build system targets, and each entry is an unsigned integer 0-based index into the maintargetsarray.abstractTargetIndexesโ added in codemodel version 2.9. optional, present when the directory itself has abstract targets, excluding the ones belonging to subdirectories. the value is a JSON array of entries for the abstract targets, each one an unsigned integer 0-based index into the mainabstractTargetsarray ๐ฆminimumCMakeVersionโ optional, present when a minimum required version of CMake is known for the directory. it's the<min>version given to the most local call ofcmake_minimum_required(VERSION)in the directory itself or one of its ancestors. the value is a JSON object with a single member:stringโ a string with the minimum required version, formatted like so:
<major>.<minor>[.<patch>[.<tweak>]][<suffix>]
every component is an unsigned integer, and the suffix can be literally any arbitrary string you want. iconic.
hasInstallRuleโ optional, and when it's there it's a booleantrue. it means the directory or one of its subdirectories contains anyinstall()rules โ i.e. whether amake installor equivalent rule is actually available. so like, yes you can install it, no cap ๐ฅjsonFileโ added in codemodel version 2.3. a JSON string with a path relative to the codemodel file pointing at another JSON file containing a"codemodel"version 2"directory"object. follow the breadcrumb trail ๐
projectsโ a JSON array of entries for the top-level project plus every sub-project defined in the build system. each (sub-)project corresponds to a source directory whoseCMakeLists.txtcalls theproject()command with a project name that's different from its parent directory's. the first entry is the top-level project, always.
each entry is a JSON object with these members:
nameโ a string with the name that was handed to theproject()command.parentIndexโ optional, present when the project is not top-level. it's an unsigned integer 0-based index of another entry in the mainprojectsarray โ the parent project that added this one as a sub-project.childIndexesโ optional, present when the project has sub-projects. a JSON array of entries for those sub-projects, each one an unsigned integer 0-based index of another entry in the mainprojectsarray.directoryIndexesโ a JSON array of entries for the build system directories that are part of the project. the first entry is the project's top-level directory. each entry is an unsigned integer 0-based index into the maindirectoriesarray ๐targetIndexesโ optional, present when the project itself has build system targets, excluding those that belong to sub-projects. a JSON array of entries for the build system targets, each one an unsigned integer 0-based index into the maintargetsarray.abstractTargetIndexesโ added in codemodel version 2.9. optional, present when the project itself has abstract targets, excluding those belonging to sub-projects. a JSON array of entries for the abstract targets, each one an unsigned integer 0-based index into the mainabstractTargetsarray ๐
targetsโ a JSON array where each entry is one of the build system targets, bestie. These are the targets that get created by calls toadd_executable(),add_library(), andadd_custom_target(), but imported targets and interface libraries that don't generate any build rules are not invited to this party. Each entry is a JSON object with these members:nameโ a string with the target's name. iconic.idโ a string that uniquely identifies the target. It matches theidfield in the file thatjsonFilepoints at, so you can always trace it back ๐ซถdirectoryIndexโ an unsigned integer, 0-based index into the maindirectoriesarray, telling you which build system directory the target is defined in.projectIndexโ an unsigned integer, 0-based index into the mainprojectsarray, telling you which build system project the target is defined in.jsonFileโ a JSON string with a path relative to the codemodel file, pointing to another JSON file that holds a"codemodel"version 2"target"object. it's giving breadcrumb trail โจ
abstractTargetsโ added in codemodel version 2.9, so don't come looking for it in older files ๐
A JSON array of entries for targets that are not present in the build system. These are imported targets, or interface libraries created by calling add_executable() or add_library(). For interface libraries specifically, only the ones that aren't part of the build system show up in this array โ interface libraries that do participate in the build system go in the targets array instead. no gatekeeping confusion, iykyk.
Each entry is a JSON object with these members:
nameโ a string with the target's name.idโ a string that uniquely identifies the target. Matches theidfield in the file referenced byjsonFile.directoryIndexโ an unsigned integer, 0-based index into the maindirectoriesarray, indicating the build system directory where the target is defined.projectIndexโ an unsigned integer, 0-based index into the mainprojectsarray, indicating the build system project where the target is defined.jsonFileโ a JSON string with a path relative to the codemodel file, pointing to another JSON file containing a"codemodel"version 2"target"object.
๐ฆ the "codemodel" version 2 "directory" object ๐ฆ
Added in version 4.1: the directory object reply is described in machine-readable form by this JSON schema. slay, documentation that documents itself ๐
A codemodel "directory" object is referenced by a "codemodel" version 2 object's directories array. Each "directory" object is a JSON object with these members:
codemodelVersionโ added in codemodel version 2.9.
This specifies the codemodel version this file is part of. It will match the version field of the codemodel object kind that references this file. It's a JSON object with these members:
majorโ the codemodel major version.minorโ the codemodel minor version.
pathsโ a JSON object with these members:sourceโ a string with the path to the source directory, written with forward slashes. If the directory lives inside the top-level source directory then the path is given relative to that directory (and.means the top-level source directory itself). Otherwise the path is absolute. periodt.buildโ a string with the path to the build directory, also written with forward slashes. If the directory lives inside the top-level build directory then the path is relative to that directory (with.for the top-level build directory itself). Otherwise it's absolute.
installersโ a JSON array of entries corresponding toinstall()rules. Each entry is a JSON object with these members:componentโ a string with the component selected by the correspondinginstall()command invocation.destinationโ an optional member, present for specifictypevalues below. The value is a string with the install destination path. The path may be absolute or relative to the install prefix. your call bestie ๐pathsโ an optional member, present for specifictypevalues below. The value is a JSON array of entries for the paths (files or directories) to be installed. Each entry is one of:- A string with the path from which a file or directory is to be installed. The portion of the path not preceded by a
/also specifies the path (name) to which the file or directory gets installed under thedestination. - A JSON object with these members:
fromโ a string with the path from which a file or directory is to be installed.toโ a string with the path to which the file or directory is to be installed under thedestination.
- A string with the path from which a file or directory is to be installed. The portion of the path not preceded by a
In both cases the paths are written with forward slashes. If the "from" path is inside the top-level directory documented by the corresponding type value, then the path is given relative to that directory. Otherwise the path is absolute. no cap.
typeโ a string with the type of installation rule. The value is one of the following, and some variants hand you extra members too:fileโ aninstall(FILES)orinstall(PROGRAMS)call. Thedestinationandpathsmembers are populated, with paths under the top-level source directory expressed relative to it. TheisOptionalmember may exist. This type has no additional members.directoryโ aninstall(DIRECTORY)call. Thedestinationandpathsmembers are populated, with paths under the top-level source directory expressed relative to it. TheisOptionalmember may exist. This type has no additional members.targetโ aninstall(TARGETS)call. Thedestinationandpathsmembers are populated, with paths under the top-level build directory expressed relative to it. TheisOptionalmember may exist. This type has additional memberstargetId,targetIndex,targetIsImportLibrary, andtargetInstallNamelink.exportโ aninstall(EXPORT)call. Thedestinationandpathsmembers are populated, with paths under the top-level build directory expressed relative to it. Thepathsentries refer to files generated automatically by CMake for installation, and their actual values are considered private implementation details ๐ so don't go building anything on top of them, fr fr. This type has additional membersexportNameandexportTargets.scriptโ aninstall(SCRIPT)call. This type has an additional memberscriptFile.codeโ aninstall(CODE)call. This type has no additional members.importedRuntimeArtifactsโ aninstall(IMPORTED_RUNTIME_ARTIFACTS)call. Thedestinationmember is populated. TheisOptionalmember may exist. This type has no additional members.runtimeDependencySetโ aninstall(RUNTIME_DEPENDENCY_SET)call, or aninstall(TARGETS)call withRUNTIME_DEPENDENCIES. Thedestinationmember is populated. This type has additional membersruntimeDependencySetNameandruntimeDependencySetType.fileSetโ added in codemodel version 2.4.
An install(TARGETS) call with FILE_SET. The destination and paths members are populated. The isOptional member may exist. This type has additional members fileSetName, fileSetType, fileSetDirectories, and fileSetTarget.
cxxModuleBmiโ added in codemodel version 2.5.
An install(TARGETS) call with CXX_MODULES_BMI. The destination member is populated and the isOptional member may exist. This type has an additional member cxxModuleBmiTarget. modules era ๐
isExcludeFromAllโ an optional member, present with boolean valuetruewheninstall()is called with theEXCLUDE_FROM_ALLoption.isForAllComponentsโ an optional member, present with boolean valuetruewheninstall(SCRIPT|CODE)is called with theALL_COMPONENTSoption.isOptionalโ an optional member, present with boolean valuetruewheninstall()is called with theOPTIONALoption. This is allowed whentypeisfile,directory, ortarget.
targetIdโ optional member, only shows up whentypeistarget๐ฏ. Itโs a string that uniquely identifies the target to be installed, and it matches theidmember of that target in the main"codemodel"objectโstargetsarray. bestie, itโs literally the same ID, no cap.targetIndexโ optional member, only whentypeistargetโจ. Value is an unsigned integer0-based index into the main"codemodel"objectโstargetsarray for the target to be installed. index energy.targetIsImportLibraryโ optional member, present whentypeistargetand the installer is for a Windows DLL import library file or for an AIX linker import file ๐ช. If itโs there, it has boolean valuetrue. iconic little flag.targetInstallNamelinkโ optional member, present whentypeistargetand the installer corresponds to a target that may use symbolic links to implement theVERSIONandSOVERSIONtarget properties ๐. Value is a string saying how the installer should handle the symlinks:skipmeans the installer should skip the symlinks and install only the real file, andonlymeans the installer should install only the symlinks and not the real file. In all cases thepathsmember lists what it actually installs. periodt.exportNameโ optional member, present whentypeisexport๐ฆ. The value is a string specifying the name of the export. simple, clean, slay.exportTargetsโ optional member, present whentypeisexport๐. The value is a JSON array of entries corresponding to the targets included in the export. Each entry is a JSON object with members:idโ a string uniquely identifying the target. This matches theidmember of the target in the main"codemodel"objectโstargetsarray.indexโ an unsigned integer0-based index into the main"codemodel"objectโstargetsarray for the target.
runtimeDependencySetNameโ optional member, present whentypeisruntimeDependencySetand the installer was created by aninstall(RUNTIME_DEPENDENCY_SET)call ๐. The value is a string specifying the name of the runtime dependency set that was installed.runtimeDependencySetTypeโ optional member, present whentypeisruntimeDependencySet๐. The value is a string with one of these values:libraryโ indicates that this installer installs dependencies that are not macOS frameworks.frameworkโ indicates that this installer installs dependencies that are macOS frameworks.
fileSetNameโ Added in codemodel version 2.4. Optional member, present whentypeisfileSet๐๏ธ. The value is a string with the name of the file set.fileSetTypeโ Added in codemodel version 2.4. Optional member, present whentypeisfileSet๐ง. The value is a string with the type of the file set.
Changed in codemodel version 2.11: This field additionally accounts for SOURCES file sets. glow-up.
fileSetDirectoriesโ Added in codemodel version 2.4. Optional member, present whentypeisfileSet๐. The value is a list of strings with the file setโs base directories, determined by genex-evaluation ofHEADER_DIRSorHEADER_DIRS_<NAME>. directories but make it genex.fileSetTargetโ Added in codemodel version 2.4. Optional member, present whentypeisfileSet๐ฏ. The value is a JSON object with members:idโ a string uniquely identifying the target. This matches theidmember of the target in the main"codemodel"objectโstargetsarray.indexโ an unsigned integer0-based index into the main"codemodel"objectโstargetsarray for the target.
cxxModuleBmiTargetโ Added in codemodel version 2.5. Optional member, present whentypeiscxxModuleBmi๐งฌ. The value is a JSON object with members:idโ a string uniquely identifying the target. This matches theidmember of the target in the main"codemodel"objectโstargetsarray.indexโ an unsigned integer0-based index into the main"codemodel"objectโstargetsarray for the target.
scriptFileโ optional member, present whentypeisscript๐. The value is a string specifying the path to the script file on disk, represented with forward slashes. If the file is inside the top-level source directory then the path is specified relative to that directory. Otherwise the path is absolute. path vibes, but precise.backtraceโ optional member, present when a CMake language backtrace to theinstall()or other command invocation that added this installer is available ๐งต. The value is an unsigned integer0-based index into thebacktraceGraphmemberโsnodesarray.
backtraceGraph ๐ธ๏ธ
A "codemodel" version 2 "backtrace graph" whose nodes are referenced from backtrace members elsewhere in this "directory" object. iykyk.
๐ฏ "codemodel" version 2 "target" object ๐ฏ
Added in version 4.1: The target object reply is described in machine-readable form by this JSON schema. ๐งพ
A codemodel "target" object is referenced by a "codemodel" version 2 objectโs targets array. Each "target" object is a JSON object with members:
codemodelVersionโ Added in codemodel version 2.9. This specifies the codemodel version this file is part of. It will match theversionfield of the codemodel object kind that references this file. It is a JSON object with the following members:majorโ the codemodel major version.minorโ the codemodel minor version.
nameโ a string specifying the logical name of the target. ๐idโ a string uniquely identifying the target. The format is unspecified and should not be interpreted by clients. no cap, donโt read into it.typeโ a string specifying the type of the target. The value is one ofEXECUTABLE,STATIC_LIBRARY,SHARED_LIBRARY,MODULE_LIBRARY,OBJECT_LIBRARY,INTERFACE_LIBRARY, orUTILITY. ๐ท๏ธimportedโ Added in codemodel version 2.9. Optional member, present with boolean valuetrueif the target is an imported target. ๐ฅlocalโ Added in codemodel version 2.9. Optional member, present with boolean valuetrueif the target is only defined with local scope rather than being a global target. Currently, only imported targets will potentially have this field. ๐abstractโ Added in codemodel version 2.9. Optional member, present with boolean valuetrueif the target is an abstract target. Abstract targets are not part of the build system โ they only exist to describe dependencies or to provide usage requirements to targets that link to them. Examples include imported targets and interface libraries that have no generated sources. Abstract targets cannot be built, so they should not be presented to the user as a buildable target. ๐ซฅ
Abstract targets were not included in codemodel version 2.8 and earlier. important lore.
symbolicโ Added in codemodel version 2.9. Optional member, present with boolean valuetrueif the target isSYMBOLIC. Symbolic targets are created by calls toadd_library(INTERFACE SYMBOLIC), and are also abstract targets that are not part of the build system. ๐ฎ
Symbolic targets were not included in codemodel version 2.8 and earlier. another 2.8 exclusion, bestie.
backtraceโ optional member, present when a CMake language backtrace to the command in the source code that created the target is available. The value is an unsigned integer0-based index into thebacktraceGraphmemberโsnodesarray. ๐งตfolderโ optional member, present when theFOLDERtarget property is set. The value is a JSON object with one member:nameโ a string specifying the name of the target folder. ๐
pathsโ a JSON object containing members:sourceโ a string specifying the path to the targetโs 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.buildโ a string specifying the path to the targetโs 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. ๐ ๏ธ
nameOnDiskโ optional member, present for executable and library targets that are linked or archived into a single primary artifact. The value is a string specifying the file name of that artifact on disk. ๐พartifactsโ optional member, present for executable and library targets that produce artifacts on disk meant for consumption by dependents. The value is a JSON array of entries corresponding to the artifacts. Each entry is a JSON object containing one member: ๐งบ
path
A string that says where the file lives on disk, written with forward slashes (/). โจ If the file is inside the top-level build directory, the path is relative to that directory. Otherwise it's absolute. That's the whole rule, no cap. ๐
isGeneratorProvided
Optional member, present with boolean value true when the target is provided by CMake's build system generator instead of by a command in the source code. Like, nobody wrote this target, the generator just manifested it. ๐ง
install
Optional member, present when the target has an install() rule. Bestie, this one's a whole JSON object with these members:
prefixโ a JSON object describing the installation prefix. It has exactly one member:pathโ a string holding the value ofCMAKE_INSTALL_PREFIX.
destinationsโ a JSON array of entries describing install destination paths. Each entry is a JSON object with:pathโ a string saying the install destination path. It may be absolute, or relative to the install prefix.backtraceโ optional member, present when a CMake language backtrace to theinstall()command invocation that specified this destination is available. The value is an unsigned integer, a 0-based index into thebacktraceGraphmember'snodesarray.
launchers
Added in codemodel version 2.7. ๐
Optional member, present on executable targets that have at least one launcher specified by the project. The value is a JSON array of entries, one per specified launcher, and each entry is a JSON object with:
commandโ a string with the path to the launcher on disk, forward slashes please. If the file is inside the top-level source directory, the path is specified relative to that directory.argumentsโ optional member, present when the launcher command has arguments that come before the executable being launched. The value is a JSON array of strings, aka the arguments.typeโ a string telling you what kind of launcher it is. One of these two, periodt:emulatorโ an emulator for the target platform when cross-compiling. Go look at theCROSSCOMPILING_EMULATORtarget property.testโ a start program for executing tests. See theTEST_LAUNCHERtarget property.
link
Optional member that's present for non-imported executables and shared library targets that link into a runtime binary. The value is a JSON object whose members describe the link step. ๐
languageโ a string with the language (likeC,CXX,Fortran) of the toolchain used to invoke the linker.commandFragmentsโ optional member, present when fragments of the link command line invocation are available. The value is a JSON array of entries with the fragments in order. Each entry is a JSON object with:fragmentโ a string, one fragment of the link command line invocation. The value is encoded in the build system's native shell format.roleโ a string saying what the fragment's content is for:flags: link flags.libraries: link library file paths or flags.libraryPath: library search path flags.frameworkPath: macOS framework search path flags.
backtraceโ optional member, present when a CMake language backtrace to thetarget_link_libraries(),target_link_options(), or other command invocation that added this link fragment is available. Value's an unsigned integer, 0-based index into thebacktraceGraphmember'snodesarray.
ltoโ optional member, present with boolean valuetruewhen link-time optimization (a.k.a. interprocedural optimization, a.k.a. link-time code generation) is enabled. ๐ฅsysrootโ optional member, present when theCMAKE_SYSROOT_LINKorCMAKE_SYSROOTvariable is defined. The value is a JSON object with one member:pathโ a string with the absolute path to the sysroot, forward slashes only.
archive
Optional member, present for non-imported static library targets. The value is a JSON object whose members describe the archive step. ๐
commandFragmentsโ optional member, present when fragments of the archiver command line invocation are available. The value is a JSON array of entries describing those fragments. Each entry is a JSON object with:fragmentโ a string, one fragment of the archiver command line invocation. The value is encoded in the build system's native shell format.roleโ a string saying what the fragment's content is for:flags: archiver flags.
ltoโ optional member, present with boolean valuetruewhen link-time optimization (a.k.a. interprocedural optimization, a.k.a. link-time code generation) is enabled.
debugger
Added in codemodel version 2.8. ๐ธ
Optional member, present when the target has one of the following fields set. The value is a JSON object of entries matching the debugger-specific values that are set.
workingDirectoryโ optional member, present when theDEBUGGER_WORKING_DIRECTORYtarget property is set. It'll also be present in Visual Studio Generators whenVS_DEBUGGER_WORKING_DIRECTORYis set.
dependencies
Optional member, present when the target depends on other targets. Heads up: it's only present if the target is part of the build system. Imported targets aren't part of the build system, and interface libraries are only part of it if they have sources or file sets. ๐
The value is a JSON array of entries matching the build dependencies. And it's not just the direct ones, bestie โ it includes the transitive dependencies too. Everything listed builds before this target. ๐ฏ
The list reflects build graph dependencies, not necessarily link dependencies. So if there are cycles in the link dependencies of static libraries, not all the link dependencies will show up in this list of build graph dependencies. (iykyk ๐ญ)
Each entry is a JSON object with:
idโ a string uniquely identifying the target this target depends on. It matches the mainidmember of that other target.backtraceโ optional member, present when a CMake language backtrace to theadd_dependencies(),target_link_libraries(), or other command invocation that created this dependency is available. The value is an unsigned integer, 0-based index into thebacktraceGraphmember'snodesarray.
linkLibraries
Added in codemodel version 2.9. โญ
Optional member that may be present when the target links directly to one or more other targets or libraries. It holds the items used when linking this target. Those come from the target's LINK_LIBRARIES property (evaluated non-transitively), or from the INTERFACE_LINK_LIBRARIES_DIRECT property of another target it links to directly or transitively.
Items that are only applied as usage requirements โ like when they're wrapped in a $<COMPILE_ONLY:...> expression โ will not be in this member. Not them. ๐
The value is a JSON array of entries. Each entry is a JSON object with:
idโ optional member, present when the library being linked is a target. It uniquely identifies the target this one has a direct link relationship with, and matches the mainidmember of that other target.- Important: the target this
ididentifies isn't necessarily part of the build system. It might be an imported target, or an interface library with no sources or file sets. - Exactly one of
idorfragmentwill always be present. Always.
- Important: the target this
fragmentโ optional member, present when the library being linked is not a target. It's a string with the raw linker command line arguments that capture the relationship โ typically linking to libraries or frameworks by name rather than as a target.- Exactly one of
idorfragmentwill always be present. ๐ซถ
- Exactly one of
backtraceโ optional, and it only shows up when CMake actually has a language backtrace pointing at the command that created this relationship ๐ซถ. The value? An unsigned integer, 0-based, indexing into thebacktraceGraphmember'snodesarray. That's your little treasure map back to the guilty line of CMake code.fromDependencyโ optional, and only present when this relationship is the result of anINTERFACE_LINK_LIBRARIES_DIRECTtarget property living on one of this target's directly or transitively linked libraries ๐. It's a JSON object with exactly one member:idโ a string that uniquely identifies the target whoseINTERFACE_LINK_LIBRARIES_DIRECTproperty created this relationship. Its value matches the mainidmember of that target. iykyk ๐
โจ interfaceLinkLibraries โจ
Added in codemodel version 2.9.
Optional member, may show up when the target has one or more interface link libraries ๐. It holds the items that get used when linking consumers of this target โ and those items come straight from the target's INTERFACE_LINK_LIBRARIES property.
Heads up bestie: items that are only applied as usage requirements (like when they're wrapped in a $<COMPILE_ONLY:...> expression) will not be present here. They're just not that kind of item, okay? ๐
The value is a JSON array of entries, and each entry is a JSON object with these members:
idโ optional, present when the interface link library is for a target. It uniquely identifies that target, and the value matches the mainidmember of that target.
Important though: the target this id identifies is not necessarily part of the build system ๐ซ . It could be an imported target, or an interface library with no sources or file sets. So don't assume it exists as a buildable thing.
And exactly one of id or fragment will always be present โ no cap, that's the rule โจ
fragmentโ optional, present when the interface link library is not for a target. It's a string holding the raw linker command line arguments to be applied to consumers of this target's interface link libraries. Typically these are linker arguments for linking to libraries or frameworks by name instead of as a target ๐
Exactly one of id or fragment will always be present. (Yes, I said it twice. It's that important, bestie ๐
)
backtraceโ optional, present when there's a CMake language backtrace to the command invocation that created this interface relationship. Value is an unsigned integer, 0-based index into thebacktraceGraphmember'snodesarray ๐ฅ
๐ธ compileDependencies ๐ธ
Added in codemodel version 2.9.
Optional member, may be present when the target links directly to one or more other targets that might hand it usage requirements ๐. These affect how this target's sources get compiled, which is a whole different vibe from linking.
Where do these relationships come from? Two places:
- The target's
LINK_LIBRARIESproperty, evaluated non-transitively - The
INTERFACE_LINK_LIBRARIES_DIRECTproperty of other targets it links to, directly or transitively
Careful: relationships that only apply linking requirements (like when they're wrapped in a $<LINK_ONLY:...> expression) will not be present in this member. Linking-only stuff stays out of the compile party ๐
โโ๏ธ
The value is a JSON array of entries. Each entry is a JSON object with these members:
idโ a string uniquely identifying the target on which this target directly depends. It matches the mainidmember of that other target.
And again: the target this id points to is not necessarily part of the build system ๐ โ it may be an imported target, or an interface library with no sources or file sets.
backtraceโ optional, present when there's a CMake language backtrace to the command invocation that created this relationship. Unsigned integer, 0-based index into thebacktraceGraphmember'snodesarray ๐fromDependencyโ optional, and only there when the relationship came from anINTERFACE_LINK_LIBRARIES_DIRECTtarget property on one of this target's directly or transitively linked libraries. JSON object, one member:idโ a string uniquely identifying the target whoseINTERFACE_LINK_LIBRARIES_DIRECTproperty created this relationship. Value matches the mainidmember of that target ๐
๐ฆ interfaceCompileDependencies ๐ฆ
Added in codemodel version 2.9.
Optional member, may be present when the target has one or more interface linking relationships to other targets ๐. It carries the items that affect how consumers' sources get compiled, and these relationships are defined by the target's INTERFACE_LINK_LIBRARIES property.
Same vibe check as before: relationships that only apply linking requirements (think $<LINK_ONLY:...> wrapping) will not be present in this member โญ
The value is a JSON array of entries, each entry a JSON object with:
idโ a string uniquely identifying the target on which this target specifies an interface relationship. Matches the mainidmember of that other target.
And yeah, once more with feeling: that target is not necessarily part of the build system ๐ญ โ imported target, or an interface library with no sources or file sets, both totally valid.
backtraceโ optional, present when a CMake language backtrace to the command invocation that created this relationship is available. Unsigned integer, 0-based index into thebacktraceGraphmember'snodesarray ๐
๐ objectDependencies ๐
Added in codemodel version 2.9.
Optional member, present when the target has one or more entries in its SOURCES property where the entry is specified using $<TARGET_OBJECTS:...>, and where no other generator expression is used inside that $<TARGET_OBJECTS:...> expression ๐. (Yes โ one single genex, clean and simple. Nest another one in there and this member minds its own business.)
The value is a JSON array of entries. Each entry is a JSON object with:
idโ a string uniquely identifying the target whose objects are referred to in the$<TARGET_OBJECTS:...>expression. Matches the mainidmember of that other target ๐backtraceโ optional, present when there's a CMake language backtrace to the command invocation that created this dependency. Unsigned integer, 0-based index into thebacktraceGraphmember'snodesarray ๐ง
๐ฅ orderDependencies ๐ฅ
Added in codemodel version 2.9.
Optional member, present when the target has one or more direct order dependencies on other targets ๐ค. These can come from calls to add_dependencies() or from internal CMake processing โ either way, they're order-only, not link-y.
Big difference from thedependenciesarray: theZERO_CHECKtarget will not be included inorderDependencies. Also, this detail is only relevant forXcodeandVisual Studiogenerators ๐ซถ โ so if you're not on those, this is just lore.
The value is a JSON array of entries, each one a JSON object with:
idโ a string uniquely identifying the target on which this target depends. Matches the mainidmember of that other target ๐ซbacktraceโ optional, present when there's a CMake language backtrace to the command invocation that created this dependency. Unsigned integer, 0-based index into thebacktraceGraphmember'snodesarray ๐ธ
๐
fileSets ๐
Added in codemodel version 2.5.
An optional member, present when a target defines one or more file sets ๐๏ธ. The value is a JSON array of entries corresponding to the target's file sets โ each entry a JSON object with these members:
nameโ a string specifying the name of the file set โจtypeโ a string specifying the type of the file set. Peep the file set types supported bytarget_sources()for the full menu ๐visibilityโ a string specifying the visibility of the file set; one ofPUBLIC,PRIVATE, orINTERFACE. Pick your fighter ๐baseDirectoriesโ a JSON array of strings, each specifying a base directory containing sources in the file set. If the directory is inside the top-level source directory, the path is relative to that directory. Otherwise the path is absolute ๐
๐ sources ๐
A JSON array of entries corresponding to the target's source files ๐. Each entry is a JSON object with these members:
pathโ a string specifying the path to the source file on disk, written with forward slashes ๐ซถ. If the file is inside the top-level source directory, the path is relative to that directory. Otherwise it's absolute. (Same rule asbaseDirectoriesโ consistency is iconic.)compileGroupIndexโ optional, present when the source is actually compiled ๐จ. The value is an unsigned integer, 0-based index into thecompileGroupsarray. Go look it up, bestie, the whole story is in there ๐
sourceGroupIndex
Optional member โ it's there when the source is part of a source group, either because someone called the source_group() command or just by default. The value is an unsigned integer, 0-based, and it indexes into the sourceGroups array. ๐
isGenerated
Optional member, present with boolean value true when the source is GENERATED (as in the <prop_sf:GENERATED> property). โจ
fileSetIndex
Added in codemodel version 2.5.
Deprecated since version 4.4: use the fileSetIndexes field instead โ that one's an array, and it actually accounts for sources assigned to multiple file sets. ๐ญ
Optional member that's present when the source is part of a file set. The value is an unsigned integer 0-based index into the fileSets array, pointing at the file set to which the source was most recently added.
fileSetIndexes
Added in codemodel version 2.11.
Optional member, present when the source is part of at least one file set; see also policy CMP0211. The value is an array of unsigned integer 0-based indexes into the fileSets array. ๐ฆ
backtrace
Deprecated since version 4.4: use the backtraces field instead โ it's an array, and it accounts for sources added to multiple file sets over multiple command invocations.
Optional member that's present when a CMake language backtrace to the target_sources(), add_executable(), add_library(), add_custom_target(), or other command invocation that added this source to the target is available. The value is an unsigned integer 0-based index into the backtraceGraph member's nodes array.
backtraces
Added in codemodel version 2.11.
Optional member that's present when CMake language backtraces to the target_sources(), add_executable(), add_library(), add_custom_target(), or other command invocation that added this source to the target are available. And listen โ it's completely possible for a single source file to be included in multiple target_sources() invocations, each naming it in a different file set (see also policy CMP0211), so yeah, there could be multiple backtraces. The value is a JSON array where each entry is an unsigned integer 0-based index into the backtraceGraph member's nodes array. ๐
interfaceSources
Added in codemodel version 2.10.
An optional member that's present when a target defines one or more interface sources. The value is a JSON array of entries, one per interface source file of the target. Each entry is a JSON object with these members:
pathโ a string, the path to the source file on disk, written with forward slashes. If the file is inside the top-level source directory, the path is relative to that directory; otherwise it's absolute. ๐sourceGroupIndexโ optional member, present when the source is part of a source group either via thesource_group()command or by default. Unsigned integer 0-based index into thesourceGroupsarray.isGeneratedโ optional member, present with boolean valuetrueif the source isGENERATED.fileSetIndexโ added in codemodel version 2.5; deprecated since version 4.4: use thefileSetIndexesfield instead, which is an array and accounts for sources assigned to multiple file sets. Optional member, present when the source is part of a file set. Unsigned integer 0-based index into thefileSetsarray representing the file set to which the source was most recently added.fileSetIndexesโ added in codemodel version 2.11. Optional member, present when the source is part of at least one file set; see also policyCMP0211. The value is an array of unsigned integer 0-based indexes into thefileSetsarray.
sourceGroups
Optional member that's present when sources are grouped together by the source_group() command or by default. The value is a JSON array of entries, one per group. Each entry is a JSON object with these members:
nameโ a string, the name of the source group.sourceIndexesโ a JSON array listing the sources that belong to the group. Each entry is an unsigned integer 0-based index into the mainsourcesarray for the target.interfaceSourceIndexesโ added in codemodel version 2.10. Optional member, present when at least one interface source file is part of the source group. The value is a JSON array listing the interface sources belonging to the group, each entry an unsigned integer 0-based index into the maininterfaceSourcesarray for the target. ๐
compileGroups
Optional member that's present when the target has sources that compile. The value is a JSON array of entries, one per group of sources that all compile with the same settings. Each entry is a JSON object with these members:
sourceIndexesโ a JSON array listing the sources belonging to the group. Each entry is an unsigned integer 0-based index into the mainsourcesarray for the target.languageโ a string specifying the language (e.g.C,CXX,Fortran) of the toolchain used to compile the source file.languageStandardโ added in codemodel version 2.2. Optional member, present when the language standard is set explicitly (e.g. viaCXX_STANDARD) or implicitly by compile features. Each entry is a JSON object with two members:backtracesโ optional member, present when a CMake language backtrace to the<LANG>_STANDARDsetting is available. If the language standard was set implicitly by compile features, those are used as the backtrace(s). Multiple compile features can require the same language standard, so there could be multiple backtraces. The value is a JSON array where each entry is an unsigned integer 0-based index into thebacktraceGraphmember'snodesarray.standardโ string representing the language standard.
compileCommandFragmentsโ optional member, present when fragments of the compiler command line invocation are available. The value is a JSON array of entries specifying ordered fragments. Each entry is a JSON object with one member:fragmentโ a string specifying a fragment of the compile command line invocation. The value is encoded in the build system's native shell format.backtraceโ optional member, present when a CMake language backtrace to the command invocation that added this fragment is available. The value is an unsigned integer 0-based index into thebacktraceGraphmember'snodesarray.
includesโ optional member, present when there are include directories. The value is a JSON array with an entry for each directory. Each entry is a JSON object with these members:pathโ a string specifying the path to the include directory, represented with forward slashes.isSystemโ optional member, present with boolean valuetrueif the include directory is marked as a system include directory.backtraceโ optional member, present when a CMake language backtrace to thetarget_include_directories()or other command invocation that added this include directory is available. The value is an unsigned integer 0-based index into thebacktraceGraphmember'snodesarray.
frameworksโ added in codemodel version 2.6. Optional member, present when, on Apple platforms, there are frameworks. The value is a JSON array with an entry for each directory. Each entry is a JSON object with these members:pathโ a string specifying the path to the framework directory, represented with forward slashes.isSystemโ optional member, present with boolean valuetrueif the framework is marked as a system one.
backtrace
Optional member โ it shows up when there's a CMake language backtrace pointing at the target_link_libraries() call (or whatever other command invocation) that added this framework. The value? An unsigned integer, a 0-based index into the backtraceGraph member's nodes array. โจ
precompileHeaders
Added in codemodel version 2.1.
Optional member, present when target_precompile_headers() or other command invocations set PRECOMPILE_HEADERS on the target. The value is a JSON array with one entry per header, and every entry is a JSON object with these members:
headerโ the full path to the precompile header file.backtraceโ optional member, present when there's a CMake language backtrace to thetarget_precompile_headers()call (or other command invocation) that added this precompiled header. The value is an unsigned integer, a 0-based index into thebacktraceGraphmember'snodesarray.
defines
Optional member, present when there are preprocessor definitions. The value is a JSON array with one entry per definition, and each entry is a JSON object with these members:
defineโ a string giving the preprocessor definition in the format<name>[=<value>], e.g.DEForDEF=1.backtraceโ optional member, present when there's a CMake language backtrace to thetarget_compile_definitions()call (or other command invocation) that added this preprocessor definition. The value is an unsigned integer, a 0-based index into thebacktraceGraphmember'snodesarray.
sysroot
Optional member, present when the CMAKE_SYSROOT_COMPILE or CMAKE_SYSROOT variable is defined. The value is a JSON object with exactly one member:
pathโ a string giving the absolute path to the sysroot, written with forward slashes.
backtraceGraph
A "codemodel" version 2 "backtrace graph" whose nodes get referenced from backtrace members elsewhere in this "target" object. ๐ซถ
๐ง "codemodel" version 2 "backtrace graph"
The backtraceGraph member of a "codemodel" version 2 "directory" object (or of a "codemodel" version 2 "target" object, bestie โ both do it) is a JSON object describing a graph of backtraces. Its nodes are referenced from backtrace members elsewhere in the containing object. The members of this backtrace graph object are:
nodesโ a JSON array listing the nodes in the backtrace graph. Each entry is a JSON object with these members:fileโ an unsigned integer, 0-based index into thebacktracefilesarray.lineโ optional member, present when the node represents a line within the file. The value is an unsigned integer, a 1-based line number.commandโ optional member, present when the node represents a command invocation within the file. The value is an unsigned integer, 0-based index into thebacktracecommandsarray.parentโ optional member, present when the node is not the bottom of the call stack. The value is an unsigned integer, a 0-based index of another entry in thebacktracenodesarray.
commandsโ a JSON array listing command names referenced by backtrace nodes. Each entry is a string giving a command name.filesโ a JSON array listing CMake language files referenced by backtrace nodes. Each entry is a string giving the path to a file, written with forward slashes. If the file lives inside the top-level source directory, the path is relative to that directory; otherwise it's absolute. ๐
โจ Object Kind configureLog โจ
Added in version 3.26.
The configureLog object kind describes the location and the contents of a cmake-configure-log(7) file. Iconic behaviour, honestly.
There is only one configureLog object major version โ version 1.
Added in version 4.1: the configureLog object kind reply is described in machine-readable form by this JSON schema.
"configureLog" version 1
configureLog object version 1 is a JSON object:
{
"kind": "configureLog",
"version": { "major": 1, "minor": 0 },
"path": "/path/to/top-level-build-dir/CMakeFiles/CMakeConfigureLog.yaml",
"eventKindNames": [ "try_compile-v1", "try_run-v1" ]
}
The members specific to configureLog objects are:
pathโ a string giving the path to the configure log file. Clients must read the log file from this path, which may be different from the path documented bycmake-configure-log(7). Heads up though: the log file may not exist at all if no events are logged. ๐eventKindNamesโ a JSON array whose entries are each a JSON string naming one of thecmake-configure-log(7)versioned event kinds. At most one version of each configure log event kind will be listed. And even though the configure log may contain other (versioned) event kinds, clients must ignore the ones that aren't listed in this field. Fr fr, ignore them.
๐ Object Kind cache ๐
The cache object kind lists cache entries โ these are the Variables stored in the persistent cache (CMakeCache.txt) for the build tree. ๐
There is only one cache object major version, version 2. Version 1 straight-up does not exist, specifically to avoid confusion with the version 1 from cmake-server(7) mode. Not me skipping a number for my own sanity.
Added in version 4.1: the cache object kind reply is described in machine-readable form by this JSON schema.
"cache" version 2
cache object version 2 is a JSON object:
{
"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."
}
]
}
]
}
The members specific to cache objects are:
entriesโ a JSON array whose entries are each a JSON object specifying a cache entry. The members of each entry are:nameโ a string giving the name of the entry.valueโ a string giving the value of the entry.typeโ a string giving the type of the entry, the onecmake-gui(1)uses to choose a widget for editing. ๐propertiesโ a JSON array of entries specifying the associated cache entry properties. Each entry is a JSON object containing these members:nameโ a string giving the name of the cache entry property.valueโ a string giving the value of the cache entry property.
๐ฆ Object Kind cmakeFiles ๐ฆ
The cmakeFiles object kind lists files that CMake uses while configuring and generating the build system โ including the CMakeLists.txt files and the included .cmake files. The way it's just cataloguing everything? Obsessed.
There is only one cmakeFiles object major version, version 1.
Added in version 4.1: the cmakeFiles object kind reply is described in machine-readable form by this JSON schema.
"cmakeFiles" version 1
cmakeFiles object version 1 is a JSON object:
{
"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"
]
}
]
}
The members specific to cmakeFiles objects are:
pathsโ a JSON object containing these members:sourceโ a string giving the absolute path to the top-level source directory, written with forward slashes.buildโ a string giving the absolute path to the top-level build directory, written with forward slashes.
inputsโ a JSON array whose entries are each a JSON object specifying an input file that CMake uses when configuring and generating the build system. The members of each entry are:pathโ a string giving the path to an input file to CMake, written with forward slashes. If the file lives inside the top-level source directory, the path is relative to that directory; otherwise the path is absolute.
isGeneratedโ optional member, and it shows up with the boolean valuetruewhen the path points at a file that lives under the top-level build directory and the build is out-of-source. Heads up bestie: this member is not available on in-source builds. ๐isExternalโ optional member, present with boolean valuetruewhen the path specifies a file that's not under the top-level source or build directories.isCMakeโ optional member, present with boolean valuetrueif the path specifies a file that's chillin' inside the CMake installation itself.
โจ globsDependent โจ
Added in cmakeFiles version 1.1.
Optional member, and it's only there when the project calls file(GLOB) or file(GLOB_RECURSE) with the CONFIGURE_DEPENDS option. Its value is a JSON array of JSON objects, each one specifying a globbing expression plus the list of paths it matched. And here's the โจconsequenceโจ: if the globbing expression no longer matches that same list of paths, CMake considers the build system to be out of date. It will be judging you. ๐
The members of each entry are:
expressionโ a string specifying the globbing expression.recurseโ optional member, present with boolean valuetrueif the entry corresponds to afile(GLOB_RECURSE)call. Otherwise the entry corresponds to afile(GLOB)call.listDirectoriesโ optional member, present with boolean valuetrueiffile(GLOB)was called withoutLIST_DIRECTORIES false, or iffile(GLOB_RECURSE)was called withLIST_DIRECTORIES true.followSymlinksโ optional member, present with boolean valuetrueiffile(GLOB)was called with theFOLLOW_SYMLINKSoption.relativeโ optional member, present iffile(GLOB)was called with theRELATIVE <path>option. The value is a string containing the<path>that was given.pathsโ a JSON array of strings specifying the paths matched by the call tofile(GLOB)orfile(GLOB_RECURSE).
๐ Object Kind "toolchains" ๐
Okay so the toolchains object kind lists properties of the toolchains used during the build. These include the language, compiler path, ID, and version. It's giving full compiler rรฉsumรฉ. ๐
There is only one toolchains object major version, version 1.
Added in version 4.1: the toolchains object kind reply is described in machine-readable form by this JSON schema.
๐ ๏ธ "toolchains" version 1
toolchains object version 1 is a JSON object:
{
"kind": "toolchains",
"version": { "major": 1, "minor": 1 },
"toolchains": [
{
"language": "C",
"compiler": {
"path": "/usr/bin/cc",
"commandFragment": "--config x86_64-linux-gnu.cfg",
"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"
]
}
]
}
The members specific to toolchains objects are:
toolchainsโ a JSON array whose entries are each a JSON object specifying a toolchain associated with a particular language. The members of each entry are:languageโ a JSON string specifying the toolchain language, likeCorCXX. Language names are the same as language names that can be passed to theproject()command. Because CMake only supports a single toolchain per language, this field can be used as a key. ๐compilerโ a JSON object containing members:pathโ optional member, present when theCMAKE_<LANG>_COMPILERvariable is defined for the current language. Its value is a JSON string holding the path to the compiler.commandFragmentโ added intoolchainsversion 1.1. Optional member, present when theCMAKE_<LANG>_COMPILERvariable is a list containing multiple elements, or when theCCor similar environment variable contains command line arguments after the compiler executable. Its value is a JSON string holding the second and further elements (mandatory arguments to the compiler) as a command line fragment.idโ optional member, present when theCMAKE_<LANG>_COMPILER_IDvariable is defined for the current language. Its value is a JSON string holding the ID (GNU,MSVC, etc.) of the compiler.versionโ optional member, present when theCMAKE_<LANG>_COMPILER_VERSIONvariable is defined for the current language. Its value is a JSON string holding the version of the compiler.targetโ optional member, present when theCMAKE_<LANG>_COMPILER_TARGETvariable is defined for the current language. Its value is a JSON string holding the cross-compiling target of the compiler.implicitโ a JSON object containing members:includeDirectoriesโ optional member, present when theCMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIESvariable is defined for the current language. Its value is a JSON array of JSON strings where each string holds a path to an implicit include directory for the compiler.linkDirectoriesโ optional member, present when theCMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIESvariable is defined for the current language. Its value is a JSON array of JSON strings where each string holds a path to an implicit link directory for the compiler.linkFrameworkDirectoriesโ optional member, present when theCMAKE_<LANG>_IMPLICIT_LINK_FRAMEWORK_DIRECTORIESvariable is defined for the current language. Its value is a JSON array of JSON strings where each string holds a path to an implicit link framework directory for the compiler.linkLibrariesโ optional member, present when theCMAKE_<LANG>_IMPLICIT_LINK_LIBRARIESvariable is defined for the current language. Its value is a JSON array of JSON strings where each string holds a path to an implicit link library for the compiler.
sourceFileExtensionsโ optional member, present when theCMAKE_<LANG>_SOURCE_FILE_EXTENSIONSvariable is defined for the current language. Its value is a JSON array of JSON strings where each string holds a file extension (without the leading dot) for the language. ๐
๐ Copyright ๐
2000-2026 Kitware, Inc. and Contributors
And that's the whole page bestie, we literally made it to the end ๐ซถ๐ This was CMAKE-FILE-API(7) from source/version 4.4.5, dated Oct 28, 2026 โ go forth and query that file API, you absolute icon. ๐
๐ฆ where this page comes from
- arch rolling: cmake 4.4.5-1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms