新建两个文件

CMakeLists.txt中写入
cmake_minimum_required (VERSION 2.8)
project (hello)
add_executable(hello hello.c)
详细可进https://blog.youkuaiyun.com/weixin_43708622/article/details/108155521?
下一步 "cmake ."通过cmake来生成Makefile
最后"make"执行make进行编译
多个源文件时可参考以下写法
#CMake 最低版本号要求
cmake_minimum_required (VERSION 2.8)
#项目信息
project (sum_sub_test)
#查找当前目录下的所有源文件将名称保存到 SRC_LIST变量
aux_source_directory(. SRC_LIST)
#指定生成目标
add_executable(sum_sub_test ${SRC_LIST})
该文指导如何创建CMakeLists.txt文件,配置项目如hello,添加源文件并使用cmake生成Makefile,然后通过make命令编译项目。当有多个源文件时,展示了如何使用aux_source_directory辅助函数处理。
3770

被折叠的 条评论
为什么被折叠?



