xmake.lua 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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("sdl3", {showmenu = true, default = false})
  15. option("sdl3_renderer", {showmenu = true, default = false})
  16. option("sdl3_gpu", {showmenu = true, default = false})
  17. option("vulkan", {showmenu = true, default = false})
  18. option("volk", {showmenu = true, default = false})
  19. option("win32", {showmenu = true, default = false})
  20. option("osx", {showmenu = true, default = false})
  21. option("wgpu", {showmenu = true, default = false})
  22. option("wgpu_backend", {showmenu = true, default = "wgpu", type = "string", values = {"wgpu", "dawn"}})
  23. option("freetype", {showmenu = true, default = false})
  24. option("user_config", {showmenu = true, default = nil, type = "string"})
  25. option("wchar32", {showmenu = true, default = false})
  26. if has_config("glfw") then
  27. add_requires("glfw")
  28. end
  29. if has_config("glad") then
  30. add_requires("glad")
  31. end
  32. if has_config("sdl2_renderer") then
  33. add_requires("libsdl2 >=2.0.17")
  34. elseif has_config("sdl2") then
  35. add_requires("libsdl2")
  36. end
  37. if has_config("sdl3") or has_config("sdl3_renderer") or has_config("sdl3_gpu") then
  38. add_requires("libsdl3")
  39. end
  40. if has_config("vulkan") then
  41. add_requires("vulkan-headers")
  42. end
  43. if has_config("volk") then
  44. add_requires("volk")
  45. end
  46. if has_config("wgpu") then
  47. add_requires("wgpu-native")
  48. end
  49. if has_config("freetype") then
  50. add_requires("freetype")
  51. end
  52. target("imgui")
  53. set_kind("$(kind)")
  54. add_files("*.cpp", "misc/cpp/*.cpp")
  55. add_headerfiles("*.h", "(misc/cpp/*.h)")
  56. add_includedirs(".", "misc/cpp")
  57. if is_kind("shared") and is_plat("windows", "mingw") then
  58. add_defines("IMGUI_API=__declspec(dllexport)")
  59. end
  60. if has_config("dx9") then
  61. add_files("backends/imgui_impl_dx9.cpp")
  62. add_headerfiles("(backends/imgui_impl_dx9.h)")
  63. end
  64. if has_config("dx10") then
  65. add_files("backends/imgui_impl_dx10.cpp")
  66. add_headerfiles("(backends/imgui_impl_dx10.h)")
  67. end
  68. if has_config("dx11") then
  69. add_files("backends/imgui_impl_dx11.cpp")
  70. add_headerfiles("(backends/imgui_impl_dx11.h)")
  71. end
  72. if has_config("dx12") then
  73. add_files("backends/imgui_impl_dx12.cpp")
  74. add_headerfiles("(backends/imgui_impl_dx12.h)")
  75. end
  76. if has_config("glfw") then
  77. add_files("backends/imgui_impl_glfw.cpp")
  78. add_headerfiles("(backends/imgui_impl_glfw.h)")
  79. add_packages("glfw")
  80. end
  81. if has_config("opengl2") then
  82. add_files("backends/imgui_impl_opengl2.cpp")
  83. add_headerfiles("(backends/imgui_impl_opengl2.h)")
  84. end
  85. if has_config("opengl3") then
  86. add_files("backends/imgui_impl_opengl3.cpp")
  87. add_headerfiles("(backends/imgui_impl_opengl3.h)")
  88. if has_config("glad") then
  89. add_defines("IMGUI_IMPL_OPENGL_LOADER_GLAD")
  90. add_packages("glad")
  91. else
  92. add_headerfiles("(backends/imgui_impl_opengl3_loader.h)")
  93. end
  94. end
  95. if has_config("sdl2") then
  96. if os.exists("backends/imgui_impl_sdl2.cpp") then
  97. add_files("backends/imgui_impl_sdl2.cpp")
  98. add_headerfiles("(backends/imgui_impl_sdl2.h)")
  99. else
  100. add_files("backends/imgui_impl_sdl.cpp")
  101. add_headerfiles("(backends/imgui_impl_sdl.h)")
  102. end
  103. add_packages("libsdl2")
  104. end
  105. if has_config("sdl2_renderer") then
  106. if os.exists("backends/imgui_impl_sdlrenderer2.cpp") then
  107. add_files("backends/imgui_impl_sdlrenderer2.cpp")
  108. add_headerfiles("(backends/imgui_impl_sdlrenderer2.h)")
  109. else
  110. add_files("backends/imgui_impl_sdlrenderer.cpp")
  111. add_headerfiles("(backends/imgui_impl_sdlrenderer.h)")
  112. end
  113. add_packages("libsdl2")
  114. end
  115. if has_config("sdl3") then
  116. add_files("backends/imgui_impl_sdl3.cpp")
  117. add_headerfiles("(backends/imgui_impl_sdl3.h)")
  118. add_packages("libsdl3")
  119. end
  120. if has_config("sdl3_renderer") then
  121. add_files("backends/imgui_impl_sdlrenderer3.cpp")
  122. add_headerfiles("(backends/imgui_impl_sdlrenderer3.h)")
  123. add_packages("libsdl3")
  124. end
  125. if has_config("sdl3_gpu") then
  126. add_files("backends/imgui_impl_sdlgpu3.cpp")
  127. add_headerfiles("backends/imgui_impl_sdlgpu3.h","backends/imgui_impl_sdlgpu3_shaders.h")
  128. add_packages("libsdl3")
  129. end
  130. if has_config("vulkan") then
  131. add_files("backends/imgui_impl_vulkan.cpp")
  132. add_headerfiles("(backends/imgui_impl_vulkan.h)")
  133. add_packages("vulkan-headers")
  134. end
  135. if has_config("volk") then
  136. add_files("backends/imgui_impl_vulkan.cpp")
  137. add_headerfiles("(backends/imgui_impl_vulkan.h)")
  138. add_packages("volk")
  139. add_defines("IMGUI_IMPL_VULKAN_USE_VOLK")
  140. end
  141. if has_config("win32") then
  142. add_files("backends/imgui_impl_win32.cpp")
  143. add_headerfiles("(backends/imgui_impl_win32.h)")
  144. end
  145. if has_config("osx") then
  146. add_frameworks("Cocoa", "Carbon", "GameController")
  147. add_files("backends/imgui_impl_osx.mm")
  148. add_headerfiles("(backends/imgui_impl_osx.h)")
  149. end
  150. if has_config("wgpu") then
  151. add_files("backends/imgui_impl_wgpu.cpp")
  152. add_headerfiles("(backends/imgui_impl_wgpu.h)")
  153. add_packages("wgpu-native")
  154. if has_config("wgpu_backend") then
  155. add_defines("IMGUI_IMPL_WEBGPU_BACKEND_" .. string.upper(get_config("wgpu_backend")))
  156. end
  157. end
  158. if has_config("freetype") then
  159. add_files("misc/freetype/imgui_freetype.cpp")
  160. add_headerfiles("misc/freetype/imgui_freetype.h")
  161. add_packages("freetype")
  162. add_defines("IMGUI_ENABLE_FREETYPE")
  163. end
  164. if has_config("user_config") then
  165. local user_config = get_config("user_config")
  166. add_defines("IMGUI_USER_CONFIG=\"".. user_config .."\"")
  167. end
  168. if has_config("wchar32") then
  169. add_defines("IMGUI_USE_WCHAR32")
  170. end
  171. after_install(function (target)
  172. local config_file = path.join(target:installdir(), "include/imconfig.h")
  173. if has_config("wchar32") then
  174. io.gsub(config_file, "//#define IMGUI_USE_WCHAR32", "#define IMGUI_USE_WCHAR32")
  175. end
  176. if has_config("freetype") then
  177. io.gsub(config_file, "//#define IMGUI_ENABLE_FREETYPE", "#define IMGUI_ENABLE_FREETYPE")
  178. end
  179. end)