mirror of https://github.com/labapart/gattlib
Fixed examples linker issue (missing pthread link). Added two cmake-options GATTLIB_BUILD_EXAMPLES and GATTLIB_SHARED_LIB
parent
5b08f051d8
commit
d6a87e47a9
|
@ -27,6 +27,9 @@ include(CrossCompilation.cmake)
|
|||
|
||||
project(gattlib)
|
||||
|
||||
option(GATTLIB_BUILD_EXAMPLES "Build GattLib examples" YES)
|
||||
option(GATTLIB_SHARED_LIB "Build GattLib as a shared library" YES)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
# Show all the warnings
|
||||
|
@ -77,16 +80,18 @@ configure_file(dbus/gattlib.pc.in ${PROJECT_BINARY_DIR}/gattlib.pc @ONLY)
|
|||
# Add the build directory to PKG_CONFIG_PATH
|
||||
set(ENV{PKG_CONFIG_PATH} "${PROJECT_BINARY_DIR}:$ENV{PKG_CONFIG_PATH}")
|
||||
|
||||
# Examples
|
||||
add_subdirectory(examples/ble_scan)
|
||||
add_subdirectory(examples/discover)
|
||||
add_subdirectory(examples/read_write)
|
||||
add_subdirectory(examples/notification)
|
||||
add_subdirectory(examples/nordic_uart)
|
||||
if(GATTLIB_BUILD_EXAMPLES)
|
||||
# Examples
|
||||
add_subdirectory(examples/ble_scan)
|
||||
add_subdirectory(examples/discover)
|
||||
add_subdirectory(examples/read_write)
|
||||
add_subdirectory(examples/notification)
|
||||
add_subdirectory(examples/nordic_uart)
|
||||
|
||||
# Some examples require Bluez code and other DBus support
|
||||
if (NOT GATTLIB_DBUS)
|
||||
add_subdirectory(examples/gatttool)
|
||||
# Some examples require Bluez code and other DBus support
|
||||
if (NOT GATTLIB_DBUS)
|
||||
add_subdirectory(examples/gatttool)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
|
|
|
@ -98,7 +98,12 @@ else()
|
|||
endif()
|
||||
|
||||
# gattlib
|
||||
add_library(gattlib SHARED ${gattlib_SRCS})
|
||||
target_link_libraries(gattlib ${gattlib_LIBS})
|
||||
|
||||
install(TARGETS gattlib LIBRARY DESTINATION lib)
|
||||
if(GATTLIB_SHARED_LIB)
|
||||
add_library(gattlib SHARED ${gattlib_SRCS})
|
||||
target_link_libraries(gattlib ${gattlib_LIBS})
|
||||
|
||||
install(TARGETS gattlib LIBRARY DESTINATION lib)
|
||||
else()
|
||||
add_library(gattlib ${gattlib_SRCS})
|
||||
target_link_libraries(gattlib ${gattlib_LIBS})
|
||||
endif()
|
||||
|
|
|
@ -28,4 +28,4 @@ pkg_search_module(GATTLIB REQUIRED gattlib)
|
|||
set(discover_SRCS discover.c)
|
||||
|
||||
add_executable(discover ${discover_SRCS})
|
||||
target_link_libraries(discover ${GATTLIB_LDFLAGS})
|
||||
target_link_libraries(discover ${GATTLIB_LDFLAGS} pthread)
|
||||
|
|
|
@ -51,4 +51,4 @@ endif()
|
|||
set(gatttool_SRCS gatttool.c interactive.c utils.c)
|
||||
|
||||
add_executable(gatttool ${gatttool_SRCS})
|
||||
target_link_libraries(gatttool ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS} readline)
|
||||
target_link_libraries(gatttool ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS} readline pthread)
|
||||
|
|
|
@ -29,4 +29,4 @@ pkg_search_module(GATTLIB REQUIRED gattlib)
|
|||
set(nordic_uart_SRCS nordic_uart.c)
|
||||
|
||||
add_executable(nordic_uart ${nordic_uart_SRCS})
|
||||
target_link_libraries(nordic_uart ${GATTLIB_LDFLAGS})
|
||||
target_link_libraries(nordic_uart ${GATTLIB_LDFLAGS} pthread)
|
||||
|
|
|
@ -31,4 +31,4 @@ include_directories(${GLIB_INCLUDE_DIRS})
|
|||
set(notification_SRCS notification.c)
|
||||
|
||||
add_executable(notification ${notification_SRCS})
|
||||
target_link_libraries(notification ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS})
|
||||
target_link_libraries(notification ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS} pthread)
|
||||
|
|
|
@ -29,4 +29,4 @@ pkg_search_module(GATTLIB REQUIRED gattlib)
|
|||
set(read_write_SRCS read_write.c)
|
||||
|
||||
add_executable(read_write ${read_write_SRCS})
|
||||
target_link_libraries(read_write ${GATTLIB_LDFLAGS})
|
||||
target_link_libraries(read_write ${GATTLIB_LDFLAGS} pthread)
|
||||
|
|
Loading…
Reference in New Issue