一个最最最简单的cmake工程

1. 工程目录树如下:

 

 注意cmake为空文件夹。

2. 写CMakeLists.txt

1 cmake_minimum_required(VERSION 2.6)
2 SET(CMAKE_C_COMPILER "E:/MinGW-W64/mingw64/bin/gcc.exe")
3 project(print_test)
4 add_executable(helloworld_print test.c)

3. 写个test.c

1 #include "stdio.h"
2 int main()
3 {
4     puts("Hello, world!");
5     return 0;
6 }

4. cd cmake

5. 终端运行如下命令:

cmake -G "MinGW Makefiles" ..

6. 终端运行如下命令:

make

7.结果出来,success!!!!!

 

posted @ 2022-04-01 15:12  昆山皮皮虾  阅读(85)  评论(0编辑  收藏  举报