In my (limited) understanding, my required functionality is not possible, but I better ask.
Ich have custom targets called “clean-xyz” which remove files nicely via cmake -E remove …
I would like to also unset a cmake cache variable when I call clean-xyz but I believe, this is not possible as it would require CMakeCache.txt manipulation.
I’m not sure why you say it is not possible, I would have tried using
cmake -U <var> from the custom command.
Thank you very much, I was not aware of this option. I added a cmake . -U … to my custom target and it works.
It would be a bonus, if cmake would only remove the variable from the cache and not process CMakeLists.txt the same time, but already the current state is an improvement!