将外部库添加到CMakeList.txt c ++
我有我的外部库,如下图所示,我创建后的符号链接:
和与其他文件中的库相关的标题:
我正在使用ROS ubuntu
,我需要将这些库添加到CmakeList.txt
包中:
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#common commands for building c++ executables and libraries
#rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
#target_link_libraries(${PROJECT_NAME} another_library)
#rosbuild_add_boost_directories()
#rosbuild_link_boost(${PROJECT_NAME} thread)
#rosbuild_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})
rosbuild_add_executable(kinectueye src/kinect_ueye.cpp)
所以我的问题是如何将这些文件夹(我认为我需要添加的第一个文件夹我不确定)添加到CmakeList.txt
文件中,以便我可以在程序中使用类和方法。
我会开始升级CMAKE版本。
您可以将INCLUDE_DIRECTORIES用于标题位置,LINK_DIRECTORIES + TARGET_LINK_LIBRARIES用于库
INCLUDE_DIRECTORIES(your/header/dir)
LINK_DIRECTORIES(your/library/dir)
rosbuild_add_executable(kinectueye src/kinect_ueye.cpp)
TARGET_LINK_LIBRARIES(kinectueye lib1 lib2 lib2 ...)
请注意, lib1
已扩展到liblib1.so
(在Linux上),因此如果您没有它们,请使用ln创建适当的链接
上一篇: Add external libraries to CMakeList.txt c++
下一篇: Unix SSH : Find files with different path on two servers