Cached FILEPATH can get stale when file is removed
I'm quite often running into issues where I need to wipe the CMake build folder to be able to compile a project. The reason is that CMake does not check the validity of cached file paths. I.e. right now I have the following:
┌milian@milian-kdab2:~/projects/kf5/build/extragear/kdevelop/kdevelop
└$ grep -R libclang.so CMakeCache.txt
CLANG_LIBCLANG_LIB:FILEPATH=/ssd2/milian/projects/compiled/other/lib/libclang.so
KDevClangPrivate_LIB_DEPENDS:STATIC=general;Qt5::Core;general;KF5::TextEditor;general;KF5::ThreadWeaver;general;KDev::Util;general;KDev::Language;general;KDev::Project;general;KDev::Util;general;/ssd2/milian/projects/compiled/other/lib/libclang.so;
┌milian@milian-kdab2:~/projects/kf5/build/extragear/kdevelop/kdevelop/plugins/clang
└$ make
...
make[2]: *** No rule to make target '/ssd2/milian/projects/compiled/other/lib/libclang.so', needed by 'plugins/clang/tests/clang-minimal-visitor'. Stop.
make[1]: *** [CMakeFiles/Makefile2:15817: plugins/clang/tests/CMakeFiles/clang-minimal-visitor.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
This path is stale. It used to be valid and pointed to my self-compiled LLVM. But I removed that now - the file is gone. CMake does not detect it. I would expect it to see that this happened and then wipe the cache entry. I cannot even run make rebuild_cache
to fix this. The only options I know of is manually editing the CMakeCache.txt
or starting with a clean build directory.