From 0affe8710a4a5b26328e909fe1ad7146df39d108 Mon Sep 17 00:00:00 2001 From: Ada Tufankjian Date: Thu, 26 Sep 2024 07:54:48 -0700 Subject: [PATCH] [libmysofa] Adding port (#38368) Co-authored-by: Kai Pastor --- ports/libmysofa/portfile.cmake | 36 ++++++++++++ ports/libmysofa/usage | 4 ++ ports/libmysofa/use-vcpkg-zlib.patch | 82 ++++++++++++++++++++++++++++ ports/libmysofa/vcpkg.json | 18 ++++++ versions/baseline.json | 4 ++ versions/l-/libmysofa.json | 9 +++ 6 files changed, 153 insertions(+) create mode 100644 ports/libmysofa/portfile.cmake create mode 100644 ports/libmysofa/usage create mode 100644 ports/libmysofa/use-vcpkg-zlib.patch create mode 100644 ports/libmysofa/vcpkg.json create mode 100644 versions/l-/libmysofa.json diff --git a/ports/libmysofa/portfile.cmake b/ports/libmysofa/portfile.cmake new file mode 100644 index 00000000000000..f8ccce7a2d7ab2 --- /dev/null +++ b/ports/libmysofa/portfile.cmake @@ -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") diff --git a/ports/libmysofa/usage b/ports/libmysofa/usage new file mode 100644 index 00000000000000..e7cce3ad0e24a9 --- /dev/null +++ b/ports/libmysofa/usage @@ -0,0 +1,4 @@ +libmysofa provides CMake targets: + + find_package(mysofa CONFIG REQUIRED) + target_link_libraries(main PRIVATE $,mysofa::mysofa-shared,mysofa::mysofa-static>) diff --git a/ports/libmysofa/use-vcpkg-zlib.patch b/ports/libmysofa/use-vcpkg-zlib.patch new file mode 100644 index 00000000000000..06c2fbc1f705d5 --- /dev/null +++ b/ports/libmysofa/use-vcpkg-zlib.patch @@ -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 + "$" + $ + ) +-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) + "$" + $ + ) +- 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 diff --git a/ports/libmysofa/vcpkg.json b/ports/libmysofa/vcpkg.json new file mode 100644 index 00000000000000..3d6b7f28740099 --- /dev/null +++ b/ports/libmysofa/vcpkg.json @@ -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" + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index 41d4faf26bad01..ed61be6a816bdb 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -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 diff --git a/versions/l-/libmysofa.json b/versions/l-/libmysofa.json new file mode 100644 index 00000000000000..40580588a8b309 --- /dev/null +++ b/versions/l-/libmysofa.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "7af8df14c5cacf2ba9f4798281ec863159c387ec", + "version": "1.3.2", + "port-version": 0 + } + ] +}