cmake_instrumentation.rst 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. cmake_instrumentation
  2. ---------------------
  3. .. versionadded:: 4.0
  4. .. note::
  5. This command is only available when experimental support for instrumentation
  6. has been enabled by the ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` gate.
  7. Enables interacting with the
  8. :manual:`CMake Instrumentation API <cmake-instrumentation(7)>`.
  9. This allows for configuring instrumentation at the project-level.
  10. .. code-block:: cmake
  11. cmake_instrumentation(
  12. API_VERSION <version>
  13. DATA_VERSION <version>
  14. [HOOKS <hooks>...]
  15. [QUERIES <queries>...]
  16. [CALLBACK <callback>]
  17. )
  18. The ``API_VERSION`` and ``DATA_VERSION`` must always be given. Currently, the
  19. only supported value for both fields is 1. See :ref:`cmake-instrumentation API v1`
  20. for details of the ``API_VERSION`` and :ref:`cmake-instrumentation Data v1` for details
  21. of the ``DATA_VERSION``.
  22. Each of the optional keywords ``HOOKS``, ``QUERIES``, and ``CALLBACK``
  23. correspond to one of the parameters to the :ref:`cmake-instrumentation v1 Query Files`.
  24. The ``CALLBACK`` keyword can be provided multiple times to create multiple callbacks.
  25. Whenever ``cmake_instrumentation`` is invoked, a query file is generated in
  26. ``<build>/.cmake/instrumentation/v1/query/generated`` to enable instrumentation
  27. with the provided arguments.
  28. Example
  29. ^^^^^^^
  30. The following example shows an invocation of the command and its
  31. equivalent JSON query file.
  32. .. code-block:: cmake
  33. cmake_instrumentation(
  34. API_VERSION 1
  35. DATA_VERSION 1
  36. HOOKS postGenerate preCMakeBuild postCMakeBuild
  37. QUERIES staticSystemInformation dynamicSystemInformation
  38. CALLBACK ${CMAKE_COMMAND} -P /path/to/handle_data.cmake
  39. CALLBACK ${CMAKE_COMMAND} -P /path/to/handle_data_2.cmake
  40. )
  41. .. code-block:: json
  42. {
  43. "version": 1,
  44. "hooks": [
  45. "postGenerate", "preCMakeBuild", "postCMakeBuild"
  46. ],
  47. "queries": [
  48. "staticSystemInformation", "dynamicSystemInformation"
  49. ],
  50. "callbacks": [
  51. "/path/to/cmake -P /path/to/handle_data.cmake"
  52. "/path/to/cmake -P /path/to/handle_data_2.cmake"
  53. ]
  54. }