Cmake简单使用记录
配置环境是ubuntu14.04
第一次使用cmake进行编译
- 新建一个cmakelists.txt文件
- 打开终端运行cmake . (此处空格很重要)
cmake .
- 伴随产生很多文件,例如cmake.check_cache 、 makefile.cmake等等
- 继续运行make
make
6.新建任务,此处任务是在cmakelist.txt中你写进去的任务名字,假设为hello
7.对hello文件进行编译
./hello
8.完成输出
出现的问题
- 我是在/home/rootname下直接建立的cmakelists.txt文件,用C++编写的cpp文件也要在同一个目录下,否则找不到可编译的文件
Cannot find source file:
- 文件名字一定要命名为cmakelists.txt,(我一度写成cmakelist.txt),会报错。
CMake Error: The source directory "/home/rootname" does not appear to contain CMakeLists.txt.