xmake.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. add_rules("mode.debug", "mode.release")
  2. add_rules("utils.install.cmake_importfiles")
  3. set_languages("cxx14")
  4. option("dx9", {showmenu = true, default = false})
  5. option("dx10", {showmenu = true, default = false})
  6. option("dx11", {showmenu = true, default = false})
  7. option("dx12", {showmenu = true, default = false})
  8. option("glfw", {showmenu = true, default = false})
  9. option("opengl2", {showmenu = true, default = false})
  10. option("opengl3", {showmenu = true, default = false})
  11. option("glad", {showmenu = true, default = false})
  12. option("sdl2", {showmenu = true, default = false})
  13. option("sdl2_renderer", {showmenu = true, default = false})
  14. option("vulkan", {showmenu = true, default = false})
  15. option("win32", {showmenu = true, default = false})
  16. option("wgpu", {showmenu = true, default = false})
  17. option("freetype", {showmenu = true, default = false})
  18. option("user_config", {showmenu = true, default = nil, type = "string"})
  19. option("wchar32", {showmenu = true, default = false})
  20. if has_config("glfw") then
  21. add_requires("glfw")
  22. end
  23. if has_config("glad") then
  24. add_requires("glad")
  25. end
  26. if has_config("sdl2_renderer") then
  27. add_requires("libsdl >=2.0.17")
  28. elseif has_config("sdl2") then
  29. add_requires("libsdl")
  30. end
  31. if has_config("vulkan") then
  32. add_requires("vulkansdk")
  33. end
  34. if has_config("wgpu") then
  35. add_requires("wgpu-native")
  36. end
  37. if has_config("freetype") then
  38. add_requires("freetype")
  39. end
  40. target("imgui")
  41. set_kind("$(kind)")
  42. add_files("*.cpp", "misc/cpp/*.cpp")
  43. add_headerfiles("*.h", "(misc/cpp/*.h)")
  44. add_includedirs(".", "misc/cpp")
  45. if is_kind("shared") and is_plat("windows", "mingw") then
  46. add_defines("IMGUI_API=__declspec(dllexport)")
  47. end
  48. if has_config("dx9") then
  49. add_files("backends/imgui_impl_dx9.cpp")
  50. add_headerfiles("(backends/imgui_impl_dx9.h)")
  51. end
  52. if has_config("dx10") then
  53. add_files("backends/imgui_impl_dx10.cpp")
  54. add_headerfiles("(backends/imgui_impl_dx10.h)")
  55. end
  56. if has_config("dx11") then
  57. add_files("backends/imgui_impl_dx11.cpp")
  58. add_headerfiles("(backends/imgui_impl_dx11.h)")
  59. end
  60. if has_config("dx12") then
  61. add_files("backends/imgui_impl_dx12.cpp")
  62. add_headerfiles("(backends/imgui_impl_dx12.h)")
  63. end
  64. if has_config("glfw") then
  65. add_files("backends/imgui_impl_glfw.cpp")
  66. add_headerfiles("(backends/imgui_impl_glfw.h)")
  67. add_packages("glfw")
  68. end
  69. if has_config("opengl2") then
  70. add_files("backends/imgui_impl_opengl2.cpp")
  71. add_headerfiles("(backends/imgui_impl_opengl2.h)")
  72. end
  73. if has_config("opengl3") then
  74. add_files("backends/imgui_impl_opengl3.cpp")
  75. add_headerfiles("(backends/imgui_impl_opengl3.h)")
  76. if has_config("glad") then
  77. add_defines("IMGUI_IMPL_OPENGL_LOADER_GLAD")
  78. add_packages("glad")
  79. else
  80. add_headerfiles("(backends/imgui_impl_opengl3_loader.h)")
  81. end
  82. end
  83. if has_config("sdl2") then
  84. if os.exists("backends/imgui_impl_sdl2.cpp") then
  85. add_files("backends/imgui_impl_sdl2.cpp")
  86. add_headerfiles("(backends/imgui_impl_sdl2.h)")
  87. else
  88. add_files("backends/imgui_impl_sdl.cpp")
  89. add_headerfiles("(backends/imgui_impl_sdl.h)")
  90. end
  91. add_packages("libsdl")
  92. end
  93. if has_config("sdl2_renderer") then
  94. if os.exists("backends/imgui_impl_sdlrenderer2.cpp") then
  95. add_files("backends/imgui_impl_sdlrenderer2.cpp")
  96. add_headerfiles("(backends/imgui_impl_sdlrenderer2.h)")
  97. else
  98. add_files("backends/imgui_impl_sdlrenderer.cpp")
  99. add_headerfiles("(backends/imgui_impl_sdlrenderer.h)")
  100. end
  101. add_packages("libsdl")
  102. end
  103. if has_config("vulkan") then
  104. add_files("backends/imgui_impl_vulkan.cpp")
  105. add_headerfiles("(backends/imgui_impl_vulkan.h)")
  106. add_packages("vulkansdk")
  107. end
  108. if has_config("win32") then
  109. add_files("backends/imgui_impl_win32.cpp")
  110. add_headerfiles("(backends/imgui_impl_win32.h)")
  111. end
  112. if has_config("wgpu") then
  113. add_files("backends/imgui_impl_wgpu.cpp")
  114. add_headerfiles("(backends/imgui_impl_wgpu.h)")
  115. add_packages("wgpu-native")
  116. end
  117. if has_config("freetype") then
  118. add_files("misc/freetype/imgui_freetype.cpp")
  119. add_headerfiles("misc/freetype/imgui_freetype.h")
  120. add_packages("freetype")
  121. add_defines("IMGUI_ENABLE_FREETYPE")
  122. end
  123. if has_config("user_config") then
  124. local user_config = get_config("user_config")
  125. add_defines("IMGUI_USER_CONFIG=\"".. user_config .."\"")
  126. end
  127. if has_config("wchar32") then
  128. add_defines("IMGUI_USE_WCHAR32")
  129. end
  130. after_install(function (target)
  131. local config_file = path.join(target:installdir(), "include/imconfig.h")
  132. if has_config("wchar32") then
  133. io.gsub(config_file, "//#define IMGUI_USE_WCHAR32", "#define IMGUI_USE_WCHAR32")
  134. end
  135. if has_config("freetype") then
  136. io.gsub(config_file, "//#define IMGUI_ENABLE_FREETYPE", "#define IMGUI_ENABLE_FREETYPE")
  137. end
  138. end)