aom: Fix compilations errors in Cygwin

From 405f2d05062c0e2e6bc54b2f5085cf79d8d9930d Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Fri, 26 Jan 2024 10:46:19 -0800
Subject: [PATCH] Fix compilations errors in Cygwin

Tested with both GCC 11.4.0 and Clang 8.0.1 in Cygwin. Must use yasm as
the assembler. nasm (2.13.01) cannot find the include files (in %include
statements) in .asm files.

This is the libaom version of the libvpx CL
https://chromium-review.googlesource.com/c/webm/libvpx/+/2732960.

Bug: aomedia:3541
Change-Id: Id84e83900297001bdb9aca5e0df1fb554f1294b6
---
 CMakeLists.txt                  |  6 ------
 build/cmake/aom_configure.cmake | 11 +++++++++++
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a02b220bdb..f594e9b4f8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -843,12 +843,6 @@ if(BUILD_SHARED_LIBS)
   setup_exports_target()
 endif()
 
-# Do not allow implicit vector type conversions on Clang builds (this is already
-# the default on GCC builds).
-if(CMAKE_C_COMPILER_ID MATCHES "Clang")
-  append_compiler_flag("-flax-vector-conversions=none")
-endif()
-
 # Handle user supplied compile and link flags last to ensure they're obeyed.
 set_user_flags()
 
diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake
index 917e7cac5d..304d90d1e1 100644
--- a/build/cmake/aom_configure.cmake
+++ b/build/cmake/aom_configure.cmake
@@ -320,6 +320,10 @@ else()
     # minimum supported C++ version. If Clang is using this Standard Library
     # implementation, it cannot target C++11.
     require_cxx_flag_nomsvc("-std=c++14" YES)
+  elseif(CYGWIN AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    # The GNU C++ compiler in Cygwin needs the -std=gnu++11 flag to make the
+    # POSIX function declarations visible in the Standard C Library headers.
+    require_cxx_flag_nomsvc("-std=gnu++11" YES)
   else()
     require_cxx_flag_nomsvc("-std=c++11" YES)
   endif()
@@ -393,6 +397,13 @@ else()
   endif()
   add_compiler_flag_if_supported("-D_LARGEFILE_SOURCE")
   add_compiler_flag_if_supported("-D_FILE_OFFSET_BITS=64")
+
+  # Do not allow implicit vector type conversions on Clang builds (this is
+  # already the default on GCC builds).
+  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+    # Clang 8.0.1 (in Cygwin) doesn't support -flax-vector-conversions=none.
+    add_compiler_flag_if_supported("-flax-vector-conversions=none")
+  endif()
 endif()
 
 # Prior to r23, or with ANDROID_USE_LEGACY_TOOLCHAIN_FILE set,