在cmake中包含头文件

use*_*277 5 cmake include

我有一个CMakeList.txt文件,它include(startevn.cmake) 在startevn.cmake中只有一个 线程,我有,

project(startevn)
set(headers 
   startup.h
)
set(sources
  system-init.cpp
)
new_library(startevn ${sources} ${headers})
Run Code Online (Sandbox Code Playgroud)

现在我必须将启动移动到另一个目录.在这之后我将以下行添加到"startevn.cmake",

include_directories("/new_folder_location/sub_folder")
Run Code Online (Sandbox Code Playgroud)

其中sub_folder是startup.h现在所在的位置,但编译器仍然说无法找到源文件:startup.h.我究竟做错了什么?

viv*_*ivi 3

导致之前的代码:

\n\n

new_library(startevn ${sources} ${headers})

\n\n

它确实告诉了图书馆的位置,

\n\n

但之后,你的include_directories()也许就不是了。

\n\n

尝试\xef\xbc\x9a

\n\n
set(INCLUDE_DIR /new_folder_location/sub_folder)\ninclude_directories (${INCLUDE_DIR})     # make sure your .h all inside.\n
Run Code Online (Sandbox Code Playgroud)\n\n

(或者需要先使用cmake的find_library()来检查是否正确找到。)

\n