xmake.lua 5.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package("directxtk12")
  2. set_homepage("https://github.com/Microsoft/DirectXTK12")
  3. set_description("A collection of helper classes for writing DirectX 12 code in C++")
  4. set_license("MIT")
  5. local tag = {
  6. ["2024.06"] = "jun2024",
  7. ["2024.09"] = "sep2024"
  8. }
  9. add_urls("https://github.com/microsoft/DirectXTK12.git")
  10. add_urls("https://github.com/microsoft/DirectXTK12/archive/refs/tags/$(version).tar.gz",
  11. { version = function (version) return tag[tostring(version)] end })
  12. add_versions("2024.06", "c543e2de8c9f8eeb83fcc39c5d142e02a190b57080449ac4785d3c4cb1e8dfe6")
  13. add_versions("2024.09", "03f76b5bd58b98697f078f17db8ecd73c408dfeed09c7788ce56a2db75a86e6d")
  14. add_configs("dxil_shaders", { description = "Use DXC Shader Model 6 for shaders", default = true, type = "boolean" })
  15. add_configs("gameinput", { description = "Build for GameInput", default = false, type = "boolean" })
  16. add_configs("mixed_dx11", { description = "Support linking with DX11 version of toolkit", default = false, type = "boolean" })
  17. add_configs("testing", { description = "Build the testing tree", default = true, type = "boolean" })
  18. add_configs("wgi", { description = "Build for Windows.Gaming.Input", default = false, type = "boolean" })
  19. add_configs("xaudio_redist", { description = "Build for XAudio2Redist", default = false, type = "boolean" })
  20. add_configs("xaudio_win10", { description = "Build for XAudio 2.9", default = true, type = "boolean" })
  21. add_configs("xinput", { description = "Build for XInput", default = false, type = "boolean" })
  22. add_configs("spectre_mitigation", { description = "Build using /Qspectre for MSVC", default = false, type = "boolean" })
  23. add_configs("iterator_debugging", { description = "Disable MSVC iterator debugging in Debug", default = false, type = "boolean" })
  24. add_configs("prebuilt_shaders", { description = "Use externally built HLSL shaders", default = false, type = "boolean" })
  25. add_configs("no_wchar_t", { description = "Use legacy wide-character as unsigned short", default = false, type = "boolean" })
  26. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  27. add_deps("cmake")
  28. if on_check then
  29. on_check("windows", function (package)
  30. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  31. if vs_toolset then
  32. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  33. local minor = vs_toolset_ver:minor()
  34. assert(minor and minor >= 30, "package(directxtk12) require vs_toolset >= 14.3")
  35. end
  36. end)
  37. end
  38. on_load(function (package)
  39. if package:is_plat("windows") then
  40. package:add("defines", "WIN32")
  41. end
  42. if package:config("mixed_dx11") then
  43. package:add("deps", "directxtk")
  44. end
  45. if package:config("gameinput") then
  46. package:add("defines", "USING_GAMEINPUT")
  47. end
  48. if package:config("wgi") then
  49. package:add("defines", "USING_WINDOWS_GAMING_INPUT")
  50. end
  51. if package:config("xinput") then
  52. package:add("defines", "USING_XINPUT")
  53. end
  54. end)
  55. on_install("windows", function (package)
  56. local configs = {}
  57. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  58. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  59. table.insert(configs, "-DBUILD_DXIL_SHADERS=" .. (package:config("dxil_shaders") and "ON" or "OFF"))
  60. table.insert(configs, "-DBUILD_GAMINPUT=" .. (package:config("gameinput") and "ON" or "OFF"))
  61. table.insert(configs, "-DBUILD_MIXED_DX11=" .. (package:config("mixed_dx11") and "ON" or "OFF"))
  62. table.insert(configs, "-DBUILD_TESTING=" .. (package:config("testing") and "ON" or "OFF"))
  63. table.insert(configs, "-DBUILD_WGI=" .. (package:config("wgi") and "ON" or "OFF"))
  64. table.insert(configs, "-DBUILD_XAUDIO_REDIST=" .. (package:config("xaudio_redist") and "ON" or "OFF"))
  65. table.insert(configs, "-DBUILD_XAUDIO_WIN10=" .. (package:config("xaudio_win10") and "ON" or "OFF"))
  66. table.insert(configs, "-DBUILD_XINPUT=" .. (package:config("xinput") and "ON" or "OFF"))
  67. table.insert(configs, "-DBUILD_ENABLE_SPECTRE_MITIGATION=" .. (package:config("spectre_mitigation") and "ON" or "OFF"))
  68. table.insert(configs, "-DDISABLE_MSVC_ITERATOR_DEBUGGING=" .. (package:config("iterator_debugging") and "ON" or "OFF"))
  69. table.insert(configs, "-DUSE_PREBUILT_SHADERS=" .. (package:config("prebuilt_shaders") and "ON" or "OFF"))
  70. table.insert(configs, "-DNO_WCHAR_T=" .. (package:config("no_wchar_t") and "ON" or "OFF"))
  71. import("package.tools.cmake").install(package, configs)
  72. end)
  73. on_test(function (package)
  74. assert(package:check_cxxsnippets({ test = [[
  75. void test() {
  76. DirectX::SimpleMath::Vector3 eye(0.0f, 0.7f, 1.5f);
  77. DirectX::SimpleMath::Vector3 at(0.0f, -0.1f, 0.0f);
  78. auto lookAt = DirectX::SimpleMath::Matrix::CreateLookAt(eye, at, DirectX::SimpleMath::Vector3::UnitY);
  79. }
  80. ]] }, {configs = {languages = "c++17"}, includes = "directxtk12/SimpleMath.h"}))
  81. end)