我一直在谷歌搜索了一段時間,我沒有結果,所以我轉向你們^^ 我想使用CMake來構建我的C++項目,我有一個問題在標題路徑。因爲我使用了很多在幾個目錄中組織的類,所有我的include語句都使用絕對路徑(所以不需要使用「../../」),但是當嘗試使用CMake生成的時候Makefile它不起作用。CMake和絕對標題路徑
有誰知道如何在CMakeLists.txt中指定所有包含都是絕對路徑? 非常感謝。
我試圖讓
~/multiboost/BanditsLS/GenericBanditAlgorithmLS.h:45:25: Utils/Utils.h: No such file or directory
~/multiboost/BanditsLS/GenericBanditAlgorithmLS.h:46:35: Utils/StreamTokenizer.h: No such file or directory
我的CMakeLists.txt文件時輸出:
#The following command allows the use of the "file" command
cmake_minimum_required(VERSION 2.6)
#The declaration of the project
project(multiboost)
#This allows recursive parsing of the source files
file(
GLOB_RECURSE
source_files
*
)
list(REMOVE_ITEM source_files ./build/*)
#This indicates the target (the executable)
add_executable(
multiboost
${source_files} #EXCLUDE_FROM_ALL build/
)
可以prvodie一個小例子(源/頭/ cmake)?另外,絕對路徑通常是一個壞主意。做這件事最好的方法是使用boost來實現它:在編譯器的include路徑中指定一個單根,並從那裏開始。 – stijn 2010-09-28 07:53:17
是的,這就是我所做的:假設我有一個src/dir,其中包含源代碼的所有子代以及主文件。在我所有的include語句中,我只需要指定src /的路徑。 在我的XCode項目中,它工作正常,但我還沒有弄清楚如何在CMake中製作它。 (感謝您的回答; o)) – Archy 2010-09-28 07:55:44
是的,但我們仍然需要一個例子+更多信息('它只是不工作'是一樣神祕的錯誤描述可以得到,並沒有告訴我們任何事情) – stijn 2010-09-28 07:58:21