cmake-file-api.7.rst 66 KB

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