mafalda
mafalda

Reputation: 147

Cmake and library linker flags for bluetooth

I am trying to compile a .cpp program with CMAKE. When I was simply using gcc on terminal I needed to type:

gcc nxt_bt_connect.c -o nxt_bt_connect -lm -lbluetooth

How do I include these two linker flags to my CmakeLists.txt (pasted below) file?

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

Thank you!!

Upvotes: 3

Views: 2443

Answers (1)

Doug
Doug

Reputation: 35186

try:

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

or:

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

Upvotes: 5

Related Questions