我有库,AprilTags,它使用cmake top构建它。
我有另一个使用AprilTags的项目AIV。我想将apriltags库保留在〜/ aiv / apriltags中,但是有另一个文件,front_back_camera_demo,它使用了AprilTags库中的一些文件。
所以文件结构看起来像
~/aiv/build/
/apriltags/CMakeLists.txt
/apriltags/AprilTags/TagDetector.h
/apriltags/AprilTags/*.h
/front_back_camera_demo.cpp
/CMakeLists.txt
当我在顶级CMakeLists.txt上运行cmake时,它成功构建了AprilTags库,但后来我得到了
front_back_camera_demo.cpp:72:35:致命错误:AprilTags / TagDetector.h:没有这样的文件或目录
包含AprilTags / TagDetector.h
的行上的错误以下是两个相关的CMakeLists.txt:
顶级:
cmake_minimum_required(VERSION 2.6)
project(AIV)
add_subdirectory(apriltags)
add_executable(front_back_camera_demo front_back_camera_demo.cpp
Serial.cpp)
target_link_libraries(front_back_camera_demo apriltags)
in apriltags:
cmake_minimum_required(VERSION 2.6)
project(apriltags)
#add_definitions(-pg) #"-fopenmp)
# pull in the pods macros. See cmake/pods.cmake for documentation
set(POD_NAME apriltags)
include(cmake/pods.cmake)
file(GLOB SOURCE_FILES "src/*.cc")
include_directories(AprilTags . /opt/local/include)
add_library(apriltags ${SOURCE_FILES})
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(apriltags ${OpenCV_LIBS}) #-pg) #-fopenmp)
pods_use_pkg_config_packages(apriltags eigen3)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(apriltags -L/opt/local/lib/) # MacPorts
special treatment...
else (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
pods_use_pkg_config_packages(apriltags libv4l2)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
pods_install_libraries(apriltags)
file(GLOB header_files "AprilTags/*.h")
pods_install_headers(${header_files} DESTINATION AprilTags/)
pods_install_pkg_config_file(apriltags
LIBS -lapriltags
REQUIRES eigen3 opencv2
VERSION 1.0.0)
add_subdirectory(example)
我做错了什么?
答案 0 :(得分:0)
首选target_*
命令。
apriltags /的CMakeLists.txt:
target_include_directories(apriltags
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/AprilTags"
/opt/local/include)
也就是说,使用apriltags
目标的所有内容都可以访问"。"中的任何内容,apriltags
也可以使用"。&# 34;只有apriltags
本身使用" AprilTags"和" / opt / local / include"目录。
如果你真的知道自己在做什么,可以通过使用生成器表达式来获得更细粒度的效果,但这并不是必须让它工作。