Arc*_*chy 12 c++ header path cmake include
我正在尝试使用CMake来构建我的C++项目,我在标题路径中遇到了问题.
由于我在很多目录中使用了很多类,所有我的include语句都是绝对路径(因此不需要使用"../../")但是当尝试制作CMake生成的Makefile时它只是没有不行.
有谁知道如何在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/
)
Run Code Online (Sandbox Code Playgroud)
fsc*_*itt 15
你需要在CMakeLists.txt中这样的东西:
SET(BASEPATH "${CMAKE_SOURCE_DIR}")
INCLUDE_DIRECTORIES("${BASEPATH}")
Run Code Online (Sandbox Code Playgroud)
设置正确的包含路径:假设你的Utils目录在/ exp/appstat/benbou/multiboost中,那么cmake(实际上,gcc)必须知道这个:
include_directories( /exp/appstat/benbou/multiboost )
Run Code Online (Sandbox Code Playgroud)
或者将它作为在命令行传递的选项传递可能更方便:
include_directories( ${MyProjectRoot} )
cmake -DMyProjectRoot=/exp/appstat/benbou/multiboost
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11873 次 |
| 最近记录: |