2013-07-18 56 views
4

头文件我有只有一个衬垫 include(startevn.cmake) 在startevn.cmake我有一个CMakeList.txt文件,包括cmake的

project(startevn) 
set(headers 
    startup.h 
) 
set(sources 
    system-init.cpp 
) 
new_library(startevn ${sources} ${headers}) 

现在我必须启动移动到不同的目录中。 startup.h:这样做,我添加 以下行“startevn.cmake”,

include_directories("/new_folder_location/sub_folder") 

其中sub_folder就是startup.h现在位于但是编译器仍然说 找不到源文件之后。 我在做什么错?

+0

你真的意味着 “/ new_folder_location/sub_folder”?这是一条绝对的道路。要给出相对路径,请删除前导“/”。 – Fraser

+0

是的,这是一条绝对路径。 – user1566277

+0

应该工作。您是否尝试过运行'make VERBOSE = 1'来查看实际的编译器命令?你应该在里面有'-I/new_folder_location/sub_folder'这样的东西。 – Fraser

回答

2

原因之前代码:

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

它没有告诉图书馆的位置,

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

尝试:

set(INCLUDE_DIR /new_folder_location/sub_folder) 
include_directories (${INCLUDE_DIR})  # make sure your .h all inside. 

(或需要使用find_library()cmake的前检查它是否是正确找到)