raylib_premake5.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. function platform_defines()
  2. defines{"PLATFORM_DESKTOP"}
  3. filter {"options:graphics=opengl43"}
  4. defines{"GRAPHICS_API_OPENGL_43"}
  5. filter {"options:graphics=opengl33"}
  6. defines{"GRAPHICS_API_OPENGL_33"}
  7. filter {"options:graphics=opengl21"}
  8. defines{"GRAPHICS_API_OPENGL_21"}
  9. filter {"options:graphics=opengl11"}
  10. defines{"GRAPHICS_API_OPENGL_11"}
  11. filter {"system:macosx"}
  12. disablewarnings {"deprecated-declarations"}
  13. filter {"system:linux"}
  14. defines {"_GNU_SOURCE"}
  15. -- This is necessary, otherwise compilation will fail since
  16. -- there is no CLOCK_MONOTOMIC. raylib claims to have a workaround
  17. -- to compile under c99 without -D_GNU_SOURCE, but it didn't seem
  18. -- to work. raylib's Makefile also adds this flag, probably why it went
  19. -- unnoticed for so long.
  20. -- It compiles under c11 without -D_GNU_SOURCE, because c11 requires
  21. -- to have CLOCK_MONOTOMIC
  22. -- See: https://github.com/raysan5/raylib/issues/2729
  23. filter{}
  24. end
  25. function get_raylib_dir()
  26. if (os.isdir("raylib-master")) then
  27. return "raylib-master"
  28. end
  29. if (os.isdir("../raylib-master")) then
  30. return "raylib-master"
  31. end
  32. return "raylib"
  33. end
  34. function link_raylib()
  35. links {"raylib"}
  36. raylib_dir = get_raylib_dir();
  37. includedirs {raylib_dir .. "/src" }
  38. includedirs {raylib_dir .."/src/external" }
  39. includedirs {raylib_dir .."/src/external/glfw/include" }
  40. platform_defines()
  41. filter "action:vs*"
  42. defines{"_WINSOCK_DEPRECATED_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"}
  43. dependson {"raylib"}
  44. links {"raylib.lib"}
  45. characterset ("MBCS")
  46. filter "system:windows"
  47. defines{"_WIN32"}
  48. links {"winmm", "kernel32", "opengl32", "gdi32"}
  49. libdirs {"_bin/%{cfg.buildcfg}"}
  50. filter "system:linux"
  51. links {"pthread", "GL", "m", "dl", "rt", "X11"}
  52. filter "system:macosx"
  53. links {"OpenGL.framework", "Cocoa.framework", "IOKit.framework", "CoreFoundation.framework", "CoreAudio.framework", "CoreVideo.framework"}
  54. filter{}
  55. end
  56. function include_raylib()
  57. raylib_dir = get_raylib_dir();
  58. includedirs {raylib_dir .."/src" }
  59. includedirs {raylib_dir .."/src/external" }
  60. includedirs {raylib_dir .."/src/external/glfw/include" }
  61. platform_defines()
  62. filter "action:vs*"
  63. defines{"_WINSOCK_DEPRECATED_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"}
  64. filter{}
  65. end
  66. project "raylib"
  67. kind "StaticLib"
  68. platform_defines()
  69. location "_build"
  70. language "C"
  71. targetdir "_bin/%{cfg.buildcfg}"
  72. filter "action:vs*"
  73. defines{"_WINSOCK_DEPRECATED_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS"}
  74. characterset ("MBCS")
  75. filter{}
  76. raylib_dir = get_raylib_dir();
  77. print ("Using raylib dir " .. raylib_dir);
  78. includedirs {raylib_dir .. "/src", raylib_dir .. "/src/external/glfw/include" }
  79. vpaths
  80. {
  81. ["Header Files"] = { raylib_dir .. "/src/**.h"},
  82. ["Source Files/*"] = { raylib_dir .. "/src/**.c"},
  83. }
  84. files {raylib_dir .. "/src/*.h", raylib_dir .. "/src/*.c"}
  85. removefiles {raylib_dir .. "/src/rcore_*.c"}
  86. filter { "system:macosx", "files:" .. raylib_dir .. "/src/rglfw.c" }
  87. compileas "Objective-C"
  88. filter{}