首页 > 其他 > 详细

cmake编译多个文件

时间:2020-02-07 00:57:52      阅读:83      评论:0      收藏:0      [点我收藏+]

demo.h

#ifndef UNTITLED_HEADER_DEMO_H
#define UNTITLED_HEADER_DEMO_H

void printHello(char *name);

#endif //UNTITLED_HEADER_DEMO_H

demo.c

//
// Created by gxf on 2020/2/6.
//
#include <stdio.h>

#include "header-demo.h"

void printHello(char *name) {
    printf("hello %s\n", name);
}

main.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "header-demo.h"

int main() {
    char *name = "guanxianseng";
    printHello(name);

    return 0;
}

cmakelist.txt

# main.c
add_executable(main main.c header-demo.h header-demo.c)

  

cmake编译多个文件

原文:https://www.cnblogs.com/luckygxf/p/12271240.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!