【发布时间】:2013-07-05 16:44:48
【问题描述】:
我并不是只为自己提出这个要求。我希望这个问题能成为许多喜欢我的新手的参考,因为对于这么小的CMakeLists.txt 文件,幕后究竟发生了什么感到非常困惑
cmake_minimum_required (VERSION 2.6)
project(Tutorial)
add_executable(Tutorial tutorial.cpp)
还有这么小的tutorial.cpp
int main() { return 0; }
生成的文件太多了
CMakeCache.txt cmake_install.cmake Makefile
CMakeLists.txt tutorial.cpp
还有一个CMakeFiles 文件夹,里面有很多文件和文件夹
CMakeCCompiler.cmake CMakeOutput.log Makefile.cmake
cmake.check_cache CMakeSystem.cmake progress.marks
CMakeCXXCompiler.cmake CMakeTmp TargetDirectories.txt
CMakeDetermineCompilerABI_C.bin CompilerIdC Tutorial.dir
CMakeDetermineCompilerABI_CXX.bin CompilerIdCXX
CMakeDirectoryInformation.cmake Makefile2
不了解幕后发生的事情(即为什么必须生成文件以及它们的目的是什么)是学习 CMake 的最大障碍。
如果有人知道,请您为后代解释一下吗?这些文件的用途是什么,当我输入cmake .时,cmake在构建项目之前究竟是在配置和生成什么?
【问题讨论】:
-
我知道源代码外的构建。如果有人没有进行源代码构建并且仍在寻找清理生成文件的方法,则此技术效果很好:stackoverflow.com/a/12055610/453673
-
在aosabook.org/en/cmake.html 上有精彩的描述,并且可能对问题进行了深入的回答(此处无法简单概括)。
-
@SebTu 链接断开。 cmake.html 页面不存在。
-
@Nav Yap,搞砸了标记语法,抱歉。因此,这里是更正的版本:对于刚接触 cmake 的人,我真的建议阅读 architecture of cmake。它提供了足够的信息来感受 cmake 的工作原理,而不会失去细节。
标签: cmake