cmake編譯多個文件


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)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM