-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
88 lines (78 loc) · 3.16 KB
/
Copy pathCMakeLists.txt
File metadata and controls
88 lines (78 loc) · 3.16 KB
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
cmake_minimum_required(VERSION 3.16)
project(AgentGATT VERSION 1.0.0 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
option(AGENTGATT_BUILD_TESTS "Build self-contained host tests" OFF)
option(AGENTGATT_USE_NIMBLE "Build against Apache NimBLE (requires NimBLE source)" OFF)
option(AGENTGATT_BUILD_BRIDGE "Build the host-side Central bridge" OFF)
# ---------------------------------------------------------------------------
# Portable core library (no BLE stack dependency).
# ---------------------------------------------------------------------------
add_library(agentgatt-core STATIC
src/agentgatt_core.c
)
target_include_directories(agentgatt-core PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_compile_options(agentgatt-core PRIVATE
-Wall -Wextra -Wpedantic
)
# ---------------------------------------------------------------------------
# Peripheral (device-side) example — only builds with a concrete HAL.
# ---------------------------------------------------------------------------
if(AGENTGATT_USE_NIMBLE)
# Provide your NimBLE include dir + sources below.
if(NOT DEFINED NIMBLE_ROOT)
message(FATAL_ERROR "Set -DNIMBLE_ROOT=/path/to/nimble")
endif()
add_library(agentgatt-nimble-hal STATIC
src/nimble_hal.c
)
target_include_directories(agentgatt-nimble-hal PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${NIMBLE_ROOT}/nimble/include
${NIMBLE_ROOT}/porting
)
add_executable(agentgatt-peripheral examples/example_peripheral.c)
target_link_libraries(agentgatt-peripheral PRIVATE
agentgatt-core
agentgatt-nimble-hal
)
endif()
# ---------------------------------------------------------------------------
# Host-side bridge + BlueZ HAL (GDBus).
# ---------------------------------------------------------------------------
if(AGENTGATT_BUILD_BRIDGE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
add_executable(agentgatt-bridge
src/central_bridge.c
src/host/bluez_hal.c
)
target_include_directories(agentgatt-bridge PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(agentgatt-bridge PRIVATE
agentgatt-core
PkgConfig::GIO
PkgConfig::GLIB
)
find_package(Threads REQUIRED)
target_link_libraries(agentgatt-bridge PRIVATE Threads::Threads)
endif()
# ---------------------------------------------------------------------------
# Tests.
# ---------------------------------------------------------------------------
if(AGENTGATT_BUILD_TESTS)
enable_testing()
find_package(CUnit QUIET)
# Fall back to plain C smoke tests if CUnit is absent.
add_executable(agentgatt-smoke tests/smoke.c)
target_link_libraries(agentgatt-smoke PRIVATE agentgatt-core)
add_test(NAME smoke COMMAND agentgatt-smoke)
# Golden-byte conformance vectors for the wire format.
add_executable(agentgatt-conformance tests/conformance.c)
target_link_libraries(agentgatt-conformance PRIVATE agentgatt-core)
add_test(NAME conformance COMMAND agentgatt-conformance)
endif()