CMake - Compile file in C using object file

0

Hello,

I have a very general question:

Assuming I create the main.c , list.c and list.h files. And you want to create the list.c object file, which contains the helper functions I will use in main.c whose signatures are in the header list.h . How would I do this through CMake?

main.c

#include "lista.h"

int main() {
    HelloWorld();

    return 0;
}

lista.c

#include <stdio.h>

void HelloWorld() {
    printf("Hello World!\n");
}

list.h

#ifndef LISTA_H
#define LISTA_H

void HelloWorld();

#endif // LISTA_H

In GCC, I would first compile the list.c :

gcc -c lista.c

And then with the object file " .o " I would generate the executable:

gcc main.c lista.o -o teste

What would generate the test executable file.

I ask this because I want to do larger projects with the headers and the source code separated folders and wanted to automate the process in an efficient way. I want to keep the source code secrecy of my functions ( lista.c ).

    
asked by anonymous 22.04.2018 / 06:52

0 answers