2013-07-18 60 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的前檢查它是否是正確找到)