xmake.lua 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package("directxtex")
  2. set_homepage("https://walbourn.github.io/directxtex/")
  3. set_description("DirectXTex texture processing library")
  4. set_license("MIT")
  5. local tag =
  6. {
  7. ["2023.06"] = "jun2023",
  8. }
  9. add_urls("https://github.com/microsoft/DirectXTex/archive/refs/tags/$(version).tar.gz",
  10. "https://github.com/microsoft/DirectXTex.git", {version = function (version) return tag[tostring(version)] end})
  11. add_versions("2023.06", "51f0ff3bee0d1015c110e0c92ebdd9704aa6acd91185328fd92f10b9558f4c62")
  12. if is_plat("windows") then
  13. add_configs("dx11", {description = "Build with DirectX11 Runtime support", default = true, type = "boolean"})
  14. add_configs("dx12", {description = "Build with DirectX12 Runtime support", default = true, type = "boolean"})
  15. add_configs("spectre", {description = "Build using /Qspectre for MSVC", default = false, type = "boolean"})
  16. end
  17. add_configs("openmp", {description = "Build with OpenMP support", default = false, type = "boolean"})
  18. add_configs("iterator_debugging", {description = "Disable iterator debugging in Debug configurations with the MSVC CRT", default = false, type = "boolean"})
  19. add_configs("code_analysis", {description = "Use Static Code Analysis on build", default = false, type = "boolean"})
  20. add_configs("prebuild_shader", {description = "Use externally built HLSL shaders", default = false, type = "boolean"})
  21. add_configs("openexr", {description = "Build with OpenEXR support", default = false, type = "boolean"})
  22. add_deps("cmake")
  23. if is_plat("linux") then
  24. add_deps("directxmath", "directx-headers")
  25. end
  26. on_load(function (package)
  27. if package:config("openexr") then
  28. package:add("deps", "openexr")
  29. end
  30. end)
  31. on_install("windows", "linux", function (package)
  32. local configs = {"-DBUILD_TOOLS=OFF", "-DBUILD_SAMPLE=OFF"}
  33. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  34. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. if package:is_plat("windows") then
  36. table.insert(configs, "-DBUILD_DX11=" .. (package:config("dx11") and "ON" or "OFF"))
  37. table.insert(configs, "-DBUILD_DX12=" .. (package:config("dx12") and "ON" or "OFF"))
  38. table.insert(configs, "-DENABLE_SPECTRE_MITIGATION=" .. (package:config("spectre") and "ON" or "OFF"))
  39. end
  40. table.insert(configs, "-DBC_USE_OPENMP=" .. (package:config("openmp") and "ON" or "OFF"))
  41. table.insert(configs, "-DDISABLE_MSVC_ITERATOR_DEBUGGING=" .. (package:config("iterator_debugging") and "ON" or "OFF"))
  42. table.insert(configs, "-DENABLE_CODE_ANALYSIS=" .. (package:config("code_analysis") and "ON" or "OFF"))
  43. table.insert(configs, "-DUSE_PREBUILT_SHADERS=" .. (package:config("prebuild_shader") and "ON" or "OFF"))
  44. table.insert(configs, "-DENABLE_OPENEXR_SUPPORT=" .. (package:config("openexr") and "ON" or "OFF"))
  45. import("package.tools.cmake").install(package, configs)
  46. end)
  47. on_test(function (package)
  48. assert(package:check_cxxsnippets({test = [[
  49. #include <DirectXTex.h>
  50. void test() {
  51. DirectX::IsValid(DXGI_FORMAT_UNKNOWN);
  52. }
  53. ]]}, {configs = {languages = "c++17"}}))
  54. end)