用于蓝牙的Cmake和库链接器标志

时间:2012-06-18 12:18:40

标签: bluetooth cmake

我正在尝试使用CMAKE编译.cpp程序。 当我在终端上使用gcc时,我需要输入:

gcc nxt_bt_connect.c -o nxt_bt_connect -lm -lbluetooth

如何将这两个链接器标志包含在我的CmakeLists.txt(粘贴在下面)文件中?

# YARP needs CMake 2.6 or greater
cmake_minimum_required(VERSION 2.6)
# find YARP
find_package(YARP REQUIRED)
# add YARP include directories
include_directories(${YARP_INCLUDE_DIRS})
# set up our program
add_executable(send_angles send_angles.cpp)
# link with YARP libraries
target_link_libraries(send_angles ${YARP_LIBRARIES})

谢谢!

1 个答案:

答案 0 :(得分:4)

尝试:

set(EXTRA_LIBS ${YARP_LIBRARIES})
list(APPEND EXTRA_LIBS "m")
list(APPEND EXTRA_LIBS "bluetooth")
target_link_libraries(send_angles ${EXTRA_LIBS})

或:

target_link_libraries(send_angles "${YARP_LIBRARIES};m;bluetooth")