-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
120 lines (93 loc) · 3.36 KB
/
CMakeLists.txt
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# SPDX-License-Identifier: MIT
# Copyright © 2023 Lesosoftware https://github.com/leso-kn.
#
# pebble-le - Main CMake build file.
#
cmake_minimum_required(VERSION 3.0)
project(pebble-le VERSION 0.3.0)
# Build Options
option(BUILD_UNIT_TESTS "Enable unit tests" OFF)
option(PEBBLE_LE_BUILD_EXAMPLE "Build example program" ON)
# Sources
set(pebble_le_SOURCES
src/pebble-le.cpp
src/pebble-proto.cpp
src/gatt-client.cpp
src/gatt-server.cpp
src/util.cpp)
# Third-Party Dependencies
add_subdirectory(third_party/SimpleBLE/simpleble EXCLUDE_FROM_ALL)
add_subdirectory(third_party/binc/binc)
set(SimpleBLE_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/third_party/SimpleBLE/simpleble/include
${CMAKE_SOURCE_DIR}/third_party/SimpleBLE/simplebluez/include
${CMAKE_SOURCE_DIR}/third_party/SimpleBLE/simpledbus/include
${CMAKE_BINARY_DIR}/third_party/SimpleBLE/simpleble/export)
set(Binc_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/third_party/binc)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_search_module(GIO REQUIRED gio-2.0)
pkg_search_module(DBus1 REQUIRED dbus-1)
# libpebble-le
add_library(pebble-le_o OBJECT ${pebble_le_SOURCES})
add_library(pebble-le SHARED)
add_library(pebble-le_static STATIC)
target_link_libraries(pebble-le pebble-le_o)
target_link_libraries(pebble-le_static pebble-le_o)
set_target_properties(pebble-le PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
set_target_properties(pebble-le_static PROPERTIES
OUTPUT_NAME pebble-le)
target_include_directories(pebble-le_o PRIVATE ${Binc_INCLUDE_DIRS} ${SimpleBLE_INCLUDE_DIRS} ${DBus1_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS})
target_include_directories(pebble-le_o PUBLIC include ${CMAKE_BINARY_DIR}/exports)
target_link_libraries(pebble-le_o PUBLIC
Binc
simpleble
${DBus1_LIBRARIES}
${GLIB_LIBRARIES}
${GIO_LIBRARIES})
include(GenerateExportHeader)
generate_export_header(pebble-le_o
EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/pebble-le-config.h
BASE_NAME PEBBLE_LE)
set_property(TARGET pebble-le_o PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET Binc PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(Binc PRIVATE ${GLIB_INCLUDE_DIRS})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pebble-le.pc.in
${CMAKE_CURRENT_BINARY_DIR}/pebble-le.pc @ONLY)
if (PEBBLE_LE_BUILD_EXAMPLE)
add_subdirectory(example)
endif()
install(
TARGETS pebble-le
EXPORT pebble-le-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(
TARGETS pebble-le_static
EXPORT pebble-le-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/pebble-le/ ${CMAKE_BINARY_DIR}/exports/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pebble-le)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/pebble-le.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(
FILES src/dbus-policy.conf
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/dbus-1/system.d
RENAME pebble-le.conf)
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
VERBATIM)
install(
DIRECTORY docs/man
DESTINATION ${CMAKE_INSTALL_PREFIX}/share)
endif (DOXYGEN_FOUND)