CMake: Make the default build empty

- Include subdirectories with EXCLUDE_FROM_ALL and make sure all targets
  have this property set. This gives external projects full control over
  what builds by default.
- Provide a `pw_apps` top-level group that builds standalone
  applications and add this to the CMake presubmit step.

Change-Id: I52f0043f78ffdf6a78ddf23e7a1a9635eb9eda58
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/25182
Reviewed-by: Zoltan Szatmary-Ban <szatmz@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1199180..020cf7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,38 +16,41 @@
 
 cmake_minimum_required(VERSION 3.16)
 
-add_subdirectory(pw_assert)
-add_subdirectory(pw_assert_basic)
-add_subdirectory(pw_assert_log)
-add_subdirectory(pw_base64)
-add_subdirectory(pw_blob_store)
-add_subdirectory(pw_build)
-add_subdirectory(pw_bytes)
-add_subdirectory(pw_checksum)
-add_subdirectory(pw_containers)
-add_subdirectory(pw_cpu_exception)
-add_subdirectory(pw_cpu_exception_armv7m)
-add_subdirectory(pw_hdlc_lite)
-add_subdirectory(pw_kvs)
-add_subdirectory(pw_log)
-add_subdirectory(pw_log_basic)
-add_subdirectory(pw_log_tokenized)
-add_subdirectory(pw_minimal_cpp_stdlib)
-add_subdirectory(pw_polyfill)
-add_subdirectory(pw_protobuf)
-add_subdirectory(pw_preprocessor)
-add_subdirectory(pw_random)
-add_subdirectory(pw_result)
-add_subdirectory(pw_rpc)
-add_subdirectory(pw_span)
-add_subdirectory(pw_status)
-add_subdirectory(pw_stream)
-add_subdirectory(pw_string)
-add_subdirectory(pw_sys_io)
-add_subdirectory(pw_sys_io_stdio)
-add_subdirectory(pw_tokenizer)
-add_subdirectory(pw_trace)
-add_subdirectory(pw_unit_test)
-add_subdirectory(pw_varint)
+add_subdirectory(pw_assert EXCLUDE_FROM_ALL)
+add_subdirectory(pw_assert_basic EXCLUDE_FROM_ALL)
+add_subdirectory(pw_assert_log EXCLUDE_FROM_ALL)
+add_subdirectory(pw_base64 EXCLUDE_FROM_ALL)
+add_subdirectory(pw_blob_store EXCLUDE_FROM_ALL)
+add_subdirectory(pw_build EXCLUDE_FROM_ALL)
+add_subdirectory(pw_bytes EXCLUDE_FROM_ALL)
+add_subdirectory(pw_checksum EXCLUDE_FROM_ALL)
+add_subdirectory(pw_containers EXCLUDE_FROM_ALL)
+add_subdirectory(pw_cpu_exception EXCLUDE_FROM_ALL)
+add_subdirectory(pw_cpu_exception_armv7m EXCLUDE_FROM_ALL)
+add_subdirectory(pw_hdlc_lite EXCLUDE_FROM_ALL)
+add_subdirectory(pw_kvs EXCLUDE_FROM_ALL)
+add_subdirectory(pw_log EXCLUDE_FROM_ALL)
+add_subdirectory(pw_log_basic EXCLUDE_FROM_ALL)
+add_subdirectory(pw_log_tokenized EXCLUDE_FROM_ALL)
+add_subdirectory(pw_minimal_cpp_stdlib EXCLUDE_FROM_ALL)
+add_subdirectory(pw_polyfill EXCLUDE_FROM_ALL)
+add_subdirectory(pw_protobuf EXCLUDE_FROM_ALL)
+add_subdirectory(pw_preprocessor EXCLUDE_FROM_ALL)
+add_subdirectory(pw_random EXCLUDE_FROM_ALL)
+add_subdirectory(pw_result EXCLUDE_FROM_ALL)
+add_subdirectory(pw_rpc EXCLUDE_FROM_ALL)
+add_subdirectory(pw_span EXCLUDE_FROM_ALL)
+add_subdirectory(pw_status EXCLUDE_FROM_ALL)
+add_subdirectory(pw_stream EXCLUDE_FROM_ALL)
+add_subdirectory(pw_string EXCLUDE_FROM_ALL)
+add_subdirectory(pw_sys_io EXCLUDE_FROM_ALL)
+add_subdirectory(pw_sys_io_stdio EXCLUDE_FROM_ALL)
+add_subdirectory(pw_tokenizer EXCLUDE_FROM_ALL)
+add_subdirectory(pw_trace EXCLUDE_FROM_ALL)
+add_subdirectory(pw_unit_test EXCLUDE_FROM_ALL)
+add_subdirectory(pw_varint EXCLUDE_FROM_ALL)
 
-add_subdirectory(third_party/nanopb)
+add_subdirectory(third_party/nanopb EXCLUDE_FROM_ALL)
+
+add_custom_target(pw_apps)
+add_dependencies(pw_apps pw_hdlc_lite.rpc_example)
diff --git a/pw_hdlc_lite/rpc_example/CMakeLists.txt b/pw_hdlc_lite/rpc_example/CMakeLists.txt
index 9c2d32c..be26438 100644
--- a/pw_hdlc_lite/rpc_example/CMakeLists.txt
+++ b/pw_hdlc_lite/rpc_example/CMakeLists.txt
@@ -13,7 +13,10 @@
 # the License.
 
 
-add_executable(pw_hdlc_lite.rpc_example hdlc_rpc_server.cc main.cc)
+add_executable(pw_hdlc_lite.rpc_example EXCLUDE_FROM_ALL
+    hdlc_rpc_server.cc
+    main.cc
+)
 
 target_link_libraries(pw_hdlc_lite.rpc_example
   PRIVATE