CMake实战(一)

https://cmake.org/cmake/help/v3.19/manual/cmake-commands.7.html

    前面我们介绍过Autotools的使用,今天来看看CMake的使用方法。CMake和Autotools一样,都是项目构建工具。可以简单理解为,帮助我们生成Makefile,方便编译。

使用实例

(1) 创建main.c/hello.c/hello.h文件,内容如下:

//hello.c#include<stdio.h>#include "hello.h"
int printHello(void){
  
   
       printf("Hello,World\n");}

//hello.h#ifndef _HELLO_H#define _HELLO_H
int printHello(void);
#endif

//main.c#include<stdio.h>#include "hello.h"
int main(void){
  
   
       printHello();    return 0;}

猜你喜欢

转载自blog.csdn.net/weixin_54707168/article/details/120624698