pw_build: Check the library type in pw_add_library CMake function

This is helpful in case the user forgets to specify the library type,
since it is not required for the built-in add_library function.

Change-Id: I9932bcfb63431fccf68766ce2d292413ba03bfac
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112213
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
diff --git a/pw_build/pigweed.cmake b/pw_build/pigweed.cmake
index 401029b..ae9d4ea 100644
--- a/pw_build/pigweed.cmake
+++ b/pw_build/pigweed.cmake
@@ -287,6 +287,12 @@
 #   PUBLIC_LINK_OPTIONS - public target_link_options arguments
 #   PRIVATE_LINK_OPTIONS - private target_link_options arguments
 function(pw_add_library NAME TYPE)
+  set(supported_library_types INTERFACE OBJECT STATIC SHARED MODULE)
+  if(NOT "${TYPE}" IN_LIST supported_library_types)
+    message(FATAL_ERROR "\"${TYPE}\" is not a valid library type for ${NAME}. "
+          "Must be INTERFACE, OBJECT, STATIC, SHARED, or MODULE.")
+  endif()
+
   set(num_positional_args 2)
   set(option_args)
   set(one_value_args)