xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("minifb")
  2. set_homepage("https://github.com/emoon/minifb")
  3. set_description("MiniFB is a small cross platform library to create a frame buffer that you can draw pixels in")
  4. set_license("MIT")
  5. add_urls("https://github.com/emoon/minifb.git")
  6. add_versions("2022.11.12", "5312cb7ca07115c918148131d296864b8d67e2d7")
  7. add_deps("cmake")
  8. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  9. if is_plat("windows") then
  10. add_configs("vs_runtime", {description = "Set vs compiler runtime.", default = "MD", readonly = true})
  11. end
  12. if is_plat("macosx") then
  13. add_frameworks("CoreFoundation", "Foundation", "AppKit", "MetalKit", "Metal")
  14. elseif is_plat("linux") then
  15. add_deps("libx11", "libxkbcommon")
  16. add_deps("glx", "opengl", {optional = true})
  17. elseif is_plat("windows") then
  18. add_syslinks("gdi32", "opengl32", "user32", "winmm")
  19. end
  20. on_install("macosx", "linux", "windows", function (package)
  21. local configs = {"-DMINIFB_BUILD_EXAMPLES=OFF"}
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  23. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  24. local packagedeps
  25. if package:is_plat("linux") then
  26. packagedeps = {"libx11", "libxkbcommon", "glx", "opengl"}
  27. io.replace("CMakeLists.txt", 'set(CMAKE_C_FLAGS "")', "", {plain = true})
  28. io.replace("CMakeLists.txt", 'set(CMAKE_CXX_FLAGS "")', "", {plain = true})
  29. end
  30. import("package.tools.cmake").install(package, configs, {buildir = "build", packagedeps = packagedeps})
  31. os.cp("include", package:installdir())
  32. os.trycp("build/*.a", package:installdir("lib"))
  33. os.trycp("build/*.lib", package:installdir("lib"))
  34. end)
  35. on_test(function (package)
  36. assert(package:has_cfuncs("mfb_update_ex", {includes = "MiniFB.h"}))
  37. end)