xmake.lua 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package("directxtk")
  2. set_homepage("https://github.com/microsoft/DirectXTK")
  3. set_description("A collection of helper classes for writing Direct3D 11 C++ code For Windows.")
  4. set_urls("https://github.com/microsoft/DirectXTK/archive/$(version).zip",
  5. "https://github.com/microsoft/DirectXTK.git",
  6. {version = function (version)
  7. local versions = {
  8. ["20.9.0"] = "sept2020",
  9. ["21.4.0"] = "apr2021",
  10. ["21.11.0"] = "nov2021",
  11. ["24.2.0"] = "feb2024"
  12. }
  13. return versions[tostring(version)]
  14. end})
  15. add_versions("20.9.0", "9d5131243bf3e33db2e3a968720d860abdcbbe7cb037c2cb5dd06046d439ed09")
  16. add_versions("21.4.0", "481e769b1aabd08b46659bbec8363a2429f04d3bb9a1e857eb0ebd163304d1bf")
  17. add_versions("21.11.0", "d25e634b0e225ae572f82d0d27c97051b0069c6813d7be12453039a504dffeb8")
  18. add_versions("24.2.0", "edb643b2444ff24925339cfb1bc9f76c671d5404a5549d32ecaa0d61bbab28c9")
  19. add_deps("cmake")
  20. -- FIXME arm/MT met some link errors
  21. if is_arch("arm.*") then
  22. add_configs("runtimes", {description = "Set compiler runtimes.", default = "MD", readonly = true})
  23. end
  24. if on_check then
  25. on_check("windows", function (package)
  26. local vs_sdkver = package:toolchain("msvc"):config("vs_sdkver")
  27. if vs_sdkver then
  28. local build_ver = string.match(vs_sdkver, "%d+%.%d+%.(%d+)%.?%d*")
  29. assert(tonumber(build_ver) >= 19041, "DirectXTK requires Windows SDK to be at least 10.0.19041.0")
  30. end
  31. end)
  32. end
  33. on_install("windows", function (package)
  34. local configs = {}
  35. local vs_sdkver = package:toolchain("msvc"):config("vs_sdkver")
  36. if vs_sdkver then
  37. table.insert(configs, "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" .. vs_sdkver)
  38. table.insert(configs, "-DCMAKE_SYSTEM_VERSION=" .. vs_sdkver)
  39. end
  40. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  41. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  42. -- fix path issue with spaces
  43. io.replace("Src/Shaders/CompileShaders.cmd", " %1.hlsl ", " \"%1.hlsl\" ", {plain = true})
  44. io.replace("Src/Shaders/CompileShaders.cmd", " %1.fx ", " \"%1.fx\" ", {plain = true})
  45. import("package.tools.cmake").install(package, configs)
  46. os.cp("Inc/*", package:installdir("include"))
  47. end)
  48. on_test(function (package)
  49. assert(package:check_cxxsnippets({test = [[
  50. void test() {
  51. DirectX::SimpleMath::Vector3 eye(0.0f, 0.7f, 1.5f);
  52. DirectX::SimpleMath::Vector3 at(0.0f, -0.1f, 0.0f);
  53. auto lookAt = DirectX::SimpleMath::Matrix::CreateLookAt(eye, at, DirectX::SimpleMath::Vector3::UnitY);
  54. }
  55. ]]}, {configs = {languages = "c++11"}, includes = { "windows.h", "SimpleMath.h" } }))
  56. end)