pw_build/cmake: Extend pw_add_module_library

Extends pw_add_module_library to include link and compile options.

Change-Id: I3cc85a3e02a8589ef2cf5310bf2a279c320ac69d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/79380
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 6ccc959..1102220 100644
--- a/pw_build/pigweed.cmake
+++ b/pw_build/pigweed.cmake
@@ -166,17 +166,27 @@
 #
 #   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
+#   PUBLIC_INCLUDES - public target_include_directories argument
+#   PRIVATE_INCLUDES - public target_include_directories argument
 #   IMPLEMENTS_FACADES - which facades this library implements
 #   PUBLIC_DEFINES - public target_compile_definitions arguments
 #   PRIVATE_DEFINES - private target_compile_definitions arguments
+#   PUBLIC_COMPILE_OPTIONS - public target_compile_options arguments
+#   PRIVATE_COMPILE_OPTIONS - private target_compile_options arguments
+#   PUBLIC_LINK_OPTIONS - public target_link_options arguments
+#   PRIVATE_LINK_OPTIONS - private target_link_options arguments
 #
 function(pw_add_module_library NAME)
-  _pw_library_args(list_args PUBLIC_INCLUDES PRIVATE_INCLUDES IMPLEMENTS_FACADES
-                   PUBLIC_DEFINES PRIVATE_DEFINES)
+  _pw_library_args(
+      list_args
+          PUBLIC_INCLUDES PRIVATE_INCLUDES
+          IMPLEMENTS_FACADES
+          PUBLIC_DEFINES PRIVATE_DEFINES
+          PUBLIC_COMPILE_OPTIONS PRIVATE_COMPILE_OPTIONS
+          PUBLIC_LINK_OPTIONS PRIVATE_LINK_OPTIONS
+  )
   _pw_parse_argv_strict(pw_add_module_library 1 "" "" "${list_args}")
 
   # Check that the library's name is prefixed by the module name.
@@ -232,6 +242,22 @@
   if(NOT "${arg_PRIVATE_DEFINES}" STREQUAL "")
     target_compile_definitions("${NAME}" PRIVATE ${arg_PRIVATE_DEFINES})
   endif()
+
+  if(NOT "${arg_PUBLIC_COMPILE_OPTIONS}" STREQUAL "")
+    target_compile_options("${NAME}" PUBLIC ${arg_PUBLIC_COMPILE_OPTIONS})
+  endif()
+
+  if(NOT "${arg_PRIVATE_COMPILE_OPTIONS}" STREQUAL "")
+    target_compile_options("${NAME}" PRIVATE ${arg_PRIVATE_COMPILE_OPTIONS})
+  endif()
+
+  if(NOT "${arg_PUBLIC_LINK_OPTIONS}" STREQUAL "")
+    target_link_options("${NAME}" PUBLIC ${arg_PUBLIC_LINK_OPTIONS})
+  endif()
+
+  if(NOT "${arg_PRIVATE_LINK_OPTIONS}" STREQUAL "")
+    target_link_options("${NAME}" PRIVATE ${arg_PRIVATE_LINK_OPTIONS})
+  endif()
 endfunction(pw_add_module_library)
 
 # Declares a module as a facade.