Just as make clean
deletes all the files that a makefile has produced, I would like to do the same with CMake. All too often I find myself manually going through directories removing files like cmake_install.cmake
and CMakeCache.txt
, and the CMakeFiles
folders.
Is there a command like cmake clean
to remove all these files automatically? Ideally this should follow the recursive structure defined within the current directory's CMakeLists.txt
file.
Best Answer
CMake 3.X
CMake 3.X offers a 'clean' target.
From the CMake docs for 3.0.2:
CMake 2.X
There is no
cmake clean
in CMake version 2.XI usually build the project in a single folder like "build". So if I want to
make clean
, I can justrm -rf build
.The "build" folder in the same directory as the root "CMakeLists.txt" is usually a good choice. To build your project, you simply give cmake the location of the CMakeLists.txt as an argument. For example:
cd <location-of-cmakelists>/build && cmake ..
. (From @ComicSansMS)