From 8ca9b2b84cb027735a5eb83bad79fa5616d6c369 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
Date: Fri, 29 Apr 2022 20:42:37 +0200
Subject: [PATCH] [wavpack] arm support (#21790)

* [osx] set CMAKE_SYSTEM_PROCESSOR from VCPKG_TARGET_ARCHITECTURE on osx

* [linux] Set CMAKE_ASM_COMPILER and CMAKE_ASM-ATT_COMPILER in case of crosscompile

* [wavpack] migrate to vcpkg_cmake_install

* [wavpack] enable arm builds

* [wavpack] Add  license field to vcpkg.json

* [OSX] don't default to 86_64
---
 ports/wavpack/portfile.cmake   |  9 ++++-----
 ports/wavpack/vcpkg.json       | 15 +++++++++++++--
 scripts/toolchains/linux.cmake | 12 ++++++++++++
 scripts/toolchains/osx.cmake   | 15 ++++++++++++---
 versions/baseline.json         |  2 +-
 versions/w-/wavpack.json       |  5 +++++
 6 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/ports/wavpack/portfile.cmake b/ports/wavpack/portfile.cmake
index 2c0dba8ad00b2a..6b3d4a5c47a7c9 100644
--- a/ports/wavpack/portfile.cmake
+++ b/ports/wavpack/portfile.cmake
@@ -9,9 +9,8 @@ vcpkg_from_github(
         fix-symbol-exports.patch
 )
 
-vcpkg_configure_cmake(
+vcpkg_cmake_configure(
     SOURCE_PATH ${SOURCE_PATH}
-    PREFER_NINJA # Disable this option if project cannot be built with Ninja
     OPTIONS
         -DWAVPACK_INSTALL_DOCS=OFF
         -DWAVPACK_BUILD_PROGRAMS=OFF
@@ -21,12 +20,12 @@ vcpkg_configure_cmake(
         -DWAVPACK_BUILD_DOCS=OFF
 )
 
-vcpkg_install_cmake()
+vcpkg_cmake_install()
 
 if(VCPKG_TARGET_IS_WINDOWS)
-    vcpkg_fixup_cmake_targets(CONFIG_PATH cmake)
+    vcpkg_cmake_config_fixup(CONFIG_PATH cmake)
 else()
-    vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/WavPack)
+    vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/WavPack)
 endif()
 
 vcpkg_copy_pdbs()
diff --git a/ports/wavpack/vcpkg.json b/ports/wavpack/vcpkg.json
index 7918e036d04b8f..dff83543e0e642 100644
--- a/ports/wavpack/vcpkg.json
+++ b/ports/wavpack/vcpkg.json
@@ -1,8 +1,19 @@
 {
   "name": "wavpack",
   "version": "5.4.0",
-  "port-version": 1,
+  "port-version": 2,
   "description": "WavPack encode/decode library, command-line programs, and several plugins",
   "homepage": "https://github.com/dbry/WavPack",
-  "supports": "!(arm | arm64)"
+  "license": "BSD-3-Clause",
+  "supports": "!(windows & arm)",
+  "dependencies": [
+    {
+      "name": "vcpkg-cmake",
+      "host": true
+    },
+    {
+      "name": "vcpkg-cmake-config",
+      "host": true
+    }
+  ]
 }
diff --git a/scripts/toolchains/linux.cmake b/scripts/toolchains/linux.cmake
index fb56665384e695..2fac4922deacf7 100644
--- a/scripts/toolchains/linux.cmake
+++ b/scripts/toolchains/linux.cmake
@@ -19,6 +19,12 @@ elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
         if(NOT DEFINED CMAKE_C_COMPILER)
             set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc")
         endif()
+        if(NOT DEFINED CMAKE_ASM_COMPILER)
+            set(CMAKE_ASM_COMPILER "arm-linux-gnueabihf-gcc")
+        endif()
+        if(NOT DEFINED CMAKE_ASM-ATT_COMPILER)
+            set(CMAKE_ASM-ATT_COMPILER "arm-linux-gnueabihf-as")
+        endif()      
         message(STATUS "Cross compiling arm on host x86_64, use cross compiler: ${CMAKE_CXX_COMPILER}/${CMAKE_C_COMPILER}")
     endif()
 elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
@@ -30,6 +36,12 @@ elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
         if(NOT DEFINED CMAKE_C_COMPILER)
             set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
         endif()
+        if(NOT DEFINED CMAKE_ASM_COMPILER)
+            set(CMAKE_ASM_COMPILER "aarch64-linux-gnu-gcc")
+        endif()
+        if(NOT DEFINED CMAKE_ASM-ATT_COMPILER)
+            set(CMAKE_ASM-ATT_COMPILER "aarch64-linux-gnu-as")
+        endif()  
         message(STATUS "Cross compiling arm64 on host x86_64, use cross compiler: ${CMAKE_CXX_COMPILER}/${CMAKE_C_COMPILER}")
     endif()
 endif()
diff --git a/scripts/toolchains/osx.cmake b/scripts/toolchains/osx.cmake
index 1ab3da5e5d442f..efad6c5fedaca8 100644
--- a/scripts/toolchains/osx.cmake
+++ b/scripts/toolchains/osx.cmake
@@ -2,17 +2,26 @@ if(NOT _VCPKG_OSX_TOOLCHAIN)
 set(_VCPKG_OSX_TOOLCHAIN 1)
 if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
     set(CMAKE_CROSSCOMPILING OFF CACHE BOOL "")
-
     set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}" CACHE STRING "")
-    set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE STRING "")
 else()
     set(CMAKE_SYSTEM_VERSION "17.0.0" CACHE STRING "")
-    set(CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "")
 endif()
 set(CMAKE_SYSTEM_NAME Darwin CACHE STRING "")
 
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 
+if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
+    if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
+       set(CMAKE_SYSTEM_PROCESSOR x86_64 CACHE STRING "")
+    elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
+       set(CMAKE_SYSTEM_PROCESSOR x86 CACHE STRING "")
+    elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
+       set(CMAKE_SYSTEM_PROCESSOR arm64 CACHE STRING "")
+    else()
+       set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE STRING "")
+    endif()
+endif()
+
 get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
 if(NOT _CMAKE_IN_TRY_COMPILE)
     string(APPEND CMAKE_C_FLAGS_INIT " -fPIC ${VCPKG_C_FLAGS} ")
diff --git a/versions/baseline.json b/versions/baseline.json
index 8e39fb9a20986d..05813878654ae9 100644
--- a/versions/baseline.json
+++ b/versions/baseline.json
@@ -7438,7 +7438,7 @@
     },
     "wavpack": {
       "baseline": "5.4.0",
-      "port-version": 1
+      "port-version": 2
     },
     "websocketpp": {
       "baseline": "0.8.2",
diff --git a/versions/w-/wavpack.json b/versions/w-/wavpack.json
index a723cf1107e7a3..9a826a33033f6c 100644
--- a/versions/w-/wavpack.json
+++ b/versions/w-/wavpack.json
@@ -1,5 +1,10 @@
 {
   "versions": [
+    {
+      "git-tree": "39c514f313b4bc2fc7af0f3a889425bb78aca9e3",
+      "version": "5.4.0",
+      "port-version": 2
+    },
     {
       "git-tree": "77b8c9ab85776abb2d049d562db7350525ddf7e2",
       "version": "5.4.0",