Adding a symlink to the build directory in the source directory, before runnning cmake, breaks the generated build files
I initially reported this in https://github.com/WebAssembly/wabt/issues/1607 , but it can be observed with almost any CMake project.
Steps to reproduce:
$ cd /path/to/sourcedir
$ mkdir /tmp/builddir
$ ln -s /tmp/builddir build
$ cd build
$ cmake /path/to/sourcedir
[... CMake config runs fine ...]
If I selected the Make generator, I get this:
$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ericonr/docs/extpro/wabt/build
make[2]: *** No rule to make target '../src/apply-names.cc', needed by 'CMakeFiles/wabt.dir/src/apply-names.cc.o'. Stop.
make[1]: *** [CMakeFiles/Makefile2:823: CMakeFiles/wabt.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
If I selectde the Ninja generator, I get this:
$ ninja
[1/1] Re-running CMake...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ericonr/docs/extpro/wabt/build
[... this repeats itself until the loop detection kicks in ...]
Neither of them can build the project.
I reproduced this with CMake 3.17.1, 3.18.4, 3.19.4 and 3.19.5. I am on a Linux system.