cmake: Extends and fixes CMake support to several modules
The future addition of pw_target_link_targets exposed several
CMake build issues in Pigweed. This change adds CMake support to
pw_work_queue and pw_metric and fixes build rules from several
other modules.
Bug: 246101669
Change-Id: I5794e6d7cbc25ad3a094b1631abf9df01729afd6
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/109951
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d4cf398..acc8db0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,6 +69,7 @@
add_subdirectory(pw_log_tokenized EXCLUDE_FROM_ALL)
add_subdirectory(pw_log_zephyr EXCLUDE_FROM_ALL)
add_subdirectory(pw_minimal_cpp_stdlib EXCLUDE_FROM_ALL)
+add_subdirectory(pw_metric EXCLUDE_FROM_ALL)
add_subdirectory(pw_multisink EXCLUDE_FROM_ALL)
add_subdirectory(pw_persistent_ram EXCLUDE_FROM_ALL)
add_subdirectory(pw_polyfill EXCLUDE_FROM_ALL)
@@ -103,6 +104,7 @@
add_subdirectory(pw_transfer EXCLUDE_FROM_ALL)
add_subdirectory(pw_unit_test EXCLUDE_FROM_ALL)
add_subdirectory(pw_varint EXCLUDE_FROM_ALL)
+add_subdirectory(pw_work_queue EXCLUDE_FROM_ALL)
add_subdirectory(third_party/nanopb EXCLUDE_FROM_ALL)
add_subdirectory(third_party/freertos EXCLUDE_FROM_ALL)
diff --git a/pw_assert_basic/CMakeLists.txt b/pw_assert_basic/CMakeLists.txt
index d2d6936..362f0b8 100644
--- a/pw_assert_basic/CMakeLists.txt
+++ b/pw_assert_basic/CMakeLists.txt
@@ -49,6 +49,6 @@
pw_assert_basic.handler.facade
pw_assert.config
pw_preprocessor
- pw_string.string_builder
+ pw_string.builder
pw_sys_io
)
diff --git a/pw_file/CMakeLists.txt b/pw_file/CMakeLists.txt
index 30c9359..bcdbb50 100644
--- a/pw_file/CMakeLists.txt
+++ b/pw_file/CMakeLists.txt
@@ -24,7 +24,7 @@
pw_log
pw_result
pw_status
- TEST_DEPS
+ PRIVATE_DEPS
pw_rpc.test_utils
)
diff --git a/pw_metric/CMakeLists.txt b/pw_metric/CMakeLists.txt
new file mode 100644
index 0000000..34f7597
--- /dev/null
+++ b/pw_metric/CMakeLists.txt
@@ -0,0 +1,64 @@
+# Copyright 2022 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
+
+pw_add_module_library(pw_metric
+ HEADERS
+ public/pw_metric/metric.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_tokenizer.base64
+ pw_assert
+ pw_containers
+ pw_log
+ pw_tokenizer
+ SOURCES
+ metric.cc
+ PRIVATE_DEPS
+ pw_span
+)
+
+pw_add_module_library(pw_metric.global
+ HEADERS
+ public/pw_metric/global.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_metric
+ pw_tokenizer
+ SOURCES
+ global.cc
+)
+
+pw_add_test(pw_metric.metric_test
+ SOURCES
+ metric_test.cc
+ DEPS
+ pw_metric
+ GROUPS
+ modules
+ pw_metric
+)
+
+pw_add_test(pw_metric.global_test
+ SOURCES
+ global_test.cc
+ DEPS
+ pw_metric.global
+ GROUPS
+ modules
+ pw_metric
+)
diff --git a/pw_rpc/CMakeLists.txt b/pw_rpc/CMakeLists.txt
index cb6415e..bd7958e 100644
--- a/pw_rpc/CMakeLists.txt
+++ b/pw_rpc/CMakeLists.txt
@@ -80,7 +80,7 @@
public/pw_rpc/synchronous_call.h
public/pw_rpc/synchronous_call_result.h
PUBLIC_DEPS
- pw_chono.system_clock
+ pw_chrono.system_clock
pw_rpc.client
pw_rpc.common
pw_sync.timed_thread_notification
diff --git a/pw_snapshot/CMakeLists.txt b/pw_snapshot/CMakeLists.txt
index 8c26cc4..f8e0b9a 100644
--- a/pw_snapshot/CMakeLists.txt
+++ b/pw_snapshot/CMakeLists.txt
@@ -31,12 +31,6 @@
pw_snapshot.metadata_proto.pwpb
)
-pw_add_module_library(pw_snapshot
- PUBLIC_DEPS
- pw_snapshot.metadata_proto
- pw_snapshot.snapshot_proto
-)
-
# This proto library only contains the snapshot_metadata.proto. Typically this
# should be a dependency of snapshot-like protos.
pw_proto_library(pw_snapshot.metadata_proto
diff --git a/pw_system/CMakeLists.txt b/pw_system/CMakeLists.txt
index 93b30d5..457cc81 100644
--- a/pw_system/CMakeLists.txt
+++ b/pw_system/CMakeLists.txt
@@ -25,13 +25,15 @@
pw_add_module_library(pw_system.log
PUBLIC_DEPS
- pw_log_rpc.log_service
- pw_log_rpc.rpc_log_drain_thread
+ # TODO(b/246101669): Add CMake support.
+ # pw_log_rpc.log_service
+ # pw_log_rpc.rpc_log_drain_thread
pw_multisink
PRIVATE_DEPS
pw_system.config
pw_system.rpc_server
- pw_log_rpc.rpc_log_drain
+ # TODO(b/246101669): Add CMake support.
+ # pw_log_rpc.rpc_log_drain
pw_sync.lock_annotations
pw_sync.mutex
HEADERS
@@ -122,7 +124,7 @@
pw_add_module_library(pw_system.target_hooks
PUBLIC_DEPS
- pw_thread
+ pw_thread.thread
HEADERS
public/pw_system/target_hooks.h
)
diff --git a/pw_work_queue/CMakeLists.txt b/pw_work_queue/CMakeLists.txt
new file mode 100644
index 0000000..6d6aa5e
--- /dev/null
+++ b/pw_work_queue/CMakeLists.txt
@@ -0,0 +1,77 @@
+# Copyright 2022 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
+
+pw_add_module_library(pw_work_queue
+ HEADERS
+ public/pw_work_queue/internal/circular_buffer.h
+ public/pw_work_queue/work_queue.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_sync.interrupt_spin_lock
+ pw_sync.lock_annotations
+ pw_sync.thread_notification
+ pw_thread.thread
+ pw_function
+ pw_metric
+ pw_span
+ pw_status
+ SOURCES
+ work_queue.cc
+)
+
+pw_add_module_library(pw_work_queue.test_thread
+ HEADERS
+ public/pw_work_queue/test_thread.h
+ PUBLIC_INCLUDES
+ public
+ PUBLIC_DEPS
+ pw_thread.thread
+)
+
+# To instantiate this test based on a selected thread backend to provide
+# test_thread you can create a pw_add_test which depends on this
+# pw_add_library and a pw_add_library which provides the implementation of
+# test_thread. See pw_work_queue.stl_work_queue_test as an example.
+pw_add_module_library(pw_work_queue.work_queue_test
+ SOURCES
+ work_queue_test.cc
+ PRIVATE_DEPS
+ pw_work_queue
+ pw_work_queue.test_thread
+ pw_log
+ pw_unit_test
+)
+
+pw_add_module_library(pw_work_queue.stl_test_thread
+ SOURCES
+ stl_test_thread.cc
+ PRIVATE_DEPS
+ pw_work_queue.test_thread
+ pw_thread.thread
+ pw_thread_stl.thread
+)
+
+if("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread")
+ pw_add_test(pw_work_queue.stl_work_queue_test
+ DEPS
+ pw_work_queue.stl_test_thread
+ pw_work_queue.work_queue_test
+ GROUPS
+ modules
+ pw_work_queue
+ )
+endif()