premake5.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. newoption
  2. {
  3. trigger = "graphics",
  4. value = "OPENGL_VERSION",
  5. description = "version of OpenGL to build raylib against",
  6. allowed = {
  7. { "opengl11", "OpenGL 1.1"},
  8. { "opengl21", "OpenGL 2.1"},
  9. { "opengl33", "OpenGL 3.3"},
  10. { "opengl43", "OpenGL 4.3"}
  11. },
  12. default = "opengl33"
  13. }
  14. function define_C()
  15. language "C"
  16. end
  17. function define_Cpp()
  18. language "C++"
  19. end
  20. function string.starts(String,Start)
  21. return string.sub(String,1,string.len(Start))==Start
  22. end
  23. function link_to(lib)
  24. links (lib)
  25. includedirs ("../"..lib.."/include", "../"..lib.."/" )
  26. end
  27. function download_progress(total, current)
  28. local ratio = current / total;
  29. ratio = math.min(math.max(ratio, 0), 1);
  30. local percent = math.floor(ratio * 100);
  31. print("Download progress (" .. percent .. "%/100%)")
  32. end
  33. function check_raylib()
  34. if(os.isdir("raylib") == false and os.isdir("raylib-master") == false) then
  35. if(not os.isfile("raylib-master.zip")) then
  36. print("Raylib not found, downloading from github")
  37. local result_str, response_code = http.download("https://github.com/raysan5/raylib/archive/refs/heads/master.zip", "raylib-master.zip", {
  38. progress = download_progress,
  39. headers = { "From: Premake", "Referer: Premake" }
  40. })
  41. end
  42. print("Unzipping to " .. os.getcwd())
  43. zip.extract("raylib-master.zip", os.getcwd())
  44. os.remove("raylib-master.zip")
  45. end
  46. end
  47. function check_imgui()
  48. if(os.isdir("imgui") == false and os.isdir("imgui-master") == false) then
  49. if(not os.isfile("imgui-master.zip")) then
  50. print("imgui not found, downloading from github")
  51. local result_str, response_code = http.download("https://github.com/ocornut/imgui/archive/refs/heads/master.zip", "imgui-master.zip", {
  52. progress = download_progress,
  53. headers = { "From: Premake", "Referer: Premake" }
  54. })
  55. end
  56. print("Unzipping to " .. os.getcwd())
  57. zip.extract("imgui-master.zip", os.getcwd())
  58. os.remove("imgui-master.zip")
  59. end
  60. end
  61. workspace "rlImGui"
  62. configurations { "Debug", "Release" }
  63. platforms { "x64"}
  64. defaultplatform "x64"
  65. filter "configurations:Debug"
  66. defines { "DEBUG" }
  67. symbols "On"
  68. filter "configurations:Release"
  69. defines { "NDEBUG" }
  70. optimize "On"
  71. filter { "platforms:x64" }
  72. architecture "x86_64"
  73. filter { "system:linux" }
  74. defines { "_GLFW_X11" }
  75. defines { "_GNU_SOURCE" }
  76. targetdir "bin/%{cfg.buildcfg}/"
  77. cdialect "C99"
  78. cppdialect "C++11"
  79. check_raylib()
  80. check_imgui()
  81. include ("raylib_premake5.lua")
  82. project "rlImGui"
  83. kind "StaticLib"
  84. location "build"
  85. targetdir "bin/%{cfg.buildcfg}"
  86. language "C++"
  87. include_raylib()
  88. includedirs { "rlImGui", "imgui", "imgui-master"}
  89. vpaths
  90. {
  91. ["Header Files"] = { "*.h"},
  92. ["Source Files"] = {"*.cpp"},
  93. ["ImGui Files"] = { "imgui/*.h","imgui/*.cpp", "imgui-master/*.h","imgui-master/*.cpp" },
  94. }
  95. files {"imgui-master/*.h", "imgui-master/*.cpp", "imgui/*.h", "imgui/*.cpp", "*.cpp", "*.h", "extras/**.h"}
  96. defines {"IMGUI_DISABLE_OBSOLETE_FUNCTIONS","IMGUI_DISABLE_OBSOLETE_KEYIO"}
  97. group "Examples"
  98. project "simple"
  99. kind "ConsoleApp"
  100. language "C++"
  101. location "build"
  102. targetdir "bin/%{cfg.buildcfg}"
  103. vpaths
  104. {
  105. ["Header Files"] = { "examples/**.h"},
  106. ["Source Files"] = {"examples/**.cpp", "examples/**.c"},
  107. }
  108. files {"examples/simple.cpp"}
  109. link_raylib()
  110. links {"rlImGui"}
  111. includedirs {"./", "imgui", "imgui-master" }
  112. filter "action:vs*"
  113. debugdir "$(SolutionDir)"
  114. project "editor"
  115. kind "ConsoleApp"
  116. language "C++"
  117. location "build"
  118. targetdir "bin/%{cfg.buildcfg}"
  119. vpaths
  120. {
  121. ["Header Files"] = { "examples/**.h"},
  122. ["Source Files"] = {"examples/**.cpp", "examples/**.c"},
  123. }
  124. files {"examples/editor.cpp"}
  125. link_raylib()
  126. links {"rlImGui"}
  127. includedirs {"./", "imgui", "imgui-master" }
  128. filter "action:vs*"
  129. debugdir "$(SolutionDir)"
  130. project "imgui_style_example"
  131. kind "ConsoleApp"
  132. language "C++"
  133. location "build"
  134. targetdir "bin/%{cfg.buildcfg}"
  135. vpaths
  136. {
  137. ["Header Files"] = { "examples/**.h"},
  138. ["Source Files"] = {"examples/**.cpp", "examples/**.c"},
  139. }
  140. files {"examples/imgui_style_example.cpp"}
  141. link_raylib()
  142. links {"rlImGui"}
  143. includedirs {"./", "imgui", "imgui-master" }
  144. filter "action:vs*"
  145. debugdir "$(SolutionDir)"