xmake.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package("poly2tri")
  2. set_homepage("https://github.com/jhasse/poly2tri")
  3. set_description("2D constrained Delaunay triangulation library")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/jhasse/poly2tri.git")
  6. add_versions("2024.02.08", "13d64e75a84dd8f36673a7eaf022e8e9fdd1f88b")
  7. add_deps("cmake")
  8. on_install(function (package)
  9. if package:config("shared") then
  10. io.replace("CMakeLists.txt", "if(poly2tri_target_type STREQUAL SHARED_LIBRARY)", "if(1)", {plain = true})
  11. else
  12. io.replace("poly2tri/common/dll_symbol.h", "define P2T_DLL_SYMBOL", "define P2T_DLL_SYMBOL P2T_COMPILER_DLLEXPORT", {plain = true})
  13. io.replace("CMakeLists.txt", "if(poly2tri_target_type STREQUAL SHARED_LIBRARY)", "if(0)", {plain = true})
  14. end
  15. io.replace("CMakeLists.txt", "add_library(poly2tri ${SOURCES} ${HEADERS})", [[
  16. add_library(poly2tri ${SOURCES} ${HEADERS})
  17. install(TARGETS ${PROJECT_NAME}
  18. RUNTIME DESTINATION bin
  19. LIBRARY DESTINATION lib
  20. ARCHIVE DESTINATION lib
  21. )
  22. install(DIRECTORY "${CMAKE_SOURCE_DIR}/poly2tri" DESTINATION include FILES_MATCHING PATTERN "*.h")
  23. ]], {plain = true})
  24. local configs = {}
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  27. import("package.tools.cmake").install(package, configs)
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({test = [[
  31. void test() {
  32. std::vector<p2t::Point*> polyline {
  33. new p2t::Point(350, 500),
  34. new p2t::Point(1050, 1700)
  35. };
  36. std::vector<p2t::Point*> hole {
  37. new p2t::Point(591, 1350),
  38. new p2t::Point(550, 2050)
  39. };
  40. p2t::CDT cdt{ polyline };
  41. cdt.AddHole(hole);
  42. }
  43. ]]}, {configs = {languages = "c++14"}, includes = "poly2tri/poly2tri.h"}))
  44. end)