xref: /aosp_15_r20/external/pigweed/pw_work_queue/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_library(pw_work_queue STATIC
18  HEADERS
19    public/pw_work_queue/work_queue.h
20  PUBLIC_INCLUDES
21    public
22  PUBLIC_DEPS
23    pw_containers.inline_queue
24    pw_sync.interrupt_spin_lock
25    pw_sync.lock_annotations
26    pw_sync.thread_notification
27    pw_thread.thread
28    pw_function
29    pw_metric
30    pw_span
31    pw_status
32  SOURCES
33    work_queue.cc
34)
35
36pw_add_library(pw_work_queue.test_thread INTERFACE
37  HEADERS
38    public/pw_work_queue/test_thread.h
39  PUBLIC_INCLUDES
40    public
41  PUBLIC_DEPS
42    pw_thread.thread
43)
44
45# To instantiate this test based on a selected thread backend to provide
46# test_thread you can create a pw_add_test which depends on this
47# pw_add_library and a pw_add_library which provides the implementation of
48# test_thread. See pw_work_queue.stl_work_queue_test as an example.
49pw_add_library(pw_work_queue.work_queue_test STATIC
50  SOURCES
51    work_queue_test.cc
52  PRIVATE_DEPS
53    pw_work_queue
54    pw_work_queue.test_thread
55    pw_log
56    pw_unit_test
57)
58
59pw_add_library(pw_work_queue.stl_test_thread STATIC
60  SOURCES
61    stl_test_thread.cc
62  PRIVATE_DEPS
63    pw_work_queue.test_thread
64    pw_thread.thread
65    pw_thread_stl.thread
66)
67
68if("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread")
69  pw_add_test(pw_work_queue.stl_work_queue_test
70    PRIVATE_DEPS
71      pw_work_queue.stl_test_thread
72      pw_work_queue.work_queue_test
73    GROUPS
74      modules
75      pw_work_queue
76  )
77endif()
78