Feature Request: Generated Unity Files and Relative Paths

Currently when CMake generates the unity files when using UNITY_BUILD, the generated file contains absolute paths to the source files that are included:

unity_0_cxx.cxx
/* generated by CMake */

/* SRC_math/add.cpp */
#undef ANON
#define ANON unity_a0194eebc1fdbfb93184ef52c70cf799
/* NOLINTNEXTLINE(bugprone-suspicious-include) */
#include "C:/r/sample_unity_rel/math/add.cpp"

While this works well for normal builds, our team is also trying to leverage a distributed build and cache (something similar to ccache + distcc) in order to share compiled results across multiple developers in our team.

As you might imagine, because the unity files have absolute paths in the contents, our caching mechanism will now require all developers to have the same repository path in order to get cache hits. If they use different repository paths, the file contents no longer match and we therefore get cache misses, even if the underlying source files have not changed.

Could there be an option added to unity (e.g. UNITY_BUILD_REL_PATHS_ENABLED) that would be used to make the unity paths generate relative paths, and then add the source directory to the include path. E.g.

unity_0_cxx.cxx
/* generated by CMake */

/* SRC_math/add.cpp */
#undef ANON
#define ANON unity_a0194eebc1fdbfb93184ef52c70cf799
/* NOLINTNEXTLINE(bugprone-suspicious-include) */
#include "math/add.cpp"

For context, we have a work around to run a script that replaces the absolute path with a relative path every time CMake generates. Ideally, I’m looking to see if there is any appetite (or rejections) on adding this directly to CMake so we can remove our work around.