I am using Linux, CMake, and Conda, which is a package manager that edits $PATH as a way to switch between "environments." This means when I run a special command in Conda, $PATH points to a different compiler. $CONDA_PREFIX is also changed.
By default, CMake is not sensitive to these changes. I would like it to be. Specifically, I want CMake to automatically regenerate all Makefiles when a different GCC is found in $PATH, or alternatively when $CONDA_PREFIX has changed since the last explicit cmake invocation. This regeneration would be similar to what CMake does when you edit the top-level CMakeLists.txt file - the next time you run make it regenerates everything.
How can I do this in a simple way using CMake?