简单helle目录如下
.
├── CMakeLists.txt
├── hello
│ └── hello.c
└── main.c
main.c
#include "hello//hello.c"
int main() {
print_hello();
return 0;
}
hello.c
#include <stdio.h>
static void print_hello();
void print_hello() {
printf("Hello\n");
}
CMakeLists.txt 默认是设置
cmake_minimum_required(VERSION 3.10)
project(HelloProject C)
include_directories(hello)
add_executable(main main.c hello/hello.c)
CMakeLists.txt 指定编译目录
cmake_minimum_required(VERSION 3.10)
project(HelloProject C)
include_directories(hello)
set(EXECUTABLE_NAME hello_executable)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
add_executable(${EXECUTABLE_NAME} main.c hello/hello.c)
标签:CMakeLists,txt,C99,executable,include,main,hello
From: https://www.cnblogs.com/guanchaoguo/p/17617159.html