ccmake persists targets between configurations
Minimal test case for reproducing the problem
The project depends on ns::fake_lib target, that can be provided by two different sources (mutually exclusive), and WITH_OPTION controls which source to use.
The difference is that one source provides directly ns::fake_lib as an imported target, while the other source provides other::fake_lib and then its name is standardized to ns::fake_lib through an alias target.
Everything works as expected if each configure step is followed by a generate step, but if I change something during two configures without generating, a target conflicts arise.
To replicate the problem (see attached example CMakeLists.txt):
mkdir build
cd build
cmake ..
ccmake ..
Inside CCMake:
configure
change WITH_OPTION to ON
configure
change WITH_OPTION to OFF
configure
! here it complains about “target_include_directories can not be used on an ALIAS target”
It seems like CCMake keeps an internal state for the graph of dependencies, but it is kept during configure calls in a row and so the conflict arises. If you generate after each configure, no problem. If you use classic cmake cli no problem (because it automatically performs a generate step after the configure one).
I was expecting that each configure call would generate targets from scratch.
Tested with CMake version 3.14.5