這是我的工作目錄:設置cmakelist正確地編制項目
app
|___include
|___file1.h
|___file2.h
|___file3.h
!___ ...
|___src
|___file1.c
|___file2.c
|___file3.c
|___ ...
|__CMakeLists.txt
|__mainapp.c
這是我CMakeLists.txt
:
cmake_minimum_required(VERSION 3.5.1)
project(app)
include_directories(include)
file(GLOB SOURCES src/*.c)
add_executable(file3 src/file3.c)
target_link_libraries(file3 m ${SOURCES})
然後我執行以下操作:
$cmake .
$make
但我收到錯誤:
[ 50%] Building C object CMakeFiles/file3.dir/src/file3.c.o
[100%] Linking C executable file3
src/file3.c:1:19: fatal error: file1.h: File does not exist
哪裏file3.c
就是:
#include "file1.h"
#include "file2.h"
int foo3(int a, int b){
return foo1(a,b) + foo2(a,b);
}
如何設置CMakeLists是否正確?