raylib_premake5.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. -- Copyright (c) 2020-2024 Jeffery Myers
  2. --
  3. --This software is provided "as-is", without any express or implied warranty. In no event
  4. --will the authors be held liable for any damages arising from the use of this software.
  5. --Permission is granted to anyone to use this software for any purpose, including commercial
  6. --applications, and to alter it and redistribute it freely, subject to the following restrictions:
  7. -- 1. The origin of this software must not be misrepresented; you must not claim that you
  8. -- wrote the original software. If you use this software in a product, an acknowledgment
  9. -- in the product documentation would be appreciated but is not required.
  10. --
  11. -- 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  12. -- as being the original software.
  13. --
  14. -- 3. This notice may not be removed or altered from any source distribution.
  15. function platform_defines()
  16. defines{"PLATFORM_DESKTOP"}
  17. filter {"options:graphics=opengl43"}
  18. defines{"GRAPHICS_API_OPENGL_43"}
  19. filter {"options:graphics=opengl33"}
  20. defines{"GRAPHICS_API_OPENGL_33"}
  21. filter {"options:graphics=opengl21"}
  22. defines{"GRAPHICS_API_OPENGL_21"}
  23. filter {"options:graphics=opengl11"}
  24. defines{"GRAPHICS_API_OPENGL_11"}
  25. filter {"system:macosx"}
  26. disablewarnings {"deprecated-declarations"}
  27. filter {"system:linux"}
  28. defines {"_GLFW_X11"}
  29. defines {"_GNU_SOURCE"}
  30. -- This is necessary, otherwise compilation will fail since
  31. -- there is no CLOCK_MONOTOMIC. raylib claims to have a workaround
  32. -- to compile under c99 without -D_GNU_SOURCE, but it didn't seem
  33. -- to work. raylib's Makefile also adds this flag, probably why it went
  34. -- unnoticed for so long.
  35. -- It compiles under c11 without -D_GNU_SOURCE, because c11 requires
  36. -- to have CLOCK_MONOTOMIC
  37. -- See: https://github.com/raysan5/raylib/issues/2729
  38. filter{}
  39. end
  40. function get_raylib_dir()
  41. if (os.isdir("raylib-master")) then
  42. return "raylib-master"
  43. end
  44. if (os.isdir("../raylib-master")) then
  45. return "raylib-master"
  46. end
  47. return "raylib"
  48. end
  49. function link_raylib()
  50. links {"raylib"}
  51. raylib_dir = get_raylib_dir();
  52. includedirs {raylib_dir .. "/src" }
  53. includedirs {raylib_dir .."/src/external" }
  54. includedirs {raylib_dir .."/src/external/glfw/include" }
  55. platform_defines()
  56. filter "action:vs*"
  57. defines{"_WINSOCK_DEPRECATED_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"}
  58. dependson {"raylib"}
  59. links {"raylib.lib"}
  60. characterset ("MBCS")
  61. buildoptions { "/Zc:__cplusplus" }
  62. filter "system:windows"
  63. defines{"_WIN32"}
  64. links {"winmm", "gdi32"}
  65. libdirs {"bin/%{cfg.buildcfg}"}
  66. filter "system:linux"
  67. links {"pthread", "m", "dl", "rt", "X11"}
  68. filter "system:macosx"
  69. links {"OpenGL.framework", "Cocoa.framework", "IOKit.framework", "CoreFoundation.framework", "CoreAudio.framework", "CoreVideo.framework", "AudioToolbox.framework"}
  70. filter{}
  71. end
  72. function include_raylib()
  73. raylib_dir = get_raylib_dir();
  74. includedirs {raylib_dir .."/src" }
  75. includedirs {raylib_dir .."/src/external" }
  76. includedirs {raylib_dir .."/src/external/glfw/include" }
  77. platform_defines()
  78. filter "action:vs*"
  79. defines{"_WINSOCK_DEPRECATED_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"}
  80. filter{}
  81. end
  82. project "raylib"
  83. kind "StaticLib"
  84. platform_defines()
  85. location "build"
  86. language "C"
  87. cdialect "C99"
  88. cppdialect "C++17"
  89. targetdir "bin/%{cfg.buildcfg}"
  90. filter "action:vs*"
  91. defines{"_WINSOCK_DEPRECATED_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"}
  92. characterset ("MBCS")
  93. buildoptions { "/Zc:__cplusplus" }
  94. filter{}
  95. raylib_dir = get_raylib_dir();
  96. print ("Using raylib dir " .. raylib_dir);
  97. includedirs {raylib_dir .. "/src", raylib_dir .. "/src/external/glfw/include" }
  98. vpaths
  99. {
  100. ["Header Files"] = { raylib_dir .. "/src/**.h"},
  101. ["Source Files/*"] = { raylib_dir .. "/src/**.c"},
  102. }
  103. files {raylib_dir .. "/src/*.h", raylib_dir .. "/src/*.c"}
  104. removefiles {raylib_dir .. "/src/rcore_*.c"}
  105. filter { "system:macosx", "files:" .. raylib_dir .. "/src/rglfw.c" }
  106. compileas "Objective-C"
  107. filter{}