Skip to content

CTest: add an ENVIRONMENT_MODIFICATION property

This property allows projects to modify environment variables at test time rather than trying to guess what the state should be based on what is present at configure time. Of particular interest is the ability to use a PATH present at test time while adding entries known to be necessary for the test itself.

There are multiple operations provided to modify variables, including:

  • setting and unsetting
  • appending and prepending as:
    • strings
    • path lists
    • CMake lists

Additionally, an ignore action is provided to cancel any prior modifications to that particular variable in the case of incremental additions to the test property.


TODO:

  • error out on invalid entries
  • add test suite

See #16372 (closed) for a request for cmake -E env to do similar operations. Adding it and using it for these purposes is not desired because adding a cmake -E env "launcher" on the test interferes with things such as injection of valgrind or cross-compilation runners into a test command.

/cc @zackgalbreath

Edited by Ben Boeckel

Merge request reports