cmake-rs icon indicating copy to clipboard operation
cmake-rs copied to clipboard

Including "CMakeLists.txt" in path passed to `Config::new()` causes full rebuilds every time

Open Patrick-6 opened this issue 4 months ago • 0 comments

I noticed that my cmake project was getting completely rebuilt on every tiny change.

The issue was that I used path/to/cmake/project/CMakeLists.txt instead of path/to/cmake/project/ when calling cmake::Config::new(path) in my build script. This caused this check to always return true (since the path from the CMakeCache.txt file doesn't include "CMakeLists.txt"), so the build directory was deleted before every compilation.

The simplest fix would be to either error out on or remove the string "CMakeLists.txt" for all paths passed into Config::new (here). Alternatively, this check could be changed to ignore the "CMakeLists.txt" on either path.


Workaround:

Don't include "CMakeLists.txt" in the path for Config::new.


Tested with:

cmake-rs version 0.1.54
cmake    version 3.31.6
Linux, Debian 13

Patrick-6 avatar Sep 06 '25 09:09 Patrick-6