#Linux脚本#如何写第一个CMakeLists.txt文件

2026-03-06 12:19:33

1、编写进程的源文件

注:方便演示,写了一个hello,world程序。

#Linux脚本#如何写第一个CMakeLists.txt文件

#Linux脚本#如何写第一个CMakeLists.txt文件

2、创建CMakeLists.txt文件

注:touch,vi 命令,都可以创建文件。

#Linux脚本#如何写第一个CMakeLists.txt文件

3、指定cmake的最低版本

注:此为第一条命令。使用cmake --version,可以查询本机的cmake版本。

#Linux脚本#如何写第一个CMakeLists.txt文件

#Linux脚本#如何写第一个CMakeLists.txt文件

4、指定需要编译的源文件(.cpp)的目录

注:.(圆点)代表根目录

#Linux脚本#如何写第一个CMakeLists.txt文件

5、指定需要包含的头文件(.h)的目录

注:相当于windows下VS中的"附加包含目录"。

#Linux脚本#如何写第一个CMakeLists.txt文件

6、指定生成的可执行文件

注:此命令用于,生成可执行文件。

#Linux脚本#如何写第一个CMakeLists.txt文件

7、生成Makefile文件

注:规则由CMakeLists.txt定义的。

#Linux脚本#如何写第一个CMakeLists.txt文件

8、生成二进制文件

注:make命令,用于编译。

#Linux脚本#如何写第一个CMakeLists.txt文件

9、运行

#Linux脚本#如何写第一个CMakeLists.txt文件

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢