xref: /aosp_15_r20/external/pigweed/pw_bluetooth/CMakeLists.txt (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2022 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
16
17pw_add_module_config(pw_bluetooth_CONFIG)
18
19pw_add_library(pw_bluetooth.config INTERFACE
20  HEADERS
21    public/pw_bluetooth/config.h
22  PUBLIC_INCLUDES
23    public
24  PUBLIC_DEPS
25    ${pw_bluetooth_CONFIG}
26)
27
28pw_add_library(pw_bluetooth INTERFACE
29  HEADERS
30    public/pw_bluetooth/address.h
31    public/pw_bluetooth/assigned_uuids.h
32    public/pw_bluetooth/gatt/client.h
33    public/pw_bluetooth/gatt/constants.h
34    public/pw_bluetooth/gatt/error.h
35    public/pw_bluetooth/gatt/server.h
36    public/pw_bluetooth/gatt/types.h
37    public/pw_bluetooth/internal/hex.h
38    public/pw_bluetooth/internal/raii_ptr.h
39    public/pw_bluetooth/low_energy/advertising_data.h
40    public/pw_bluetooth/low_energy/bond_data.h
41    public/pw_bluetooth/low_energy/central.h
42    public/pw_bluetooth/low_energy/connection.h
43    public/pw_bluetooth/low_energy/peripheral.h
44    public/pw_bluetooth/low_energy/security_mode.h
45    public/pw_bluetooth/constants.h
46    public/pw_bluetooth/controller.h
47    public/pw_bluetooth/host.h
48    public/pw_bluetooth/pairing_delegate.h
49    public/pw_bluetooth/peer.h
50    public/pw_bluetooth/result.h
51    public/pw_bluetooth/types.h
52    public/pw_bluetooth/uuid.h
53    public/pw_bluetooth/vendor.h
54  PUBLIC_INCLUDES
55    public
56  PUBLIC_DEPS
57    pw_containers
58    pw_function
59    pw_multibuf
60    pw_status
61    pw_string.string
62    pw_chrono.system_clock
63)
64
65pw_add_library(pw_bluetooth.pw_bluetooth2 INTERFACE
66  HEADERS
67    public/pw_bluetooth/address.h
68    public/pw_bluetooth/assigned_uuids.h
69    public/pw_bluetooth/constants.h
70    public/pw_bluetooth/config.h
71    public/pw_bluetooth/controller2.h
72    public/pw_bluetooth/gatt/client2.h
73    public/pw_bluetooth/gatt/constants.h
74    public/pw_bluetooth/gatt/error.h
75    public/pw_bluetooth/gatt/server2.h
76    public/pw_bluetooth/gatt/types.h
77    public/pw_bluetooth/internal/hex.h
78    public/pw_bluetooth/internal/raii_ptr.h
79    public/pw_bluetooth/low_energy/advertising_data.h
80    public/pw_bluetooth/low_energy/bond_data2.h
81    public/pw_bluetooth/low_energy/central2.h
82    public/pw_bluetooth/low_energy/channel.h
83    public/pw_bluetooth/low_energy/connection2.h
84    public/pw_bluetooth/low_energy/peripheral2.h
85    public/pw_bluetooth/low_energy/security_mode.h
86    public/pw_bluetooth/pairing_delegate2.h
87    public/pw_bluetooth/peer.h
88    public/pw_bluetooth/types.h
89    public/pw_bluetooth/uuid.h
90    public/pw_bluetooth/vendor.h
91  PUBLIC_INCLUDES
92    public
93  PUBLIC_DEPS
94    pw_bluetooth.config
95    pw_async2.dispatcher
96    pw_async2.once_sender
97    pw_result.expected
98    pw_channel
99    pw_containers
100    pw_function
101    pw_multibuf
102    pw_result
103    pw_span
104    pw_status
105)
106
107
108pw_add_library(pw_bluetooth.emboss_util INTERFACE
109  HEADERS
110    public/pw_bluetooth/emboss_util.h
111  PUBLIC_INCLUDES
112    public
113  PUBLIC_DEPS
114    pw_result
115    pw_span
116    pw_status
117)
118
119pw_add_test(pw_bluetooth.address_test
120  SOURCES
121    address_test.cc
122  PRIVATE_DEPS
123    pw_bluetooth
124  GROUPS
125    modules
126)
127
128pw_add_test(pw_bluetooth.api_test
129  SOURCES
130    api_test.cc
131  PRIVATE_DEPS
132    pw_bluetooth
133  GROUPS
134    modules
135)
136
137pw_add_test(pw_bluetooth.api2_test
138  SOURCES
139    api2_test.cc
140  PRIVATE_DEPS
141    pw_bluetooth.pw_bluetooth2
142  GROUPS
143    modules
144)
145
146pw_add_test(pw_bluetooth.result_test
147  SOURCES
148    result_test.cc
149  PRIVATE_DEPS
150    pw_bluetooth
151  GROUPS
152    modules
153)
154
155pw_add_test(pw_bluetooth.uuid_test
156  SOURCES
157    uuid_test.cc
158  PRIVATE_DEPS
159    pw_bluetooth
160  GROUPS
161    modules
162)
163
164###############################################################################
165##          Everything below here is intended to be emboss only              ##
166##          and will be skipped if emboss isn't enabled.                     ##
167###############################################################################
168if("${dir_pw_third_party_emboss}" STREQUAL "")
169  # Skip emboss defs if it's not configured
170  return()
171endif()
172
173include($ENV{PW_ROOT}/third_party/emboss/emboss.cmake)
174
175emboss_cc_library(pw_bluetooth.emboss_hci_common
176  SOURCES
177    public/pw_bluetooth/hci_common.emb
178)
179
180emboss_cc_library(pw_bluetooth.emboss_hci_android
181  SOURCES
182    public/pw_bluetooth/hci_android.emb
183  IMPORT_DIRS
184    public
185  DEPS
186    pw_bluetooth.emboss_hci_common
187)
188
189emboss_cc_library(pw_bluetooth.emboss_hci_commands
190  SOURCES
191    public/pw_bluetooth/hci_commands.emb
192  IMPORT_DIRS
193    public
194  DEPS
195    pw_bluetooth.emboss_hci_common
196)
197
198emboss_cc_library(pw_bluetooth.emboss_hci_events
199  SOURCES
200    public/pw_bluetooth/hci_events.emb
201  IMPORT_DIRS
202    public
203  DEPS
204    pw_bluetooth.emboss_hci_common
205)
206
207emboss_cc_library(pw_bluetooth.emboss_hci_h4
208  SOURCES
209    public/pw_bluetooth/hci_h4.emb
210  IMPORT_DIRS
211    public
212)
213
214emboss_cc_library(pw_bluetooth.emboss_hci_data
215  SOURCES
216    public/pw_bluetooth/hci_data.emb
217)
218
219emboss_cc_library(pw_bluetooth.emboss_l2cap_frames
220  SOURCES
221    public/pw_bluetooth/l2cap_frames.emb
222)
223
224emboss_cc_library(pw_bluetooth.emboss_rfcomm_frames
225  SOURCES
226    public/pw_bluetooth/rfcomm_frames.emb
227)
228
229emboss_cc_library(pw_bluetooth.emboss_att
230  SOURCES
231    public/pw_bluetooth/att.emb
232  IMPORT_DIRS
233    public
234  DEPS
235    pw_bluetooth.emboss_hci_data
236    pw_bluetooth.emboss_l2cap_frames
237)
238
239emboss_cc_library(pw_bluetooth.emboss_hci_test
240  SOURCES
241    public/pw_bluetooth/hci_test.emb
242  IMPORT_DIRS
243    public
244  DEPS
245    pw_bluetooth.emboss_hci_common
246    pw_bluetooth.emboss_l2cap_frames
247)
248
249pw_add_library("pw_bluetooth.emboss_hci_group" INTERFACE
250  PUBLIC_DEPS
251    pw_bluetooth.emboss_hci_android
252    pw_bluetooth.emboss_hci_commands
253    pw_bluetooth.emboss_hci_common
254    pw_bluetooth.emboss_hci_data
255    pw_bluetooth.emboss_hci_events
256    pw_bluetooth.emboss_hci_h4
257)
258
259pw_target_link_targets("pw_bluetooth._public_config"
260  INTERFACE
261    pw_bluetooth.emboss_att
262    pw_bluetooth.emboss_hci_android
263    pw_bluetooth.emboss_hci_commands
264    pw_bluetooth.emboss_hci_common
265    pw_bluetooth.emboss_hci_data
266    pw_bluetooth.emboss_hci_events
267    pw_bluetooth.emboss_hci_h4
268    pw_bluetooth.emboss_l2cap_frames
269    pw_bluetooth.emboss_rfcomm_frames
270)
271
272pw_add_test(pw_bluetooth.emboss_test
273  SOURCES
274    emboss_test.cc
275  PRIVATE_DEPS
276
277    # All emboss targets are listed (even if they don't have explicit tests) to
278    # ensure they are compiled.
279    pw_bluetooth.emboss_att
280    pw_bluetooth.emboss_hci_group
281    pw_bluetooth.emboss_hci_test
282    pw_bluetooth.emboss_l2cap_frames
283    pw_bluetooth.emboss_rfcomm_frames
284    pw_third_party.fuchsia.stdcompat
285  GROUPS
286    modules
287)
288
289pw_add_test(pw_bluetooth.emboss_util_test
290  SOURCES
291    emboss_util_test.cc
292  PRIVATE_DEPS
293    pw_bluetooth.emboss_hci_test
294    pw_bluetooth.emboss_util
295  GROUPS
296    modules
297)
298