pw_build/cmake: Add PUBLIC_INCLUDES and PRIVATE_INCLUDES

Extends the pw_add_module_library function to permit explicit
private and public includes instead of assuming that public is
always used and public_overrides must be used if any facades are
implemented.

This is done in a way where the legacy behavior is used if
PUBLIC_INCLUDES are not specified.

Bug: 601
Change-Id: I2219f66861b9e74807da430cccb62689ce753a42
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/78586
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_build/pigweed.cmake b/pw_build/pigweed.cmake
index 0a3175f..6ccc959 100644
--- a/pw_build/pigweed.cmake
+++ b/pw_build/pigweed.cmake
@@ -166,6 +166,8 @@
 #
 #   SOURCES - source files for this library
 #   HEADERS - header files for this library
+#   PUBLIC_INCLUDES - public target_include_directories argument.
+#   PRIVATE_INCLUDES - public target_include_directories argument.
 #   PUBLIC_DEPS - public target_link_libraries arguments
 #   PRIVATE_DEPS - private target_link_libraries arguments
 #   IMPLEMENTS_FACADES - which facades this library implements
@@ -173,7 +175,8 @@
 #   PRIVATE_DEFINES - private target_compile_definitions arguments
 #
 function(pw_add_module_library NAME)
-  _pw_library_args(list_args IMPLEMENTS_FACADES PUBLIC_DEFINES PRIVATE_DEFINES)
+  _pw_library_args(list_args PUBLIC_INCLUDES PRIVATE_INCLUDES IMPLEMENTS_FACADES
+                   PUBLIC_DEFINES PRIVATE_DEFINES)
   _pw_parse_argv_strict(pw_add_module_library 1 "" "" "${list_args}")
 
   # Check that the library's name is prefixed by the module name.
@@ -187,7 +190,15 @@
   endif()
 
   add_library("${NAME}" EXCLUDE_FROM_ALL ${arg_HEADERS} ${arg_SOURCES})
-  target_include_directories("${NAME}" PUBLIC public)
+  if(NOT "${arg_PUBLIC_INCLUDES}" STREQUAL "")
+    target_include_directories("${NAME}" PUBLIC ${arg_PUBLIC_INCLUDES})
+  else()
+    # TODO(pwbug/601): Deprecate this legacy implicit PUBLIC_INCLUDES.
+    target_include_directories("${NAME}" PUBLIC public)
+  endif()
+  if(NOT "${arg_PRIVATE_INCLUDES}" STREQUAL "")
+    target_include_directories("${NAME}" PRIVATE ${arg_PRIVATE_INCLUDES})
+  endif()
   target_link_libraries("${NAME}"
     PUBLIC
       pw_build
@@ -200,6 +211,10 @@
 
   if(NOT "${arg_IMPLEMENTS_FACADES}" STREQUAL "")
     target_include_directories("${NAME}" PUBLIC public_overrides)
+    if("${arg_PUBLIC_INCLUDES}" STREQUAL "")
+      # TODO(pwbug/601): Deprecate this legacy implicit PUBLIC_INCLUDES.
+      target_include_directories("${NAME}" PUBLIC public_overrides)
+    endif()
     set(facades ${arg_IMPLEMENTS_FACADES})
     list(TRANSFORM facades APPEND ".facade")
     target_link_libraries("${NAME}" PUBLIC ${facades})