aboutsummaryrefslogtreecommitdiffstats
path: root/src/CMakeLists.txt
blob: 201d8baada07d1d62214a0744478de39ad805bcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
set (tinyb_LIB_INCLUDE_DIRS
  ${PROJECT_SOURCE_DIR}/api
  ${PROJECT_SOURCE_DIR}/api/tinyb
  ${PROJECT_SOURCE_DIR}/include
)

include_directories(
  ${tinyb_LIB_INCLUDE_DIRS}
  ${GLIB2_INCLUDE_DIRS}
  ${GIO_INCLUDE_DIRS}
  ${GIO-UNIX_INCLUDE_DIRS}
  ${CMAKE_CURRENT_BINARY_DIR}
)

set (tinyb_LIB_SRCS
  ${PROJECT_SOURCE_DIR}/src/BluetoothObject.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothEvent.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothManager.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothAdapter.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothDevice.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothGattService.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothGattCharacteristic.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothGattDescriptor.cpp
  ${PROJECT_SOURCE_DIR}/src/BluetoothUUID.cpp
  ${PROJECT_SOURCE_DIR}/src/tinyb_utils.cpp
# autogenerated files
  ${CMAKE_CURRENT_BINARY_DIR}/version.c
  ${CMAKE_CURRENT_BINARY_DIR}/orgbluez-dbus.c
)

set (tinyb_LIB_GLOB_HEADERS
  ${PROJECT_SOURCE_DIR}/api/tinyb.hpp
)

find_program(GDBUS_CODEGEN NAMES gdbus-codegen)
if (NOT GDBUS_CODEGEN)
  message(FATAL_ERROR "gdbus-codegen not found")
else ()
  message(STATUS "gdbus-codegen found")
endif ()

add_custom_command(OUTPUT orgbluez-dbus.c orgbluez-dbus.h
  COMMAND ${GDBUS_CODEGEN} 
    --interface-prefix org.bluez 
    --generate-c-code orgbluez-dbus 
    --c-generate-object-manager ${PROJECT_SOURCE_DIR}/src/org.bluez.xml
  COMMENT "Generating dbus code from org.bluez.xml")

add_library (tinyb SHARED ${tinyb_LIB_SRCS})
target_link_libraries (
  tinyb
  ${CMAKE_THREAD_LIBS_INIT}
  ${GLIB2_LIBRARIES}
  ${GIO_LIBRARIES}
)

set_target_properties(
   tinyb
   PROPERTIES
   SOVERSION ${tinyb_VERSION_MAJOR}
   VERSION ${tinyb_VERSION_STRING}
   CXX_STANDARD 11
)
install (FILES ${tinyb_LIB_GLOB_HEADERS} DESTINATION include/)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/api/tinyb/ DESTINATION include/tinyb)

macro (tinyb_CREATE_INSTALL_PKGCONFIG generated_file install_location)
  configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
  install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endmacro (tinyb_CREATE_INSTALL_PKGCONFIG)
tinyb_create_install_pkgconfig (tinyb.pc lib${LIB_SUFFIX}/pkgconfig)

install(TARGETS tinyb LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})