Skip to content

Commit

Permalink
Build Windows libsndfile dynamically, but dependencies statically
Browse files Browse the repository at this point in the history
this used to work, but I broke it on accident. This commit also adds
support for arm64 builds, which were not previously available.
  • Loading branch information
Bastian Bechtold committed Dec 30, 2024
1 parent a9a4f7f commit 1ac5f94
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ jobs:
strategy:
matrix:
include:
- triplet: "x64-windows"
# see ./triplets/README.md for info on "custom" triplets:
- triplet: "x64-windows-custom"
libname: "libsndfile_x64.dll"
- triplet: "x86-windows"
- triplet: "x86-windows-custom"
libname: "libsndfile_x86.dll"
- triplet: "arm64-windows"
- triplet: "arm64-windows-custom"
libname: "libsndfile_arm64.dll"
fail-fast: true

steps:
- uses: actions/checkout@v3
- name: Update VCPKG
Expand Down
Binary file modified libsndfile_arm64.dll
Binary file not shown.
Binary file modified libsndfile_x64.dll
Binary file not shown.
Binary file modified libsndfile_x86.dll
Binary file not shown.
9 changes: 6 additions & 3 deletions triplets/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Custom triplets for Vcpkg.
VCPKG allows either, static builds, or dynamic builds. However, we need to
build libsndfile as a dynamic library, but its dependencies should be
statically linked.

https://vcpkg.readthedocs.io/en/latest/users/triplets/
https://vcpkg.readthedocs.io/en/latest/examples/overlay-triplets-linux-dynamic/
These custom triplets accomplish this. They are a copy of the official
{arm64,x64,x86}-windows triplets at https://github.com/microsoft/vcpkg/tree/master/triplets,
but with all libraries except libsndfile configured for static linkage.
7 changes: 7 additions & 0 deletions triplets/arm64-windows-custom.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

if (PORT MATCHES "libsndfile")
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()
2 changes: 0 additions & 2 deletions triplets/x64-windows-custom.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic) # Runtime always dynamically linked.
set(VCPKG_LIBRARY_LINKAGE static) # Libs are static by default.
set(VCPKG_PLATFORM_TOOLSET v140) # Enforce v140 toolset.
set(VCPKG_BUILD_TYPE release) # Skip debug builds.

if (PORT STREQUAL libsndfile) # Only libsndfile is dynamic.
set(VCPKG_LIBRARY_LINKAGE dynamic)
Expand Down
2 changes: 0 additions & 2 deletions triplets/x86-windows-custom.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_PLATFORM_TOOLSET v140)
set(VCPKG_BUILD_TYPE release)

if (PORT STREQUAL libsndfile)
set(VCPKG_LIBRARY_LINKAGE dynamic)
Expand Down

0 comments on commit 1ac5f94

Please sign in to comment.