xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("msdf-atlas-gen")
  2. set_homepage("https://github.com/Chlumsky/msdf-atlas-gen")
  3. set_description("Multi-channel signed distance field atlas generator")
  4. set_license("MIT")
  5. add_urls("https://github.com/Chlumsky/msdf-atlas-gen/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/Chlumsky/msdf-atlas-gen.git", {submodules = false})
  7. add_versions("v1.3", "5d3d58e8bc92836baf23ce3a80ef79cc4c2d022fb86b7f160b11cc06cd62fe78")
  8. add_configs("standalone", {description = "Build standalone executable", default = false, type = "boolean"})
  9. add_deps("cmake")
  10. add_deps("zlib")
  11. add_deps("msdfgen", {configs = {extensions = true}})
  12. on_load("windows", function (package)
  13. if package:config("shared") then
  14. package:add("defines", "MSDF_ATLAS_PUBLIC=__declspec(dllimport)")
  15. end
  16. end)
  17. on_install(function (package)
  18. local configs = {}
  19. table.insert(configs, "-DMSDF_ATLAS_USE_VCPKG=OFF")
  20. table.insert(configs, "-DMSDF_ATLAS_INSTALL=ON")
  21. table.insert(configs, "-DMSDF_ATLAS_DYNAMIC_RUNTIME=OFF")
  22. table.insert(configs, "-DMSDF_ATLAS_MSDFGEN_EXTERNAL=ON")
  23. table.insert(configs, "-DMSDF_ATLAS_NO_ARTERY_FONT=ON")
  24. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  25. table.insert(configs, "-DMSDF_ATLAS_BUILD_STANDALONE=" .. (package:config("standalone") and "ON" or "OFF"))
  26. if package:is_plat("windows") then
  27. io.replace("CMakeLists.txt", [[set(MSDF_ATLAS_MSVC_RUNTIME "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")]], "", {plain = true})
  28. io.replace("CMakeLists.txt", [[set(MSDF_ATLAS_MSVC_RUNTIME "MultiThreaded$<$<CONFIG:Debug>:Debug>")]], "", {plain = true})
  29. end
  30. if package:is_plat("mingw") and package:config("shared") then
  31. io.replace("CMakeLists.txt", [[if(BUILD_SHARED_LIBS AND WIN32)]], [[if(0)]], {plain = true})
  32. end
  33. import("package.tools.cmake").install(package, configs)
  34. end)
  35. on_test(function (package)
  36. assert(package:check_cxxsnippets({test = [[
  37. #include <msdf-atlas-gen/msdf-atlas-gen.h>
  38. static void test() {
  39. msdf_atlas::TightAtlasPacker packer;
  40. }
  41. ]]}, {configs = {languages = "c++11"}}))
  42. if package:config("standalone") and not package:is_cross() then
  43. os.vrun("msdf-atlas-gen -help")
  44. end
  45. end)