From cd0671082bc3dbc78215657e5b89e26eb6b458f6 Mon Sep 17 00:00:00 2001
From: past-due <30942300+past-due@users.noreply.github.com>
Date: Thu, 6 Jun 2024 17:35:19 -0400
Subject: [PATCH] basisu vcpkg port: patch for mingw compilation

---
 .../overlay-ports/basisu/001-mingw.patch      | 39 +++++++++++++++++++
 .ci/vcpkg/overlay-ports/basisu/portfile.cmake |  2 +
 .ci/vcpkg/overlay-ports/basisu/vcpkg.json     |  2 +-
 3 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 .ci/vcpkg/overlay-ports/basisu/001-mingw.patch

diff --git a/.ci/vcpkg/overlay-ports/basisu/001-mingw.patch b/.ci/vcpkg/overlay-ports/basisu/001-mingw.patch
new file mode 100644
index 00000000000..93b7b1cbc4e
--- /dev/null
+++ b/.ci/vcpkg/overlay-ports/basisu/001-mingw.patch
@@ -0,0 +1,39 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 492233a..bdd4dac 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -102,8 +102,10 @@ if (NOT MSVC)
+ 	  	set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0")
+ 		set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0")
+ 	  endif()
+-	  
+-	  set(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -Wl,-rpath .")
++
++	  if (NOT MINGW)
++	    set(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -Wl,-rpath .")
++	  endif()
+    endif()
+ 
+    set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} ${GCC_COMPILE_FLAGS}")
+@@ -123,6 +125,21 @@ else()
+ 	endif()
+ endif()
+ 
++# Set BASISU_HAVE_STD_TRIVIALLY_COPYABLE if the target supports std::is_trivially_copyable
++include(CheckCXXSourceCompiles)
++check_cxx_source_compiles("
++	#include <type_traits>
++	const bool val = std::is_trivially_copyable<bool>::value;
++	int main()
++	{
++		return 0;
++	}"
++	HAVE_STD_IS_TRIVIALLY_COPYABLE
++)
++if (HAVE_STD_IS_TRIVIALLY_COPYABLE)
++	set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -DBASISU_HAVE_STD_TRIVIALLY_COPYABLE")
++endif()
++
+ set(BASISU_SRC_LIST ${COMMON_SRC_LIST} 
+ 	basisu_tool.cpp
+ 	encoder/basisu_backend.cpp
diff --git a/.ci/vcpkg/overlay-ports/basisu/portfile.cmake b/.ci/vcpkg/overlay-ports/basisu/portfile.cmake
index 60134acc1f9..2cfc4a7c537 100644
--- a/.ci/vcpkg/overlay-ports/basisu/portfile.cmake
+++ b/.ci/vcpkg/overlay-ports/basisu/portfile.cmake
@@ -4,6 +4,8 @@ vcpkg_from_github(
     REF ad9386a4a1cf2a248f7bbd45f543a7448db15267 # post-1.16.4, including fixes
     SHA512 4922af3a8d42d8c1ab551853d0ab97c0733a869cd99e95ef7a03620da023da48070a1255dcd68f6a384ee7787b5bd5dffe2cd510b2986e2a0e7181929f6ecc64
     HEAD_REF master
+    PATCHES
+        001-mingw.patch
 )
 
 set(_additional_options)
diff --git a/.ci/vcpkg/overlay-ports/basisu/vcpkg.json b/.ci/vcpkg/overlay-ports/basisu/vcpkg.json
index 1f6f5ce14ee..a82907819ab 100644
--- a/.ci/vcpkg/overlay-ports/basisu/vcpkg.json
+++ b/.ci/vcpkg/overlay-ports/basisu/vcpkg.json
@@ -1,7 +1,7 @@
 {
   "name": "basisu",
   "version-string": "1.16.4",
-  "port-version": 1,
+  "port-version": 2,
   "description": "Basis Universal is a supercompressed GPU texture and video compression format that outputs a highly compressed intermediate file format (.basis) that can be quickly transcoded to a wide variety of GPU texture compression formats.",
   "homepage": "https://github.com/BinomialLLC/basis_universal",
   "dependencies": [