xmake.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("libsndfile")
  2. set_homepage("https://libsndfile.github.io/libsndfile/")
  3. set_description("A C library for reading and writing sound files containing sampled audio data.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/libsndfile/libsndfile/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libsndfile/libsndfile.git")
  7. add_versions("1.2.2", "ffe12ef8add3eaca876f04087734e6e8e029350082f3251f565fa9da55b52121")
  8. add_versions("1.0.31", "8cdee0acb06bb0a3c1a6ca524575643df8b1f3a55a0893b4dd9f829d08263785")
  9. add_patches("1.2.2", "patches/1.2.2/do-not-install-find.diff", "008f66254b7d0f7602b3c6153a0e9b2c74395c9e9cc0e2e75784a6ed8eb23209")
  10. add_patches("1.2.2", "patches/1.2.2/do-not-set-cmake-module-path.diff", "d59b50d14dca44485aae56ae27456779b0a38c0cfec9785bab500d31cf35188e")
  11. add_deps("cmake")
  12. add_deps("libflac", "libopus", "libvorbis", "libogg")
  13. if is_plat("linux", "bsd") then
  14. add_syslinks("m")
  15. end
  16. on_load("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
  17. if package:config("shared") then
  18. package:add("deps", "python 3.x", {kind = "binary"})
  19. end
  20. end)
  21. on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
  22. -- we pass libogg as packagedeps instead of findOgg.cmake (it does not work)
  23. io.replace("cmake/SndFileChecks.cmake", [[find_package (Ogg 1.3 CONFIG)]], [[]], {plain = true})
  24. local configs = {
  25. "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW",
  26. "-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON"
  27. }
  28. table.insert(configs, "-DBUILD_PROGRAMS=OFF")
  29. table.insert(configs, "-DBUILD_EXAMPLES=OFF")
  30. table.insert(configs, "-DBUILD_TESTING=OFF")
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  32. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  33. table.insert(configs, "-DENABLE_MPEG=OFF")
  34. if package:is_plat("windows", "mingw") then
  35. -- libsndfile doesn't build well with a static libFLAC, this fixes it
  36. if not package:dep("libflac"):config("shared") then
  37. local cmake = io.open("CMakeLists.txt", "a")
  38. cmake:write("add_definitions(-DFLAC__NO_DLL)\n")
  39. cmake:close()
  40. end
  41. end
  42. import("package.tools.cmake").install(package, configs, {packagedeps = "libogg"})
  43. end)
  44. on_test(function (package)
  45. assert(package:has_cfuncs("sf_version_string", {includes = "sndfile.h"}))
  46. end)