c++ - CMake/Ninja attempting to compile deleted `.cpp` file -
i've found when delete cpp
files project using cmake
, ninja
, can't compile without first deleting build directory , starting scratch. cmake and/or ninja apparently squirrels away number of references cpp
files compiles, deleting cmake cache before re-running cmake doesn't remove references.
is known issue? there solution? i've run rm $(grep -r <filename> <builddir>)
, that's terrible kludge.
edit: appears mistaken, have not been able duplicate problem. manually re-running cmake appears always generate correct list of .cpp
files, using glob
generate lists of sources.
turning comments answer
collecting source files file(glob ...)
yes, cmake won't know new or deleted source files when collecting source files file(glob ...)
command. known restriction cmake. i've changed cmake project(s) list source files individually because of this. out of convenience i'm still collecting header files file(glob ...)
command.
quoting cmake's file()
command documentation:
we not recommend using glob collect list of source files source tree. if no cmakelists.txt file changes when source added or removed generated build system cannot know when ask cmake regenerate.
deleting cmakecache.txt
retrigger configuration
just deleting cmakecache.txt
may not enough retrigger cmake configuration. issue 0014820: warn users removing cmakecache.txt claims need delete cmakefiles
directories.
from experience reliable way retrigger cmake configuration touch 1 of projects cmakelists.txt
files.
note: ninja
cmake adds rebuild_cache
target conveniently running cmake project again.
retrigger after updates source control
just 1 thought: if deletion of source files happens because removed source control there maybe workaround still allows use file(glob ...)
on source files.
e.g. if use git add following main cmakelists.txt
:
configure_file(${cmake_source_dir}/.git/index ${project_binary_dir}/git_index.tmp)
disadvantage: retrigger configuration each git operation (update, commit, ...).
some references:
Comments
Post a Comment