cmake_instrumentation.rst 1.9 KB

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