2012-06-18 29 views
2

我想用CMAKE編譯一個.cpp程序。 當我簡單地用對終端的gcc我需要鍵入:用於藍牙的Cmake和庫鏈接器標誌

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}) 

謝謝!

回答

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") 
+0

偉大的!第一個選項適用於:-D – mafalda

+1

@mafalda,因爲您發現Doug的答案有用,您應該'接受'它。 – Peter