寻找“cmake clean"命令来清除 CMake 输出 [英] Looking for a 'cmake clean' command to clear up CMake output

查看:132
本文介绍了寻找“cmake clean"命令来清除 CMake 输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像 make clean 删除 makefile 生成的所有文件一样,我想对 CMake 做同样的事情.我经常发现自己手动浏览目录,删除 cmake_install.cmakeCMakeCache.txt 等文件,以及 CMakeFiles 文件夹.

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.

是否有像 cmake clean 这样的命令来自动删除所有这些文件?理想情况下,这应该遵循当前目录的 CMakeLists.txt 文件中定义的递归结构.

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.

推荐答案

CMake 3.X

CMake 3.X 提供了一个干净"的目标.

CMake 3.X

CMake 3.X offers a 'clean' target.

cmake --build C:/foo/build/ --target clean

来自 3.0.2 的 CMake 文档:

From the CMake docs for 3.0.2:

--clean-first  = Build target 'clean' first, then build.
                 (To clean only, use --target 'clean'.)

CMake 2.X

CMake 2.X 版没有cmake clean

我通常在build"这样的单个文件夹中构建项目.所以如果我想make clean,我可以只rm -rf build.

I usually build the project in a single folder like "build". So if I want to make clean, I can just rm -rf build.

构建"与根目录CMakeLists.txt"位于同一目录中的文件夹;通常是一个不错的选择.要构建您的项目,您只需将 CMakeLists.txt 的位置作为参数提供给 cmake.例如:cd /build &&cmake ...(来自@ComicSansMS)

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)

这篇关于寻找“cmake clean"命令来清除 CMake 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆