xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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/$(version).tar.gz",
  6. "https://github.com/libsndfile/libsndfile.git")
  7. add_versions("v1.0.30", "5942b963d1db3ed8ab1ffb85708322aa9637df76d9fe84e1dfe49a97a90e8f47")
  8. add_versions("1.0.31", "a8cfb1c09ea6e90eff4ca87322d4168cdbe5035cb48717b40bf77e751cc02163")
  9. add_deps("cmake", "libflac", "libopus", "libvorbis", "libogg")
  10. on_load("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
  11. if package:config("shared") then
  12. package:add("deps", "python 3.x", {kind = "binary"})
  13. end
  14. end)
  15. on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
  16. local configs = {}
  17. table.insert(configs, "-DBUILD_PROGRAMS=OFF")
  18. table.insert(configs, "-DBUILD_EXAMPLES=OFF")
  19. table.insert(configs, "-DBUILD_TESTING=OFF")
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  21. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  22. if package:is_plat("windows") then
  23. -- libsndfile doesn't build well with a static libFLAC, this fixes it
  24. if not package:dep("libflac"):config("shared") then
  25. local cmake = io.open("CMakeLists.txt", "a")
  26. cmake:write("add_definitions(-DFLAC__NO_DLL)\n")
  27. cmake:close()
  28. end
  29. end
  30. import("package.tools.cmake").install(package, configs)
  31. end)
  32. on_test(function (package)
  33. assert(package:has_cfuncs("sf_version_string", {includes = "sndfile.h"}))
  34. end)