xmake.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("soil2")
  2. set_homepage("https://github.com/SpartanJ/SOIL2")
  3. set_description("SOIL2 is a tiny C library used primarily for uploading textures into OpenGL.")
  4. set_license("MIT-0")
  5. add_urls("https://github.com/SpartanJ/SOIL2.git")
  6. add_versions("2024.10.14", "1ecaa772fdc67a49f9737452d628730384806f9b")
  7. if is_plat("macosx") then
  8. add_frameworks("CoreFoundation")
  9. end
  10. add_deps("cmake")
  11. add_deps("opengl", {optional = true})
  12. if on_check then
  13. on_check("windows", function (package)
  14. if package:is_arch("arm.*") then
  15. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  16. if vs_toolset then
  17. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  18. local minor = vs_toolset_ver:minor()
  19. assert(minor and minor >= 30, "package(soil2) require vs_toolset >= 14.3")
  20. end
  21. end
  22. end)
  23. end
  24. -- TODO: fix glXGetProcAddress on linux
  25. on_install("windows", "macosx", "mingw", "msys", function (package)
  26. io.replace("CMakeLists.txt", "$<$<CXX_COMPILER_ID:Clang>:-fPIC>", "", {plain = true})
  27. io.replace("CMakeLists.txt", "$<$<CXX_COMPILER_ID:GNU>:-fPIC>", "", {plain = true})
  28. local configs = {"-DSOIL2_BUILD_TESTS=OFF"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. if package:is_plat("windows") and package:config("shared") then
  32. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  33. end
  34. local opt = {packagedeps = "opengl"}
  35. if package:is_plat("macosx") then
  36. opt.shflags = {"-framework", "CoreFoundation"}
  37. end
  38. import("package.tools.cmake").install(package, configs, opt)
  39. if package:is_plat("windows") and package:is_debug() then
  40. local dir = package:installdir(package:config("shared") and "bin" or "lib")
  41. os.trycp(path.join(package:buildir(), "soil2.pdb"), dir)
  42. end
  43. end)
  44. on_test(function (package)
  45. assert(package:has_cfuncs("SOIL_load_OGL_texture", {includes = "soil2/SOIL2.h"}))
  46. end)