Macro expansion for binaryDir in CMakePresets.json

The top section in the presets macro expansion documentation is unclear to me:

Macro Expansion

As mentioned above, some fields support macro expansion. Macros are recognized in the form $<macro-namespace>{<macro-name>}. All macros are evaluated in the context of the preset being used, even if the macro is in a field that was inherited from another preset. For example, if the Base preset sets variable PRESET_NAME to ${presetName}, and the Derived preset inherits from Base, PRESET_NAME will be set to Derived.

What is a macro-namespace? Is it this:

  • “” (nothing)
  • env
  • penv
  • vendor

Or is it:

  • configurePresets
  • buildPresets
  • testPresets

Or is there a way to get configurePresets.binaryDir into a testPreset?

(Specific use case: I need to specify COVFILE=/all.cov to all ctest runs, so the Bullseye Coverage code istrumentation knows where to put its results)

Yes, it’s this. Most macros use the empty namespace (${presetName}, ${sourceDir}, etc.), but some, such as environment variables, use the other namespaces ($env{HOME}, etc.)