include/xlog.h
#ifndef XLOG_H
#define XLOG_H
void xlog();
#endif
include/xthread.hpp
#ifndef XTHREAD_H
#define XTHREAD_H
void xthread();
#endif
src/xlog.cpp
#include <iostream>
#include "xlog.h"
using namespace std;
void xlog()
{
cout<<" In xlog"<<endl;
}
src/xtest.c
void test()
{
}
xthread.cc
#include <iostream>
using namespace std;
void xthread()
{
cout<<"In xthread"<<endl;
}
根目录下的main.cpp
#include <iostream>
#include "xlog.h"
#include "xthread.hpp"
using namespace std;
int main()
{
xlog();
xthread();
cout<<"test auto source head"<<endl;
return 0;
}
根目录下的CMakeList.txt
#[[
108auto_src_h
CMakeLists.txt
main.cpp
src
xlog.cpp
xthread.cc
xtest.c
include
xlog.h
xthread.hpp
]]
cmake_minimum_required(VERSION 3.20)
project("auto_src_h")
#头文件加载路径
set(INCLUDE_PATH "./include")
include_directories(${INCLUDE_PATH})
# 找到当前目录(.)下源码写入M_SRC变量中
aux_source_directory("." M_SRC)
aux_source_directory("./src" SRC)
#读取所有的头文件
file(GLOB H_FILE "${INCLUDE_PATH}/*.h*")
add_executable(${PROJECT_NAME} ${M_SRC} ${SRC} ${H_FILE})