cmake包括来自其他目录的h个文件 [英] cmake including h files from other directories
问题描述
我遇到了麻烦,包括在cmake项目下的测试。我的项目是这样:
I am having trouble including a test under a cmake project. My project is set out like this:
TerrainMap
/ \
PointAccumulator heightQuadGrid
\
Test
在TerrainMap目录中,CMakeLists.txt文件简单概述了cmake版本项目名称并包括两个子目录。
In the TerrainMap Directory the CMakeLists.txt file simply outlines the cmake version the project name and includes the two sub directories.
在heightQuadGrid中,CMakeLists.txt如下所示:
In heightQuadGrid the CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 2.8)
find_package(PCL 1.2 REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_library(heightQuadGrid heightQuadGrid.cpp)
add_subdirectory(Test)
根据我的理解,使一个名为heightQuadGrid的库。测试中的CMakeLists.txt如下所示:
which as I understand makes a library called heightQuadGrid. The CMakeLists.txt in Test looks like this:
FIND_PACKAGE(PCL 1.2 REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED)
FIND_PACKAGE(Boost COMPONENTS unit_test_framework REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS} )
link_libraries(heightQuadGrid)
add_executable(heightQuadTreeTest heightQuadGridTest.cpp)
target_link_libraries (heightQuadTreeTest heightQuadGrid ${PCL_LIBRARIES} ${OpenCV_LIBS} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
最后,cpp文件heightQuadGridTest.cpp包含:
And finally the cpp file heightQuadGridTest.cpp has this include:
#include <heightQuadGrid/heightQuadGrid.h>
cmake工作正常,但是当我去做项目时,它告诉我它找不到heightQuadGrid /
The cmake works correctly but when i go to make the project it tells me that it cannot find heightQuadGrid/heightQuadGrid.h
推荐答案
在另一个工作项目中,解决方案
#include <heightQuadGrid/heightQuadGrid.h>
此语法指示项目的include目录之一应为 heightQuadGrid
dir。在 heightQuadTreeTest
可执行文件的cmakelists.txt文件中,您需要向上移动两个目录,并将其添加为include目录:
This syntax indicates that one of the "include directories" for the project should be the directory above the heightQuadGrid
dir. In the cmakelists.txt file for the heightQuadTreeTest
executable, you need to go up two directories, and add that as an include directory:
include_directories(../../)
这篇关于cmake包括来自其他目录的h个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!