xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package("tinyspline")
  2. set_homepage("https://github.com/msteinbeck/tinyspline")
  3. set_description("ANSI C library for NURBS, B-Splines, and Bézier curves with interfaces for C++, C#, D, Go, Java, Javascript, Lua, Octave, PHP, Python, R, and Ruby.")
  4. set_license("MIT")
  5. add_urls("https://github.com/msteinbeck/tinyspline/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/msteinbeck/tinyspline.git")
  7. add_versions("v0.6.0", "3ea31b610dd279266f26fd7ad5b5fca7a20c0bbe05c7c32430ed6aa54d57097a")
  8. add_deps("cmake")
  9. on_install(function (package)
  10. io.replace("src/CMakeLists.txt", [["lib64"]], [["lib"]], {plain = true})
  11. io.replace("src/CMakeLists.txt", "RUNTIME DESTINATION ${TINYSPLINE_INSTALL_BINARY_DIR}", "RUNTIME DESTINATION bin", {plain = true})
  12. io.replace("src/CMakeLists.txt", "LIBRARY DESTINATION ${TINYSPLINE_INSTALL_LIBRARY_DIR}", "LIBRARY DESTINATION lib", {plain = true})
  13. io.replace("src/CMakeLists.txt", "ARCHIVE DESTINATION ${TINYSPLINE_INSTALL_LIBRARY_DIR}", "ARCHIVE DESTINATION lib", {plain = true})
  14. local configs = {
  15. "-DTINYSPLINE_BUILD_EXAMPLES=OFF", "-DTINYSPLINE_BUILD_TESTS=OFF",
  16. "-DTINYSPLINE_BUILD_DOCS=OFF", "-DTINYSPLINE_WARNINGS_AS_ERRORS=OFF"
  17. }
  18. -- Fix for mingw@macosx being recognized as Windows
  19. if package:is_plat("mingw") and is_subhost("macosx") then
  20. table.insert(configs, "-DCMAKE_SYSTEM_NAME=CYGWIN")
  21. io.replace("src/CMakeLists.txt", [[elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")]], [[elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")]], {plain = true})
  22. end
  23. -- Fix for newer WASM/Emscripten versions
  24. io.replace("src/tinysplinecxx.h", "toWireType(const std::vector<T, Allocator> &vec)", "toWireType(const std::vector<T, Allocator> &vec, rvp::default_tag)", {plain = true})
  25. io.replace("src/tinysplinecxx.h", "return ValBinding::toWireType(val::array(vec))", "return ValBinding::toWireType(val::array(vec), rvp::default_tag{})", {plain = true})
  26. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  27. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  28. import("package.tools.cmake").install(package, configs)
  29. end)
  30. on_test(function (package)
  31. assert(package:has_cfuncs("ts_deboornet_free", {includes = "tinyspline.h"}))
  32. end)