cmake_instrumentation.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 v1`
  17. for details of the data output content and location.
  18. Each of the optional keywords ``HOOKS``, ``QUERIES``, and ``CALLBACK``
  19. correspond to one of the parameters to the :ref:`cmake-instrumentation v1 Query Files`.
  20. The ``CALLBACK`` keyword can be provided multiple times to create multiple callbacks.
  21. Whenever ``cmake_instrumentation`` is invoked, a query file is generated in
  22. ``<build>/.cmake/timing/v1/query/generated`` to enable instrumentation
  23. with the provided arguments.
  24. Example
  25. ^^^^^^^
  26. The following example shows an invocation of the command and its
  27. equivalent JSON query file.
  28. .. code-block:: cmake
  29. cmake_instrumentation(
  30. API_VERSION 1
  31. DATA_VERSION 1
  32. HOOKS postGenerate preCMakeBuild postCMakeBuild
  33. QUERIES staticSystemInformation dynamicSystemInformation
  34. CALLBACK ${CMAKE_COMMAND} -P /path/to/handle_data.cmake
  35. CALLBACK ${CMAKE_COMMAND} -P /path/to/handle_data_2.cmake
  36. )
  37. .. code-block:: json
  38. {
  39. "version": 1,
  40. "hooks": [
  41. "postGenerate", "preCMakeBuild", "postCMakeBuild"
  42. ],
  43. "queries": [
  44. "staticSystemInformation", "dynamicSystemInformation"
  45. ],
  46. "callbacks": [
  47. "/path/to/cmake -P /path/to/handle_data.cmake"
  48. "/path/to/cmake -P /path/to/handle_data_2.cmake"
  49. ]
  50. }