aom: cmake: check for -Wmissing-prototypes support

From c6e26e14bc57cae5038431f07fe1b473204f41fa Mon Sep 17 00:00:00 2001
From: James Zern <[EMAIL REDACTED]>
Date: Fri, 14 Jun 2024 16:56:11 -0700
Subject: [PATCH] cmake: check for -Wmissing-prototypes support

Bug: aomedia:3416
Change-Id: I24b1c2253865a79db9a2fe1585d4c425cddf639d
---
 CMakeLists.txt                  | 5 +++++
 build/cmake/aom_configure.cmake | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1aa87f27f..05dcd57d6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -472,6 +472,11 @@ if(CONFIG_LIBYUV OR CONFIG_TUNE_BUTTERAUGLI)
   add_library(yuv OBJECT ${AOM_LIBYUV_SOURCES})
   if(NOT MSVC)
     target_compile_options(yuv PRIVATE -Wno-shadow)
+    # Many functions in libyuv trigger this warning when enabled with clang.
+    is_flag_present(AOM_CXX_FLAGS "-Wmissing-prototypes" flag_present)
+    if(flag_present)
+      target_compile_options(yuv PRIVATE -Wno-missing-prototypes)
+    endif()
   endif()
   include_directories("${AOM_ROOT}/third_party/libyuv/include")
 endif()
diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake
index 2382974d7..44fe8b757 100644
--- a/build/cmake/aom_configure.cmake
+++ b/build/cmake/aom_configure.cmake
@@ -343,6 +343,11 @@ else()
   add_compiler_flag_if_supported("-Wformat=2")
   add_c_flag_if_supported("-Wimplicit-function-declaration")
   add_compiler_flag_if_supported("-Wlogical-op")
+  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+    add_compiler_flag_if_supported("-Wmissing-prototypes")
+  else()
+    add_c_flag_if_supported("-Wmissing-prototypes")
+  endif()
   add_compiler_flag_if_supported("-Wpointer-arith")
   add_compiler_flag_if_supported("-Wshadow")
   add_compiler_flag_if_supported("-Wshorten-64-to-32")