Do you have symlinks somewhere in your build dir path? Do they match the symlinks used in your source dir path?
If not, I suggest doing a cd $(readlink -f $PWD)
to go to a path without any symlinks.
If that solves your problem, this is a long standing CMake behavior that is broader than it should be. https://gitlab.kitware.com/cmake/cmake/issues/16228 You can do any of:
- not use symlinks
- keep all symlinks common between your build and source tree
- reference symlink paths by their symlink-free name
to mitigate the issue.