cmake-file-api.7.rst 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707
  1. .. cmake-manual-description: CMake File-Based API
  2. cmake-file-api(7)
  3. *****************
  4. .. only:: html
  5. .. contents::
  6. Introduction
  7. ============
  8. CMake provides a file-based API that clients may use to get semantic
  9. information about the buildsystems CMake generates. Clients may use
  10. the API by writing query files to a specific location in a build tree
  11. to request zero or more `Object Kinds`_. When CMake generates the
  12. buildsystem in that build tree it will read the query files and write
  13. reply files for the client to read.
  14. The file-based API uses a ``<build>/.cmake/api/`` directory at the top
  15. of a build tree. The API is versioned to support changes to the layout
  16. of files within the API directory. API file layout versioning is
  17. orthogonal to the versioning of `Object Kinds`_ used in replies.
  18. This version of CMake supports only one API version, `API v1`_.
  19. .. versionadded:: 3.27
  20. Projects may also submit queries for the current run using the
  21. :command:`cmake_file_api` command.
  22. .. _`file-api v1`:
  23. API v1
  24. ======
  25. API v1 is housed in the ``<build>/.cmake/api/v1/`` directory.
  26. It has the following subdirectories:
  27. ``query/``
  28. Holds query files written by clients.
  29. These may be `v1 Shared Stateless Query Files`_,
  30. `v1 Client Stateless Query Files`_, or `v1 Client Stateful Query Files`_.
  31. ``reply/``
  32. Holds reply files written by CMake whenever it runs to generate a build
  33. system. These are indexed by a `v1 Reply Index File`_ file that may
  34. reference additional `v1 Reply Files`_. CMake owns all reply files.
  35. Clients must never remove them.
  36. Clients may look for and read a reply index file at any time.
  37. Clients may optionally create the ``reply/`` directory at any time
  38. and monitor it for the appearance of a new reply index file.
  39. v1 Shared Stateless Query Files
  40. -------------------------------
  41. Shared stateless query files allow clients to share requests for
  42. major versions of the `Object Kinds`_ and get all requested versions
  43. recognized by the CMake that runs.
  44. Clients may create shared requests by creating empty files in the
  45. ``v1/query/`` directory. The form is::
  46. <build>/.cmake/api/v1/query/<kind>-v<major>
  47. where ``<kind>`` is one of the `Object Kinds`_, ``-v`` is literal,
  48. and ``<major>`` is the major version number.
  49. Files of this form are stateless shared queries not owned by any specific
  50. client. Once created they should not be removed without external client
  51. coordination or human intervention.
  52. v1 Client Stateless Query Files
  53. -------------------------------
  54. Client stateless query files allow clients to create owned requests for
  55. major versions of the `Object Kinds`_ and get all requested versions
  56. recognized by the CMake that runs.
  57. Clients may create owned requests by creating empty files in
  58. client-specific query subdirectories. The form is::
  59. <build>/.cmake/api/v1/query/client-<client>/<kind>-v<major>
  60. where ``client-`` is literal, ``<client>`` is a string uniquely
  61. identifying the client, ``<kind>`` is one of the `Object Kinds`_,
  62. ``-v`` is literal, and ``<major>`` is the major version number.
  63. Each client must choose a unique ``<client>`` identifier via its
  64. own means.
  65. Files of this form are stateless queries owned by the client ``<client>``.
  66. The owning client may remove them at any time.
  67. v1 Client Stateful Query Files
  68. ------------------------------
  69. Stateful query files allow clients to request a list of versions of
  70. each of the `Object Kinds`_ and get only the most recent version
  71. recognized by the CMake that runs.
  72. Clients may create owned stateful queries by creating ``query.json``
  73. files in client-specific query subdirectories. The form is::
  74. <build>/.cmake/api/v1/query/client-<client>/query.json
  75. where ``client-`` is literal, ``<client>`` is a string uniquely
  76. identifying the client, and ``query.json`` is literal. Each client
  77. must choose a unique ``<client>`` identifier via its own means.
  78. ``query.json`` files are stateful queries owned by the client ``<client>``.
  79. The owning client may update or remove them at any time. When a
  80. given client installation is updated it may then update the stateful
  81. query it writes to build trees to request newer object versions.
  82. This can be used to avoid asking CMake to generate multiple object
  83. versions unnecessarily.
  84. A ``query.json`` file must contain a JSON object:
  85. .. code-block:: json
  86. {
  87. "requests": [
  88. { "kind": "<kind>" , "version": 1 },
  89. { "kind": "<kind>" , "version": { "major": 1, "minor": 2 } },
  90. { "kind": "<kind>" , "version": [2, 1] },
  91. { "kind": "<kind>" , "version": [2, { "major": 1, "minor": 2 }] },
  92. { "kind": "<kind>" , "version": 1, "client": {} },
  93. { "kind": "..." }
  94. ],
  95. "client": {}
  96. }
  97. The members are:
  98. ``requests``
  99. A JSON array containing zero or more requests. Each request is
  100. a JSON object with members:
  101. ``kind``
  102. Specifies one of the `Object Kinds`_ to be included in the reply.
  103. ``version``
  104. Indicates the version(s) of the object kind that the client
  105. understands. Versions have major and minor components following
  106. semantic version conventions. The value must be
  107. * a JSON integer specifying a (non-negative) major version number, or
  108. * a JSON object containing ``major`` and (optionally) ``minor``
  109. members specifying non-negative integer version components, or
  110. * a JSON array whose elements are each one of the above.
  111. ``client``
  112. Optional member reserved for use by the client. This value is
  113. preserved in the reply written for the client in the
  114. `v1 Reply Index File`_ but is otherwise ignored. Clients may use
  115. this to pass custom information with a request through to its reply.
  116. For each requested object kind CMake will choose the *first* version
  117. that it recognizes for that kind among those listed in the request.
  118. The response will use the selected *major* version with the highest
  119. *minor* version known to the running CMake for that major version.
  120. Therefore clients should list all supported major versions in
  121. preferred order along with the minimal minor version required
  122. for each major version.
  123. ``client``
  124. Optional member reserved for use by the client. This value is
  125. preserved in the reply written for the client in the
  126. `v1 Reply Index File`_ but is otherwise ignored. Clients may use
  127. this to pass custom information with a query through to its reply.
  128. Other ``query.json`` top-level members are reserved for future use.
  129. If present they are ignored for forward compatibility.
  130. v1 Reply Index File
  131. -------------------
  132. CMake writes an ``index-*.json`` file to the ``v1/reply/`` directory
  133. whenever it runs to generate a build system. Clients must read the
  134. reply index file first and may read other `v1 Reply Files`_ only by
  135. following references. The form of the reply index file name is::
  136. <build>/.cmake/api/v1/reply/index-<unspecified>.json
  137. where ``index-`` is literal and ``<unspecified>`` is an unspecified
  138. name selected by CMake. Whenever a new index file is generated it
  139. is given a new name and any old one is deleted. During the short
  140. time between these steps there may be multiple index files present;
  141. the one with the largest name in lexicographic order is the current
  142. index file.
  143. The reply index file contains a JSON object:
  144. .. code-block:: json
  145. {
  146. "cmake": {
  147. "version": {
  148. "major": 3, "minor": 14, "patch": 0, "suffix": "",
  149. "string": "3.14.0", "isDirty": false
  150. },
  151. "paths": {
  152. "cmake": "/prefix/bin/cmake",
  153. "ctest": "/prefix/bin/ctest",
  154. "cpack": "/prefix/bin/cpack",
  155. "root": "/prefix/share/cmake-3.14"
  156. },
  157. "generator": {
  158. "multiConfig": false,
  159. "name": "Unix Makefiles"
  160. }
  161. },
  162. "objects": [
  163. { "kind": "<kind>",
  164. "version": { "major": 1, "minor": 0 },
  165. "jsonFile": "<file>" },
  166. { "...": "..." }
  167. ],
  168. "reply": {
  169. "<kind>-v<major>": { "kind": "<kind>",
  170. "version": { "major": 1, "minor": 0 },
  171. "jsonFile": "<file>" },
  172. "<unknown>": { "error": "unknown query file" },
  173. "...": {},
  174. "client-<client>": {
  175. "<kind>-v<major>": { "kind": "<kind>",
  176. "version": { "major": 1, "minor": 0 },
  177. "jsonFile": "<file>" },
  178. "<unknown>": { "error": "unknown query file" },
  179. "...": {},
  180. "query.json": {
  181. "requests": [ {}, {}, {} ],
  182. "responses": [
  183. { "kind": "<kind>",
  184. "version": { "major": 1, "minor": 0 },
  185. "jsonFile": "<file>" },
  186. { "error": "unknown query file" },
  187. { "...": {} }
  188. ],
  189. "client": {}
  190. }
  191. }
  192. }
  193. }
  194. The members are:
  195. ``cmake``
  196. A JSON object containing information about the instance of CMake that
  197. generated the reply. It contains members:
  198. ``version``
  199. A JSON object specifying the version of CMake with members:
  200. ``major``, ``minor``, ``patch``
  201. Integer values specifying the major, minor, and patch version components.
  202. ``suffix``
  203. A string specifying the version suffix, if any, e.g. ``g0abc3``.
  204. ``string``
  205. A string specifying the full version in the format
  206. ``<major>.<minor>.<patch>[-<suffix>]``.
  207. ``isDirty``
  208. A boolean indicating whether the version was built from a version
  209. controlled source tree with local modifications.
  210. ``paths``
  211. A JSON object specifying paths to things that come with CMake.
  212. It has members for :program:`cmake`, :program:`ctest`, and :program:`cpack`
  213. whose values are JSON strings specifying the absolute path to each tool,
  214. represented with forward slashes. It also has a ``root`` member for
  215. the absolute path to the directory containing CMake resources like the
  216. ``Modules/`` directory (see :variable:`CMAKE_ROOT`).
  217. ``generator``
  218. A JSON object describing the CMake generator used for the build.
  219. It has members:
  220. ``multiConfig``
  221. A boolean specifying whether the generator supports multiple output
  222. configurations.
  223. ``name``
  224. A string specifying the name of the generator.
  225. ``platform``
  226. If the generator supports :variable:`CMAKE_GENERATOR_PLATFORM`,
  227. this is a string specifying the generator platform name.
  228. ``objects``
  229. A JSON array listing all versions of all `Object Kinds`_ generated
  230. as part of the reply. Each array entry is a
  231. `v1 Reply File Reference`_.
  232. ``reply``
  233. A JSON object mirroring the content of the ``query/`` directory
  234. that CMake loaded to produce the reply. The members are of the form
  235. ``<kind>-v<major>``
  236. A member of this form appears for each of the
  237. `v1 Shared Stateless Query Files`_ that CMake recognized as a
  238. request for object kind ``<kind>`` with major version ``<major>``.
  239. The value is a `v1 Reply File Reference`_ to the corresponding
  240. reply file for that object kind and version.
  241. ``<unknown>``
  242. A member of this form appears for each of the
  243. `v1 Shared Stateless Query Files`_ that CMake did not recognize.
  244. The value is a JSON object with a single ``error`` member
  245. containing a string with an error message indicating that the
  246. query file is unknown.
  247. ``client-<client>``
  248. A member of this form appears for each client-owned directory
  249. holding `v1 Client Stateless Query Files`_.
  250. The value is a JSON object mirroring the content of the
  251. ``query/client-<client>/`` directory. The members are of the form:
  252. ``<kind>-v<major>``
  253. A member of this form appears for each of the
  254. `v1 Client Stateless Query Files`_ that CMake recognized as a
  255. request for object kind ``<kind>`` with major version ``<major>``.
  256. The value is a `v1 Reply File Reference`_ to the corresponding
  257. reply file for that object kind and version.
  258. ``<unknown>``
  259. A member of this form appears for each of the
  260. `v1 Client Stateless Query Files`_ that CMake did not recognize.
  261. The value is a JSON object with a single ``error`` member
  262. containing a string with an error message indicating that the
  263. query file is unknown.
  264. ``query.json``
  265. This member appears for clients using
  266. `v1 Client Stateful Query Files`_.
  267. If the ``query.json`` file failed to read or parse as a JSON object,
  268. this member is a JSON object with a single ``error`` member
  269. containing a string with an error message. Otherwise, this member
  270. is a JSON object mirroring the content of the ``query.json`` file.
  271. The members are:
  272. ``client``
  273. A copy of the ``query.json`` file ``client`` member, if it exists.
  274. ``requests``
  275. A copy of the ``query.json`` file ``requests`` member, if it exists.
  276. ``responses``
  277. If the ``query.json`` file ``requests`` member is missing or invalid,
  278. this member is a JSON object with a single ``error`` member
  279. containing a string with an error message. Otherwise, this member
  280. contains a JSON array with a response for each entry of the
  281. ``requests`` array, in the same order. Each response is
  282. * a JSON object with a single ``error`` member containing a string
  283. with an error message, or
  284. * a `v1 Reply File Reference`_ to the corresponding reply file for
  285. the requested object kind and selected version.
  286. After reading the reply index file, clients may read the other
  287. `v1 Reply Files`_ it references.
  288. v1 Reply File Reference
  289. ^^^^^^^^^^^^^^^^^^^^^^^
  290. The reply index file represents each reference to another reply file
  291. using a JSON object with members:
  292. ``kind``
  293. A string specifying one of the `Object Kinds`_.
  294. ``version``
  295. A JSON object with members ``major`` and ``minor`` specifying
  296. integer version components of the object kind.
  297. ``jsonFile``
  298. A JSON string specifying a path relative to the reply index file
  299. to another JSON file containing the object.
  300. v1 Reply Files
  301. --------------
  302. Reply files containing specific `Object Kinds`_ are written by CMake.
  303. The names of these files are unspecified and must not be interpreted
  304. by clients. Clients must first read the `v1 Reply Index File`_ and
  305. follow references to the names of the desired response objects.
  306. Reply files (including the index file) will never be replaced by
  307. files of the same name but different content. This allows a client
  308. to read the files concurrently with a running CMake that may generate
  309. a new reply. However, after generating a new reply CMake will attempt
  310. to remove reply files from previous runs that it did not just write.
  311. If a client attempts to read a reply file referenced by the index but
  312. finds the file missing, that means a concurrent CMake has generated
  313. a new reply. The client may simply start again by reading the new
  314. reply index file.
  315. .. _`file-api object kinds`:
  316. Object Kinds
  317. ============
  318. The CMake file-based API reports semantic information about the build
  319. system using the following kinds of JSON objects. Each kind of object
  320. is versioned independently using semantic versioning with major and
  321. minor components. Every kind of object has the form:
  322. .. code-block:: json
  323. {
  324. "kind": "<kind>",
  325. "version": { "major": 1, "minor": 0 },
  326. "...": {}
  327. }
  328. The ``kind`` member is a string specifying the object kind name.
  329. The ``version`` member is a JSON object with ``major`` and ``minor``
  330. members specifying integer components of the object kind's version.
  331. Additional top-level members are specific to each object kind.
  332. Object Kind "codemodel"
  333. -----------------------
  334. The ``codemodel`` object kind describes the build system structure as
  335. modeled by CMake.
  336. There is only one ``codemodel`` object major version, version 2.
  337. Version 1 does not exist to avoid confusion with that from
  338. :manual:`cmake-server(7)` mode.
  339. "codemodel" version 2
  340. ^^^^^^^^^^^^^^^^^^^^^
  341. ``codemodel`` object version 2 is a JSON object:
  342. .. code-block:: json
  343. {
  344. "kind": "codemodel",
  345. "version": { "major": 2, "minor": 7 },
  346. "paths": {
  347. "source": "/path/to/top-level-source-dir",
  348. "build": "/path/to/top-level-build-dir"
  349. },
  350. "configurations": [
  351. {
  352. "name": "Debug",
  353. "directories": [
  354. {
  355. "source": ".",
  356. "build": ".",
  357. "childIndexes": [ 1 ],
  358. "projectIndex": 0,
  359. "targetIndexes": [ 0 ],
  360. "hasInstallRule": true,
  361. "minimumCMakeVersion": {
  362. "string": "3.14"
  363. },
  364. "jsonFile": "<file>"
  365. },
  366. {
  367. "source": "sub",
  368. "build": "sub",
  369. "parentIndex": 0,
  370. "projectIndex": 0,
  371. "targetIndexes": [ 1 ],
  372. "minimumCMakeVersion": {
  373. "string": "3.14"
  374. },
  375. "jsonFile": "<file>"
  376. }
  377. ],
  378. "projects": [
  379. {
  380. "name": "MyProject",
  381. "directoryIndexes": [ 0, 1 ],
  382. "targetIndexes": [ 0, 1 ]
  383. }
  384. ],
  385. "targets": [
  386. {
  387. "name": "MyExecutable",
  388. "directoryIndex": 0,
  389. "projectIndex": 0,
  390. "jsonFile": "<file>"
  391. },
  392. {
  393. "name": "MyLibrary",
  394. "directoryIndex": 1,
  395. "projectIndex": 0,
  396. "jsonFile": "<file>"
  397. }
  398. ]
  399. }
  400. ]
  401. }
  402. The members specific to ``codemodel`` objects are:
  403. ``paths``
  404. A JSON object containing members:
  405. ``source``
  406. A string specifying the absolute path to the top-level source directory,
  407. represented with forward slashes.
  408. ``build``
  409. A string specifying the absolute path to the top-level build directory,
  410. represented with forward slashes.
  411. ``configurations``
  412. A JSON array of entries corresponding to available build configurations.
  413. On single-configuration generators there is one entry for the value
  414. of the :variable:`CMAKE_BUILD_TYPE` variable. For multi-configuration
  415. generators there is an entry for each configuration listed in the
  416. :variable:`CMAKE_CONFIGURATION_TYPES` variable.
  417. Each entry is a JSON object containing members:
  418. ``name``
  419. A string specifying the name of the configuration, e.g. ``Debug``.
  420. ``directories``
  421. A JSON array of entries each corresponding to a build system directory
  422. whose source directory contains a ``CMakeLists.txt`` file. The first
  423. entry corresponds to the top-level directory. Each entry is a
  424. JSON object containing members:
  425. ``source``
  426. A string specifying the path to the source directory, represented
  427. with forward slashes. If the directory is inside the top-level
  428. source directory then the path is specified relative to that
  429. directory (with ``.`` for the top-level source directory itself).
  430. Otherwise the path is absolute.
  431. ``build``
  432. A string specifying the path to the build directory, represented
  433. with forward slashes. If the directory is inside the top-level
  434. build directory then the path is specified relative to that
  435. directory (with ``.`` for the top-level build directory itself).
  436. Otherwise the path is absolute.
  437. ``parentIndex``
  438. Optional member that is present when the directory is not top-level.
  439. The value is an unsigned integer 0-based index of another entry in
  440. the main ``directories`` array that corresponds to the parent
  441. directory that added this directory as a subdirectory.
  442. ``childIndexes``
  443. Optional member that is present when the directory has subdirectories.
  444. The value is a JSON array of entries corresponding to child directories
  445. created by the :command:`add_subdirectory` or :command:`subdirs`
  446. command. Each entry is an unsigned integer 0-based index of another
  447. entry in the main ``directories`` array.
  448. ``projectIndex``
  449. An unsigned integer 0-based index into the main ``projects`` array
  450. indicating the build system project to which the this directory belongs.
  451. ``targetIndexes``
  452. Optional member that is present when the directory itself has targets,
  453. excluding those belonging to subdirectories. The value is a JSON
  454. array of entries corresponding to the targets. Each entry is an
  455. unsigned integer 0-based index into the main ``targets`` array.
  456. ``minimumCMakeVersion``
  457. Optional member present when a minimum required version of CMake is
  458. known for the directory. This is the ``<min>`` version given to the
  459. most local call to the :command:`cmake_minimum_required(VERSION)`
  460. command in the directory itself or one of its ancestors.
  461. The value is a JSON object with one member:
  462. ``string``
  463. A string specifying the minimum required version in the format::
  464. <major>.<minor>[.<patch>[.<tweak>]][<suffix>]
  465. Each component is an unsigned integer and the suffix may be an
  466. arbitrary string.
  467. ``hasInstallRule``
  468. Optional member that is present with boolean value ``true`` when
  469. the directory or one of its subdirectories contains any
  470. :command:`install` rules, i.e. whether a ``make install``
  471. or equivalent rule is available.
  472. ``jsonFile``
  473. A JSON string specifying a path relative to the codemodel file
  474. to another JSON file containing a
  475. `"codemodel" version 2 "directory" object`_.
  476. This field was added in codemodel version 2.3.
  477. ``projects``
  478. A JSON array of entries corresponding to the top-level project
  479. and sub-projects defined in the build system. Each (sub-)project
  480. corresponds to a source directory whose ``CMakeLists.txt`` file
  481. calls the :command:`project` command with a project name different
  482. from its parent directory. The first entry corresponds to the
  483. top-level project.
  484. Each entry is a JSON object containing members:
  485. ``name``
  486. A string specifying the name given to the :command:`project` command.
  487. ``parentIndex``
  488. Optional member that is present when the project is not top-level.
  489. The value is an unsigned integer 0-based index of another entry in
  490. the main ``projects`` array that corresponds to the parent project
  491. that added this project as a sub-project.
  492. ``childIndexes``
  493. Optional member that is present when the project has sub-projects.
  494. The value is a JSON array of entries corresponding to the sub-projects.
  495. Each entry is an unsigned integer 0-based index of another
  496. entry in the main ``projects`` array.
  497. ``directoryIndexes``
  498. A JSON array of entries corresponding to build system directories
  499. that are part of the project. The first entry corresponds to the
  500. top-level directory of the project. Each entry is an unsigned
  501. integer 0-based index into the main ``directories`` array.
  502. ``targetIndexes``
  503. Optional member that is present when the project itself has targets,
  504. excluding those belonging to sub-projects. The value is a JSON
  505. array of entries corresponding to the targets. Each entry is an
  506. unsigned integer 0-based index into the main ``targets`` array.
  507. ``targets``
  508. A JSON array of entries corresponding to the build system targets.
  509. Such targets are created by calls to :command:`add_executable`,
  510. :command:`add_library`, and :command:`add_custom_target`, excluding
  511. imported targets and interface libraries (which do not generate any
  512. build rules). Each entry is a JSON object containing members:
  513. ``name``
  514. A string specifying the target name.
  515. ``id``
  516. A string uniquely identifying the target. This matches the ``id``
  517. field in the file referenced by ``jsonFile``.
  518. ``directoryIndex``
  519. An unsigned integer 0-based index into the main ``directories`` array
  520. indicating the build system directory in which the target is defined.
  521. ``projectIndex``
  522. An unsigned integer 0-based index into the main ``projects`` array
  523. indicating the build system project in which the target is defined.
  524. ``jsonFile``
  525. A JSON string specifying a path relative to the codemodel file
  526. to another JSON file containing a
  527. `"codemodel" version 2 "target" object`_.
  528. "codemodel" version 2 "directory" object
  529. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  530. A codemodel "directory" object is referenced by a `"codemodel" version 2`_
  531. object's ``directories`` array. Each "directory" object is a JSON object
  532. with members:
  533. ``paths``
  534. A JSON object containing members:
  535. ``source``
  536. A string specifying the path to the source directory, represented
  537. with forward slashes. If the directory is inside the top-level
  538. source directory then the path is specified relative to that
  539. directory (with ``.`` for the top-level source directory itself).
  540. Otherwise the path is absolute.
  541. ``build``
  542. A string specifying the path to the build directory, represented
  543. with forward slashes. If the directory is inside the top-level
  544. build directory then the path is specified relative to that
  545. directory (with ``.`` for the top-level build directory itself).
  546. Otherwise the path is absolute.
  547. ``installers``
  548. A JSON array of entries corresponding to :command:`install` rules.
  549. Each entry is a JSON object containing members:
  550. ``component``
  551. A string specifying the component selected by the corresponding
  552. :command:`install` command invocation.
  553. ``destination``
  554. Optional member that is present for specific ``type`` values below.
  555. The value is a string specifying the install destination path.
  556. The path may be absolute or relative to the install prefix.
  557. ``paths``
  558. Optional member that is present for specific ``type`` values below.
  559. The value is a JSON array of entries corresponding to the paths
  560. (files or directories) to be installed. Each entry is one of:
  561. * A string specifying the path from which a file or directory
  562. is to be installed. The portion of the path not preceded by
  563. a ``/`` also specifies the path (name) to which the file
  564. or directory is to be installed under the destination.
  565. * A JSON object with members:
  566. ``from``
  567. A string specifying the path from which a file or directory
  568. is to be installed.
  569. ``to``
  570. A string specifying the path to which the file or directory
  571. is to be installed under the destination.
  572. In both cases the paths are represented with forward slashes. If
  573. the "from" path is inside the top-level directory documented by the
  574. corresponding ``type`` value, then the path is specified relative
  575. to that directory. Otherwise the path is absolute.
  576. ``type``
  577. A string specifying the type of installation rule. The value is one
  578. of the following, with some variants providing additional members:
  579. ``file``
  580. An :command:`install(FILES)` or :command:`install(PROGRAMS)` call.
  581. The ``destination`` and ``paths`` members are populated, with paths
  582. under the top-level *source* directory expressed relative to it.
  583. The ``isOptional`` member may exist.
  584. This type has no additional members.
  585. ``directory``
  586. An :command:`install(DIRECTORY)` call.
  587. The ``destination`` and ``paths`` members are populated, with paths
  588. under the top-level *source* directory expressed relative to it.
  589. The ``isOptional`` member may exist.
  590. This type has no additional members.
  591. ``target``
  592. An :command:`install(TARGETS)` call.
  593. The ``destination`` and ``paths`` members are populated, with paths
  594. under the top-level *build* directory expressed relative to it.
  595. The ``isOptional`` member may exist.
  596. This type has additional members ``targetId``, ``targetIndex``,
  597. ``targetIsImportLibrary``, and ``targetInstallNamelink``.
  598. ``export``
  599. An :command:`install(EXPORT)` call.
  600. The ``destination`` and ``paths`` members are populated, with paths
  601. under the top-level *build* directory expressed relative to it.
  602. The ``paths`` entries refer to files generated automatically by
  603. CMake for installation, and their actual values are considered
  604. private implementation details.
  605. This type has additional members ``exportName`` and ``exportTargets``.
  606. ``script``
  607. An :command:`install(SCRIPT)` call.
  608. This type has additional member ``scriptFile``.
  609. ``code``
  610. An :command:`install(CODE)` call.
  611. This type has no additional members.
  612. ``importedRuntimeArtifacts``
  613. An :command:`install(IMPORTED_RUNTIME_ARTIFACTS)` call.
  614. The ``destination`` member is populated. The ``isOptional`` member may
  615. exist. This type has no additional members.
  616. ``runtimeDependencySet``
  617. An :command:`install(RUNTIME_DEPENDENCY_SET)` call or an
  618. :command:`install(TARGETS)` call with ``RUNTIME_DEPENDENCIES``. The
  619. ``destination`` member is populated. This type has additional members
  620. ``runtimeDependencySetName`` and ``runtimeDependencySetType``.
  621. ``fileSet``
  622. An :command:`install(TARGETS)` call with ``FILE_SET``.
  623. The ``destination`` and ``paths`` members are populated.
  624. The ``isOptional`` member may exist.
  625. This type has additional members ``fileSetName``, ``fileSetType``,
  626. ``fileSetDirectories``, and ``fileSetTarget``.
  627. This type was added in codemodel version 2.4.
  628. ``isExcludeFromAll``
  629. Optional member that is present with boolean value ``true`` when
  630. :command:`install` is called with the ``EXCLUDE_FROM_ALL`` option.
  631. ``isForAllComponents``
  632. Optional member that is present with boolean value ``true`` when
  633. :command:`install(SCRIPT|CODE)` is called with the
  634. ``ALL_COMPONENTS`` option.
  635. ``isOptional``
  636. Optional member that is present with boolean value ``true`` when
  637. :command:`install` is called with the ``OPTIONAL`` option.
  638. This is allowed when ``type`` is ``file``, ``directory``, or ``target``.
  639. ``targetId``
  640. Optional member that is present when ``type`` is ``target``.
  641. The value is a string uniquely identifying the target to be installed.
  642. This matches the ``id`` member of the target in the main
  643. "codemodel" object's ``targets`` array.
  644. ``targetIndex``
  645. Optional member that is present when ``type`` is ``target``.
  646. The value is an unsigned integer 0-based index into the main "codemodel"
  647. object's ``targets`` array for the target to be installed.
  648. ``targetIsImportLibrary``
  649. Optional member that is present when ``type`` is ``target`` and
  650. the installer is for a Windows DLL import library file or for an
  651. AIX linker import file. If present, it has boolean value ``true``.
  652. ``targetInstallNamelink``
  653. Optional member that is present when ``type`` is ``target`` and
  654. the installer corresponds to a target that may use symbolic links
  655. to implement the :prop_tgt:`VERSION` and :prop_tgt:`SOVERSION`
  656. target properties.
  657. The value is a string indicating how the installer is supposed to
  658. handle the symlinks: ``skip`` means the installer should skip the
  659. symlinks and install only the real file, and ``only`` means the
  660. installer should install only the symlinks and not the real file.
  661. In all cases the ``paths`` member lists what it actually installs.
  662. ``exportName``
  663. Optional member that is present when ``type`` is ``export``.
  664. The value is a string specifying the name of the export.
  665. ``exportTargets``
  666. Optional member that is present when ``type`` is ``export``.
  667. The value is a JSON array of entries corresponding to the targets
  668. included in the export. Each entry is a JSON object with members:
  669. ``id``
  670. A string uniquely identifying the target. This matches
  671. the ``id`` member of the target in the main "codemodel"
  672. object's ``targets`` array.
  673. ``index``
  674. An unsigned integer 0-based index into the main "codemodel"
  675. object's ``targets`` array for the target.
  676. ``runtimeDependencySetName``
  677. Optional member that is present when ``type`` is ``runtimeDependencySet``
  678. and the installer was created by an
  679. :command:`install(RUNTIME_DEPENDENCY_SET)` call. The value is a string
  680. specifying the name of the runtime dependency set that was installed.
  681. ``runtimeDependencySetType``
  682. Optional member that is present when ``type`` is ``runtimeDependencySet``.
  683. The value is a string with one of the following values:
  684. ``library``
  685. Indicates that this installer installs dependencies that are not macOS
  686. frameworks.
  687. ``framework``
  688. Indicates that this installer installs dependencies that are macOS
  689. frameworks.
  690. ``fileSetName``
  691. Optional member that is present when ``type`` is ``fileSet``. The value is
  692. a string with the name of the file set.
  693. This field was added in codemodel version 2.4.
  694. ``fileSetType``
  695. Optional member that is present when ``type`` is ``fileSet``. The value is
  696. a string with the type of the file set.
  697. This field was added in codemodel version 2.4.
  698. ``fileSetDirectories``
  699. Optional member that is present when ``type`` is ``fileSet``. The value
  700. is a list of strings with the file set's base directories (determined by
  701. genex-evaluation of :prop_tgt:`HEADER_DIRS` or
  702. :prop_tgt:`HEADER_DIRS_<NAME>`).
  703. This field was added in codemodel version 2.4.
  704. ``fileSetTarget``
  705. Optional member that is present when ``type`` is ``fileSet``. The value
  706. is a JSON object with members:
  707. ``id``
  708. A string uniquely identifying the target. This matches
  709. the ``id`` member of the target in the main "codemodel"
  710. object's ``targets`` array.
  711. ``index``
  712. An unsigned integer 0-based index into the main "codemodel"
  713. object's ``targets`` array for the target.
  714. This field was added in codemodel version 2.4.
  715. ``scriptFile``
  716. Optional member that is present when ``type`` is ``script``.
  717. The value is a string specifying the path to the script file on disk,
  718. represented with forward slashes. If the file is inside the top-level
  719. source directory then the path is specified relative to that directory.
  720. Otherwise the path is absolute.
  721. ``backtrace``
  722. Optional member that is present when a CMake language backtrace to
  723. the :command:`install` or other command invocation that added this
  724. installer is available. The value is an unsigned integer 0-based
  725. index into the ``backtraceGraph`` member's ``nodes`` array.
  726. ``backtraceGraph``
  727. A `"codemodel" version 2 "backtrace graph"`_ whose nodes are referenced
  728. from ``backtrace`` members elsewhere in this "directory" object.
  729. "codemodel" version 2 "target" object
  730. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  731. A codemodel "target" object is referenced by a `"codemodel" version 2`_
  732. object's ``targets`` array. Each "target" object is a JSON object
  733. with members:
  734. ``name``
  735. A string specifying the logical name of the target.
  736. ``id``
  737. A string uniquely identifying the target. The format is unspecified
  738. and should not be interpreted by clients.
  739. ``type``
  740. A string specifying the type of the target. The value is one of
  741. ``EXECUTABLE``, ``STATIC_LIBRARY``, ``SHARED_LIBRARY``,
  742. ``MODULE_LIBRARY``, ``OBJECT_LIBRARY``, ``INTERFACE_LIBRARY``,
  743. or ``UTILITY``.
  744. ``backtrace``
  745. Optional member that is present when a CMake language backtrace to
  746. the command in the source code that created the target is available.
  747. The value is an unsigned integer 0-based index into the
  748. ``backtraceGraph`` member's ``nodes`` array.
  749. ``folder``
  750. Optional member that is present when the :prop_tgt:`FOLDER` target
  751. property is set. The value is a JSON object with one member:
  752. ``name``
  753. A string specifying the name of the target folder.
  754. ``paths``
  755. A JSON object containing members:
  756. ``source``
  757. A string specifying the path to the target's source directory,
  758. represented with forward slashes. If the directory is inside the
  759. top-level source directory then the path is specified relative to
  760. that directory (with ``.`` for the top-level source directory itself).
  761. Otherwise the path is absolute.
  762. ``build``
  763. A string specifying the path to the target's build directory,
  764. represented with forward slashes. If the directory is inside the
  765. top-level build directory then the path is specified relative to
  766. that directory (with ``.`` for the top-level build directory itself).
  767. Otherwise the path is absolute.
  768. ``nameOnDisk``
  769. Optional member that is present for executable and library targets
  770. that are linked or archived into a single primary artifact.
  771. The value is a string specifying the file name of that artifact on disk.
  772. ``artifacts``
  773. Optional member that is present for executable and library targets
  774. that produce artifacts on disk meant for consumption by dependents.
  775. The value is a JSON array of entries corresponding to the artifacts.
  776. Each entry is a JSON object containing one member:
  777. ``path``
  778. A string specifying the path to the file on disk, represented with
  779. forward slashes. If the file is inside the top-level build directory
  780. then the path is specified relative to that directory.
  781. Otherwise the path is absolute.
  782. ``isGeneratorProvided``
  783. Optional member that is present with boolean value ``true`` if the
  784. target is provided by CMake's build system generator rather than by
  785. a command in the source code.
  786. ``install``
  787. Optional member that is present when the target has an :command:`install`
  788. rule. The value is a JSON object with members:
  789. ``prefix``
  790. A JSON object specifying the installation prefix. It has one member:
  791. ``path``
  792. A string specifying the value of :variable:`CMAKE_INSTALL_PREFIX`.
  793. ``destinations``
  794. A JSON array of entries specifying an install destination path.
  795. Each entry is a JSON object with members:
  796. ``path``
  797. A string specifying the install destination path. The path may
  798. be absolute or relative to the install prefix.
  799. ``backtrace``
  800. Optional member that is present when a CMake language backtrace to
  801. the :command:`install` command invocation that specified this
  802. destination is available. The value is an unsigned integer 0-based
  803. index into the ``backtraceGraph`` member's ``nodes`` array.
  804. ``launchers``
  805. Optional member that is present on executable targets that have
  806. at least one launcher specified by the project. The value is a
  807. JSON array of entries corresponding to the specified launchers.
  808. Each entry is a JSON object with members:
  809. ``command``
  810. A string specifying the path to the launcher on disk, represented
  811. with forward slashes. If the file is inside the top-level source
  812. directory then the path is specified relative to that directory.
  813. ``arguments``
  814. Optional member that is present when the launcher command has
  815. arguments preceding the executable to be launched. The value
  816. is a JSON array of strings representing the arguments.
  817. ``type``
  818. A string specifying the type of launcher. The value is one of
  819. the following:
  820. ``emulator``
  821. An emulator for the target platform when cross-compiling.
  822. See the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property.
  823. This field was added in codemodel version 2.7.
  824. ``link``
  825. Optional member that is present for executables and shared library
  826. targets that link into a runtime binary. The value is a JSON object
  827. with members describing the link step:
  828. ``language``
  829. A string specifying the language (e.g. ``C``, ``CXX``, ``Fortran``)
  830. of the toolchain is used to invoke the linker.
  831. ``commandFragments``
  832. Optional member that is present when fragments of the link command
  833. line invocation are available. The value is a JSON array of entries
  834. specifying ordered fragments. Each entry is a JSON object with members:
  835. ``fragment``
  836. A string specifying a fragment of the link command line invocation.
  837. The value is encoded in the build system's native shell format.
  838. ``role``
  839. A string specifying the role of the fragment's content:
  840. * ``flags``: link flags.
  841. * ``libraries``: link library file paths or flags.
  842. * ``libraryPath``: library search path flags.
  843. * ``frameworkPath``: macOS framework search path flags.
  844. ``lto``
  845. Optional member that is present with boolean value ``true``
  846. when link-time optimization (a.k.a. interprocedural optimization
  847. or link-time code generation) is enabled.
  848. ``sysroot``
  849. Optional member that is present when the :variable:`CMAKE_SYSROOT_LINK`
  850. or :variable:`CMAKE_SYSROOT` variable is defined. The value is a
  851. JSON object with one member:
  852. ``path``
  853. A string specifying the absolute path to the sysroot, represented
  854. with forward slashes.
  855. ``archive``
  856. Optional member that is present for static library targets. The value
  857. is a JSON object with members describing the archive step:
  858. ``commandFragments``
  859. Optional member that is present when fragments of the archiver command
  860. line invocation are available. The value is a JSON array of entries
  861. specifying the fragments. Each entry is a JSON object with members:
  862. ``fragment``
  863. A string specifying a fragment of the archiver command line invocation.
  864. The value is encoded in the build system's native shell format.
  865. ``role``
  866. A string specifying the role of the fragment's content:
  867. * ``flags``: archiver flags.
  868. ``lto``
  869. Optional member that is present with boolean value ``true``
  870. when link-time optimization (a.k.a. interprocedural optimization
  871. or link-time code generation) is enabled.
  872. ``dependencies``
  873. Optional member that is present when the target depends on other targets.
  874. The value is a JSON array of entries corresponding to the dependencies.
  875. Each entry is a JSON object with members:
  876. ``id``
  877. A string uniquely identifying the target on which this target depends.
  878. This matches the main ``id`` member of the other target.
  879. ``backtrace``
  880. Optional member that is present when a CMake language backtrace to
  881. the :command:`add_dependencies`, :command:`target_link_libraries`,
  882. or other command invocation that created this dependency is
  883. available. The value is an unsigned integer 0-based index into
  884. the ``backtraceGraph`` member's ``nodes`` array.
  885. ``fileSets``
  886. A JSON array of entries corresponding to the target's file sets. Each entry
  887. is a JSON object with members:
  888. ``name``
  889. A string specifying the name of the file set.
  890. ``type``
  891. A string specifying the type of the file set. See
  892. :command:`target_sources` supported file set types.
  893. ``visibility``
  894. A string specifying the visibility of the file set; one of ``PUBLIC``,
  895. ``PRIVATE``, or ``INTERFACE``.
  896. ``baseDirectories``
  897. A JSON array of strings, each specifying a base directory containing
  898. sources in the file set. If the directory is inside the top-level source
  899. directory then the path is specified relative to that directory.
  900. Otherwise the path is absolute.
  901. This field was added in codemodel version 2.5.
  902. ``sources``
  903. A JSON array of entries corresponding to the target's source files.
  904. Each entry is a JSON object with members:
  905. ``path``
  906. A string specifying the path to the source file on disk, represented
  907. with forward slashes. If the file is inside the top-level source
  908. directory then the path is specified relative to that directory.
  909. Otherwise the path is absolute.
  910. ``compileGroupIndex``
  911. Optional member that is present when the source is compiled.
  912. The value is an unsigned integer 0-based index into the
  913. ``compileGroups`` array.
  914. ``sourceGroupIndex``
  915. Optional member that is present when the source is part of a source
  916. group either via the :command:`source_group` command or by default.
  917. The value is an unsigned integer 0-based index into the
  918. ``sourceGroups`` array.
  919. ``isGenerated``
  920. Optional member that is present with boolean value ``true`` if
  921. the source is :prop_sf:`GENERATED`.
  922. ``fileSetIndex``
  923. Optional member that is present when the source is part of a file set.
  924. The value is an unsigned integer 0-based index into the ``fileSets``
  925. array.
  926. This field was added in codemodel version 2.5.
  927. ``backtrace``
  928. Optional member that is present when a CMake language backtrace to
  929. the :command:`target_sources`, :command:`add_executable`,
  930. :command:`add_library`, :command:`add_custom_target`, or other
  931. command invocation that added this source to the target is
  932. available. The value is an unsigned integer 0-based index into
  933. the ``backtraceGraph`` member's ``nodes`` array.
  934. ``sourceGroups``
  935. Optional member that is present when sources are grouped together by
  936. the :command:`source_group` command or by default. The value is a
  937. JSON array of entries corresponding to the groups. Each entry is
  938. a JSON object with members:
  939. ``name``
  940. A string specifying the name of the source group.
  941. ``sourceIndexes``
  942. A JSON array listing the sources belonging to the group.
  943. Each entry is an unsigned integer 0-based index into the
  944. main ``sources`` array for the target.
  945. ``compileGroups``
  946. Optional member that is present when the target has sources that compile.
  947. The value is a JSON array of entries corresponding to groups of sources
  948. that all compile with the same settings. Each entry is a JSON object
  949. with members:
  950. ``sourceIndexes``
  951. A JSON array listing the sources belonging to the group.
  952. Each entry is an unsigned integer 0-based index into the
  953. main ``sources`` array for the target.
  954. ``language``
  955. A string specifying the language (e.g. ``C``, ``CXX``, ``Fortran``)
  956. of the toolchain is used to compile the source file.
  957. ``languageStandard``
  958. Optional member that is present when the language standard is set
  959. explicitly (e.g. via :prop_tgt:`CXX_STANDARD`) or implicitly by
  960. compile features. Each entry is a JSON object with two members:
  961. ``backtraces``
  962. Optional member that is present when a CMake language backtrace to
  963. the ``<LANG>_STANDARD`` setting is available. If the language
  964. standard was set implicitly by compile features those are used as
  965. the backtrace(s). It's possible for multiple compile features to
  966. require the same language standard so there could be multiple
  967. backtraces. The value is a JSON array with each entry being an
  968. unsigned integer 0-based index into the ``backtraceGraph``
  969. member's ``nodes`` array.
  970. ``standard``
  971. String representing the language standard.
  972. This field was added in codemodel version 2.2.
  973. ``compileCommandFragments``
  974. Optional member that is present when fragments of the compiler command
  975. line invocation are available. The value is a JSON array of entries
  976. specifying ordered fragments. Each entry is a JSON object with
  977. one member:
  978. ``fragment``
  979. A string specifying a fragment of the compile command line invocation.
  980. The value is encoded in the build system's native shell format.
  981. ``includes``
  982. Optional member that is present when there are include directories.
  983. The value is a JSON array with an entry for each directory. Each
  984. entry is a JSON object with members:
  985. ``path``
  986. A string specifying the path to the include directory,
  987. represented with forward slashes.
  988. ``isSystem``
  989. Optional member that is present with boolean value ``true`` if
  990. the include directory is marked as a system include directory.
  991. ``backtrace``
  992. Optional member that is present when a CMake language backtrace to
  993. the :command:`target_include_directories` or other command invocation
  994. that added this include directory is available. The value is
  995. an unsigned integer 0-based index into the ``backtraceGraph``
  996. member's ``nodes`` array.
  997. ``frameworks``
  998. Optional member that is present when, on Apple platforms, there are
  999. frameworks. The value is a JSON array with an entry for each directory.
  1000. Each entry is a JSON object with members:
  1001. ``path``
  1002. A string specifying the path to the framework directory,
  1003. represented with forward slashes.
  1004. ``isSystem``
  1005. Optional member that is present with boolean value ``true`` if
  1006. the framework is marked as a system one.
  1007. ``backtrace``
  1008. Optional member that is present when a CMake language backtrace to
  1009. the :command:`target_link_libraries` or other command invocation
  1010. that added this framework is available. The value is
  1011. an unsigned integer 0-based index into the ``backtraceGraph``
  1012. member's ``nodes`` array.
  1013. This field was added in codemodel version 2.6.
  1014. ``precompileHeaders``
  1015. Optional member that is present when :command:`target_precompile_headers`
  1016. or other command invocations set :prop_tgt:`PRECOMPILE_HEADERS` on the
  1017. target. The value is a JSON array with an entry for each header. Each
  1018. entry is a JSON object with members:
  1019. ``header``
  1020. Full path to the precompile header file.
  1021. ``backtrace``
  1022. Optional member that is present when a CMake language backtrace to
  1023. the :command:`target_precompile_headers` or other command invocation
  1024. that added this precompiled header is available. The value is an
  1025. unsigned integer 0-based index into the ``backtraceGraph`` member's
  1026. ``nodes`` array.
  1027. This field was added in codemodel version 2.1.
  1028. ``defines``
  1029. Optional member that is present when there are preprocessor definitions.
  1030. The value is a JSON array with an entry for each definition. Each
  1031. entry is a JSON object with members:
  1032. ``define``
  1033. A string specifying the preprocessor definition in the format
  1034. ``<name>[=<value>]``, e.g. ``DEF`` or ``DEF=1``.
  1035. ``backtrace``
  1036. Optional member that is present when a CMake language backtrace to
  1037. the :command:`target_compile_definitions` or other command invocation
  1038. that added this preprocessor definition is available. The value is
  1039. an unsigned integer 0-based index into the ``backtraceGraph``
  1040. member's ``nodes`` array.
  1041. ``sysroot``
  1042. Optional member that is present when the
  1043. :variable:`CMAKE_SYSROOT_COMPILE` or :variable:`CMAKE_SYSROOT`
  1044. variable is defined. The value is a JSON object with one member:
  1045. ``path``
  1046. A string specifying the absolute path to the sysroot, represented
  1047. with forward slashes.
  1048. ``backtraceGraph``
  1049. A `"codemodel" version 2 "backtrace graph"`_ whose nodes are referenced
  1050. from ``backtrace`` members elsewhere in this "target" object.
  1051. "codemodel" version 2 "backtrace graph"
  1052. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1053. The ``backtraceGraph`` member of a `"codemodel" version 2 "directory" object`_,
  1054. or `"codemodel" version 2 "target" object`_ is a JSON object describing a
  1055. graph of backtraces. Its nodes are referenced from ``backtrace`` members
  1056. elsewhere in the containing object. The backtrace graph object members are:
  1057. ``nodes``
  1058. A JSON array listing nodes in the backtrace graph. Each entry
  1059. is a JSON object with members:
  1060. ``file``
  1061. An unsigned integer 0-based index into the backtrace ``files`` array.
  1062. ``line``
  1063. An optional member present when the node represents a line within
  1064. the file. The value is an unsigned integer 1-based line number.
  1065. ``command``
  1066. An optional member present when the node represents a command
  1067. invocation within the file. The value is an unsigned integer
  1068. 0-based index into the backtrace ``commands`` array.
  1069. ``parent``
  1070. An optional member present when the node is not the bottom of
  1071. the call stack. The value is an unsigned integer 0-based index
  1072. of another entry in the backtrace ``nodes`` array.
  1073. ``commands``
  1074. A JSON array listing command names referenced by backtrace nodes.
  1075. Each entry is a string specifying a command name.
  1076. ``files``
  1077. A JSON array listing CMake language files referenced by backtrace nodes.
  1078. Each entry is a string specifying the path to a file, represented
  1079. with forward slashes. If the file is inside the top-level source
  1080. directory then the path is specified relative to that directory.
  1081. Otherwise the path is absolute.
  1082. .. _`file-api configureLog`:
  1083. Object Kind "configureLog"
  1084. --------------------------
  1085. The ``configureLog`` object kind describes the location and contents of
  1086. a :manual:`cmake-configure-log(7)` file.
  1087. There is only one ``configureLog`` object major version, version 1.
  1088. "configureLog" version 1
  1089. ^^^^^^^^^^^^^^^^^^^^^^^^
  1090. ``configureLog`` object version 1 is a JSON object:
  1091. .. code-block:: json
  1092. {
  1093. "kind": "configureLog",
  1094. "version": { "major": 1, "minor": 0 },
  1095. "path": "/path/to/top-level-build-dir/CMakeFiles/CMakeConfigureLog.yaml",
  1096. "eventKindNames": [ "try_compile-v1", "try_run-v1" ]
  1097. }
  1098. The members specific to ``configureLog`` objects are:
  1099. ``path``
  1100. A string specifying the path to the configure log file.
  1101. Clients must read the log file from this path, which may be
  1102. different than the path documented by :manual:`cmake-configure-log(7)`.
  1103. The log file may not exist if no events are logged.
  1104. ``eventKindNames``
  1105. A JSON array whose entries are each a JSON string naming one
  1106. of the :manual:`cmake-configure-log(7)` versioned event kinds.
  1107. At most one version of each configure log event kind will be listed.
  1108. Although the configure log may contain other (versioned) event kinds,
  1109. clients must ignore those that are not listed in this field.
  1110. Object Kind "cache"
  1111. -------------------
  1112. The ``cache`` object kind lists cache entries. These are the
  1113. :ref:`CMake Language Variables` stored in the persistent cache
  1114. (``CMakeCache.txt``) for the build tree.
  1115. There is only one ``cache`` object major version, version 2.
  1116. Version 1 does not exist to avoid confusion with that from
  1117. :manual:`cmake-server(7)` mode.
  1118. "cache" version 2
  1119. ^^^^^^^^^^^^^^^^^
  1120. ``cache`` object version 2 is a JSON object:
  1121. .. code-block:: json
  1122. {
  1123. "kind": "cache",
  1124. "version": { "major": 2, "minor": 0 },
  1125. "entries": [
  1126. {
  1127. "name": "BUILD_SHARED_LIBS",
  1128. "value": "ON",
  1129. "type": "BOOL",
  1130. "properties": [
  1131. {
  1132. "name": "HELPSTRING",
  1133. "value": "Build shared libraries"
  1134. }
  1135. ]
  1136. },
  1137. {
  1138. "name": "CMAKE_GENERATOR",
  1139. "value": "Unix Makefiles",
  1140. "type": "INTERNAL",
  1141. "properties": [
  1142. {
  1143. "name": "HELPSTRING",
  1144. "value": "Name of generator."
  1145. }
  1146. ]
  1147. }
  1148. ]
  1149. }
  1150. The members specific to ``cache`` objects are:
  1151. ``entries``
  1152. A JSON array whose entries are each a JSON object specifying a
  1153. cache entry. The members of each entry are:
  1154. ``name``
  1155. A string specifying the name of the entry.
  1156. ``value``
  1157. A string specifying the value of the entry.
  1158. ``type``
  1159. A string specifying the type of the entry used by
  1160. :manual:`cmake-gui(1)` to choose a widget for editing.
  1161. ``properties``
  1162. A JSON array of entries specifying associated
  1163. :ref:`cache entry properties <Cache Entry Properties>`.
  1164. Each entry is a JSON object containing members:
  1165. ``name``
  1166. A string specifying the name of the cache entry property.
  1167. ``value``
  1168. A string specifying the value of the cache entry property.
  1169. Object Kind "cmakeFiles"
  1170. ------------------------
  1171. The ``cmakeFiles`` object kind lists files used by CMake while
  1172. configuring and generating the build system. These include the
  1173. ``CMakeLists.txt`` files as well as included ``.cmake`` files.
  1174. There is only one ``cmakeFiles`` object major version, version 1.
  1175. "cmakeFiles" version 1
  1176. ^^^^^^^^^^^^^^^^^^^^^^
  1177. ``cmakeFiles`` object version 1 is a JSON object:
  1178. .. code-block:: json
  1179. {
  1180. "kind": "cmakeFiles",
  1181. "version": { "major": 1, "minor": 0 },
  1182. "paths": {
  1183. "build": "/path/to/top-level-build-dir",
  1184. "source": "/path/to/top-level-source-dir"
  1185. },
  1186. "inputs": [
  1187. {
  1188. "path": "CMakeLists.txt"
  1189. },
  1190. {
  1191. "isGenerated": true,
  1192. "path": "/path/to/top-level-build-dir/.../CMakeSystem.cmake"
  1193. },
  1194. {
  1195. "isExternal": true,
  1196. "path": "/path/to/external/third-party/module.cmake"
  1197. },
  1198. {
  1199. "isCMake": true,
  1200. "isExternal": true,
  1201. "path": "/path/to/cmake/Modules/CMakeGenericSystem.cmake"
  1202. }
  1203. ]
  1204. }
  1205. The members specific to ``cmakeFiles`` objects are:
  1206. ``paths``
  1207. A JSON object containing members:
  1208. ``source``
  1209. A string specifying the absolute path to the top-level source directory,
  1210. represented with forward slashes.
  1211. ``build``
  1212. A string specifying the absolute path to the top-level build directory,
  1213. represented with forward slashes.
  1214. ``inputs``
  1215. A JSON array whose entries are each a JSON object specifying an input
  1216. file used by CMake when configuring and generating the build system.
  1217. The members of each entry are:
  1218. ``path``
  1219. A string specifying the path to an input file to CMake, represented
  1220. with forward slashes. If the file is inside the top-level source
  1221. directory then the path is specified relative to that directory.
  1222. Otherwise the path is absolute.
  1223. ``isGenerated``
  1224. Optional member that is present with boolean value ``true``
  1225. if the path specifies a file that is under the top-level
  1226. build directory and the build is out-of-source.
  1227. This member is not available on in-source builds.
  1228. ``isExternal``
  1229. Optional member that is present with boolean value ``true``
  1230. if the path specifies a file that is not under the top-level
  1231. source or build directories.
  1232. ``isCMake``
  1233. Optional member that is present with boolean value ``true``
  1234. if the path specifies a file in the CMake installation.
  1235. Object Kind "toolchains"
  1236. ------------------------
  1237. The ``toolchains`` object kind lists properties of the toolchains used during
  1238. the build. These include the language, compiler path, ID, and version.
  1239. There is only one ``toolchains`` object major version, version 1.
  1240. "toolchains" version 1
  1241. ^^^^^^^^^^^^^^^^^^^^^^
  1242. ``toolchains`` object version 1 is a JSON object:
  1243. .. code-block:: json
  1244. {
  1245. "kind": "toolchains",
  1246. "version": { "major": 1, "minor": 0 },
  1247. "toolchains": [
  1248. {
  1249. "language": "C",
  1250. "compiler": {
  1251. "path": "/usr/bin/cc",
  1252. "id": "GNU",
  1253. "version": "9.3.0",
  1254. "implicit": {
  1255. "includeDirectories": [
  1256. "/usr/lib/gcc/x86_64-linux-gnu/9/include",
  1257. "/usr/local/include",
  1258. "/usr/include/x86_64-linux-gnu",
  1259. "/usr/include"
  1260. ],
  1261. "linkDirectories": [
  1262. "/usr/lib/gcc/x86_64-linux-gnu/9",
  1263. "/usr/lib/x86_64-linux-gnu",
  1264. "/usr/lib",
  1265. "/lib/x86_64-linux-gnu",
  1266. "/lib"
  1267. ],
  1268. "linkFrameworkDirectories": [],
  1269. "linkLibraries": [ "gcc", "gcc_s", "c", "gcc", "gcc_s" ]
  1270. }
  1271. },
  1272. "sourceFileExtensions": [ "c", "m" ]
  1273. },
  1274. {
  1275. "language": "CXX",
  1276. "compiler": {
  1277. "path": "/usr/bin/c++",
  1278. "id": "GNU",
  1279. "version": "9.3.0",
  1280. "implicit": {
  1281. "includeDirectories": [
  1282. "/usr/include/c++/9",
  1283. "/usr/include/x86_64-linux-gnu/c++/9",
  1284. "/usr/include/c++/9/backward",
  1285. "/usr/lib/gcc/x86_64-linux-gnu/9/include",
  1286. "/usr/local/include",
  1287. "/usr/include/x86_64-linux-gnu",
  1288. "/usr/include"
  1289. ],
  1290. "linkDirectories": [
  1291. "/usr/lib/gcc/x86_64-linux-gnu/9",
  1292. "/usr/lib/x86_64-linux-gnu",
  1293. "/usr/lib",
  1294. "/lib/x86_64-linux-gnu",
  1295. "/lib"
  1296. ],
  1297. "linkFrameworkDirectories": [],
  1298. "linkLibraries": [
  1299. "stdc++", "m", "gcc_s", "gcc", "c", "gcc_s", "gcc"
  1300. ]
  1301. }
  1302. },
  1303. "sourceFileExtensions": [
  1304. "C", "M", "c++", "cc", "cpp", "cxx", "mm", "CPP"
  1305. ]
  1306. }
  1307. ]
  1308. }
  1309. The members specific to ``toolchains`` objects are:
  1310. ``toolchains``
  1311. A JSON array whose entries are each a JSON object specifying a toolchain
  1312. associated with a particular language. The members of each entry are:
  1313. ``language``
  1314. A JSON string specifying the toolchain language, like C or CXX. Language
  1315. names are the same as language names that can be passed to the
  1316. :command:`project` command. Because CMake only supports a single toolchain
  1317. per language, this field can be used as a key.
  1318. ``compiler``
  1319. A JSON object containing members:
  1320. ``path``
  1321. Optional member that is present when the
  1322. :variable:`CMAKE_<LANG>_COMPILER` variable is defined for the current
  1323. language. Its value is a JSON string holding the path to the compiler.
  1324. ``id``
  1325. Optional member that is present when the
  1326. :variable:`CMAKE_<LANG>_COMPILER_ID` variable is defined for the current
  1327. language. Its value is a JSON string holding the ID (GNU, MSVC, etc.) of
  1328. the compiler.
  1329. ``version``
  1330. Optional member that is present when the
  1331. :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable is defined for the
  1332. current language. Its value is a JSON string holding the version of the
  1333. compiler.
  1334. ``target``
  1335. Optional member that is present when the
  1336. :variable:`CMAKE_<LANG>_COMPILER_TARGET` variable is defined for the
  1337. current language. Its value is a JSON string holding the cross-compiling
  1338. target of the compiler.
  1339. ``implicit``
  1340. A JSON object containing members:
  1341. ``includeDirectories``
  1342. Optional member that is present when the
  1343. :variable:`CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES` variable is
  1344. defined for the current language. Its value is a JSON array of JSON
  1345. strings where each string holds a path to an implicit include
  1346. directory for the compiler.
  1347. ``linkDirectories``
  1348. Optional member that is present when the
  1349. :variable:`CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES` variable is
  1350. defined for the current language. Its value is a JSON array of JSON
  1351. strings where each string holds a path to an implicit link directory
  1352. for the compiler.
  1353. ``linkFrameworkDirectories``
  1354. Optional member that is present when the
  1355. :variable:`CMAKE_<LANG>_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES` variable
  1356. is defined for the current language. Its value is a JSON array of JSON
  1357. strings where each string holds a path to an implicit link framework
  1358. directory for the compiler.
  1359. ``linkLibraries``
  1360. Optional member that is present when the
  1361. :variable:`CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES` variable is defined
  1362. for the current language. Its value is a JSON array of JSON strings
  1363. where each string holds a path to an implicit link library for the
  1364. compiler.
  1365. ``sourceFileExtensions``
  1366. Optional member that is present when the
  1367. :variable:`CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS` variable is defined for
  1368. the current language. Its value is a JSON array of JSON strings where each
  1369. each string holds a file extension (without the leading dot) for the
  1370. language.