xmake.lua 6.4 KB

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