CMake: How to force reconfiguration.
29 Nov 2022In a TIL from yesterday, I mentioned that when I’m changing around the CMakeLists.txt
file, my go-to troubleshooting strategy is to delete everything in the build directory so that the next configure is from scratch.
I asked this question on interwebs – is there a more automated way to force a reconfigure? I have project files for the IDE in my build directories, so I don’t want to wipe the whole thing out.
Option 1: --fresh
for CMake versions 3.24 onwards
CMake has this functionality to reconfigure in new versions with the --fresh
flag. Usage:
cmake ../src --fresh
Option 2: remove select elements in the build directory
You can set up an alias to get rid of the CMakeFiles
directory and CMakeCache.txt
file.
alias clean_cmake='rm -rf CMakeFiles/ CMakeCache.txt'