重新设计了cmake编译过程

This commit is contained in:
jackfiled 2022-04-29 10:37:33 +08:00
parent fa7e3054ff
commit 44fe004f58
7 changed files with 40 additions and 9 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
build/
.vscode/
.vscode/
.idea/

View File

@ -12,5 +12,9 @@ include_directories(
${PROJECT_SOURCE_DIR}/include/
)
add_subdirectory(lib)
#
add_executable(bus src/main.c)
add_executable(bus main.c)
target_link_libraries(bus bus_lib)

11
include/example.h Normal file
View File

@ -0,0 +1,11 @@
//
// Created by ricardo on 2022/4/29.
//
#ifndef AUTO_PILOT_BUS_EXAMPLE_H
#define AUTO_PILOT_BUS_EXAMPLE_H
#include "stdio.h"
void print(char* str);
#endif //AUTO_PILOT_BUS_EXAMPLE_H

5
lib/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
aux_source_directory(. LIB_SRCS)
include_directories(../include)
add_library(bus_lib ${LIB_SRCS})

9
lib/example.c Normal file
View File

@ -0,0 +1,9 @@
//
// Created by ricardo on 2022/4/29.
//
#include "example.h"
void print(char* str)
{
printf("%s", str);
}

8
main.c Normal file
View File

@ -0,0 +1,8 @@
#include "example.h"
int main()
{
char* string = "Good morning!\n";
print(string);
return 0;
}

View File

@ -1,7 +0,0 @@
#include <stdio.h>
int main()
{
printf("good night!\n");
return 0;
}