Skip to content

Commit

Permalink
[libmysofa] Adding port (#38368)
Browse files Browse the repository at this point in the history
Co-authored-by: Kai Pastor <dg0yt@darc.de>
  • Loading branch information
Honeybunch and dg0yt committed Sep 26, 2024
1 parent 39580ae commit 0affe87
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ports/libmysofa/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO hoene/libmysofa
REF "1f9c8df42dfd6765e390ed8840341f15e1ab997b"
SHA512 67ce39d78981dc95cf190b1be4addceec4ecc7c2b14660da53a856be8fcff97a2f238343fccac2d042212e5a101eaf26fd12b78c86d0f6ce022bb79aa9815c67
HEAD_REF "v${VERSION}"
PATCHES
use-vcpkg-zlib.patch
)

# default.sofa is a symlink to MIT_KEMAR_normal_pinna.sofa,
# which can cause problems e.g. on Windows file systems.
if(EXISTS "${SOURCE_PATH}/share/default.sofa")
file(REMOVE "${SOURCE_PATH}/share/default.sofa")
endif()
file(COPY_FILE "${SOURCE_PATH}/share/MIT_KEMAR_normal_pinna.sofa" "${SOURCE_PATH}/share/default.sofa")

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_TESTS=OFF
-DBUILD_STATIC_LIBS=${BUILD_STATIC}
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME mysofa CONFIG_PATH lib/cmake/mysofa)
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
4 changes: 4 additions & 0 deletions ports/libmysofa/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
libmysofa provides CMake targets:

find_package(mysofa CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:mysofa::mysofa-shared>,mysofa::mysofa-shared,mysofa::mysofa-static>)
82 changes: 82 additions & 0 deletions ports/libmysofa/use-vcpkg-zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 018f4ce..90ec50d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,21 +13,25 @@ use_c99()
configure_file(config.h.in config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

+find_package(ZLIB REQUIRED)
+
if(NOT MSVC)
if(NOT WIN32)
find_library(MATH m)
else()
set(MATH "")
endif()
- include(FindZLIB)
+ #include(FindZLIB)
else()
set(MATH "")
+ #[[
find_program(NUGET nuget)
if(NUGET)
execute_process(COMMAND ${NUGET} install zlib)
endif()
include_directories(
${PROJECT_SOURCE_DIR}/windows/third-party/zlib-1.2.11/include/)
+ ]]#
endif()

if(NOT MSVC)
@@ -36,12 +40,13 @@ if(NOT MSVC)
else()
set(MATH "")
endif()
- include(FindZLIB)
- include_directories(${ZLIB_INCLUDE_DIRS})
+ #include(FindZLIB)
+ #include_directories(${ZLIB_INCLUDE_DIRS})
set(PKG_CONFIG_PRIVATELIBS "-lm ${PKG_CONFIG_PRIVATELIBS}")
set(PKG_CONFIG_PRIVATELIBS "-lz ${PKG_CONFIG_PRIVATELIBS}")
else()
set(MATH "")
+ #[[
find_program(NUGET nuget)
if(NOT NUGET)
message(
@@ -53,6 +58,7 @@ else()
endif()
include_directories(
${PROJECT_SOURCE_DIR}/windows/third-party/zlib-1.2.11/include/)
+ ]]#
endif()

set(libsrc
@@ -81,6 +87,8 @@ set(public-headers
hrtf/mysofa.h
)

+install(FILES "${public-headers}" DESTINATION include)
+
if(BUILD_STATIC_LIBS)
add_library(mysofa-static STATIC ${libsrc})
target_include_directories(mysofa-static
@@ -88,7 +96,7 @@ target_include_directories(mysofa-static
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hrtf>"
$<INSTALL_INTERFACE:include/>
)
-target_link_libraries(mysofa-static LINK_PRIVATE ${MATH} ${ZLIB_LIBRARIES})
+target_link_libraries(mysofa-static LINK_PRIVATE ${MATH} ZLIB::ZLIB)
set_target_properties(
mysofa-static
PROPERTIES OUTPUT_NAME mysofa CLEAN_DIRECT_OUTPUT 1 POSITION_INDEPENDENT_CODE
@@ -120,7 +128,7 @@ if(BUILD_SHARED_LIBS)
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hrtf>"
$<INSTALL_INTERFACE:include/>
)
- target_link_libraries(mysofa-shared PRIVATE ${MATH} ${ZLIB_LIBRARIES})
+ target_link_libraries(mysofa-shared PRIVATE ${MATH} ZLIB::ZLIB)
set_target_properties(mysofa-shared
PROPERTIES OUTPUT_NAME mysofa CLEAN_DIRECT_OUTPUT 1)
# Rename the Windows import library (stub) of the DLL to prevent a name clash
18 changes: 18 additions & 0 deletions ports/libmysofa/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "libmysofa",
"version": "1.3.2",
"description": "Reader for AES SOFA files to get better HRTFs (Head-Relative Transfer Functions)",
"homepage": "https://github.com/hoene/libmysofa",
"license": "BSD-3-Clause",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4804,6 +4804,10 @@
"baseline": "1.23.11",
"port-version": 0
},
"libmysofa": {
"baseline": "1.3.2",
"port-version": 0
},
"libmysql": {
"baseline": "8.0.39",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/l-/libmysofa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "7af8df14c5cacf2ba9f4798281ec863159c387ec",
"version": "1.3.2",
"port-version": 0
}
]
}

0 comments on commit 0affe87

Please sign in to comment.