meson.build 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. project('gamingcore', 'cpp', default_options : ['default_library=static', 'cpp_std=c++17'])
  2. src = [
  3. 'io/ImageReader.cpp',
  4. 'math/Math.cpp',
  5. 'math/Box.cpp',
  6. 'math/Frustum.cpp',
  7. 'math/View.cpp',
  8. 'math/Matrix.cpp',
  9. 'math/Plane.cpp',
  10. 'math/Quaternion.cpp',
  11. 'math/Vector.cpp',
  12. 'network/Client.cpp',
  13. 'network/ENet.cpp',
  14. 'network/Packet.cpp',
  15. 'network/Server.cpp',
  16. 'rendering/Shader.cpp',
  17. 'rendering/Texture.cpp',
  18. 'rendering/VertexBuffer.cpp',
  19. 'rendering/Window.cpp',
  20. 'rendering/GL.cpp',
  21. 'data/BitArray.cpp',
  22. 'utils/Buffer.cpp',
  23. 'utils/Clock.cpp',
  24. 'utils/Error.cpp',
  25. 'utils/Logger.cpp',
  26. 'utils/Random.cpp',
  27. 'utils/Utility.cpp',
  28. ]
  29. src_tests = [
  30. 'Main.cpp',
  31. 'tests/ArrayListTests.cpp',
  32. 'tests/ArrayTests.cpp',
  33. 'tests/BitArrayTests.cpp',
  34. 'tests/BufferTests.cpp',
  35. 'tests/BufferedValueTests.cpp',
  36. 'tests/BoxTests.cpp',
  37. 'tests/ClockTests.cpp',
  38. 'tests/ColorTests.cpp',
  39. 'tests/FrustumTests.cpp',
  40. 'tests/HashMapTests.cpp',
  41. 'tests/ListTests.cpp',
  42. 'tests/MatrixStackTests.cpp',
  43. 'tests/MatrixTests.cpp',
  44. 'tests/NetworkTests.cpp',
  45. 'tests/ImageReaderTests.cpp',
  46. 'tests/PlaneTests.cpp',
  47. 'tests/QuaternionTests.cpp',
  48. 'tests/RandomTests.cpp',
  49. 'tests/RingBufferTests.cpp',
  50. 'tests/SplitStringTests.cpp',
  51. 'tests/StackTests.cpp',
  52. 'tests/StringBufferTests.cpp',
  53. 'tests/Test.cpp',
  54. 'tests/TypedBufferTests.cpp',
  55. 'tests/UniquePointerTests.cpp',
  56. 'tests/MathTests.cpp',
  57. 'tests/VectorTests.cpp',
  58. 'tests/ViewTests.cpp',
  59. 'tests/ComponentsTests.cpp',
  60. ]
  61. compiler = meson.get_compiler('cpp')
  62. error_args = compiler.get_supported_arguments([
  63. '-Wcast-align=strict', '-pedantic', '-Wmissing-declarations', '-Wdate-time',
  64. '-Winit-self', '-Woverlength-strings', '-Wsign-promo', '-Wnon-virtual-dtor',
  65. '-Wconversion', '-Woverloaded-virtual', '-Wdeprecated-enum-enum-conversion',
  66. '-Wdisabled-optimization', '-Winvalid-imported-macros', '-Wduplicated-cond',
  67. '-Wdeprecated-enum-float-conversion', '-Wduplicated-branches', '-Wformat=2',
  68. '-Wmissing-braces', '-Wsuggest-override', '-Wcast-qual', '-Wbidi-chars=any',
  69. '-Wzero-as-null-pointer-constant', '-pedantic-errors', '-Wnull-dereference',
  70. '-Wformat-signedness', '-Wfloat-equal', '-Wvolatile', '-Wctor-dtor-privacy',
  71. '-Winfinite-recursion', '-Wshift-overflow=2', '-Wmultichar', '-Walloc-zero',
  72. '-Wcomma-subscript', '-Wold-style-cast', '-Wwrite-strings', '-Wswitch-enum',
  73. '-Wredundant-decls', '-Werror', '-Wsign-conversion', '-Walloca', '-Wshadow',
  74. '-Winvalid-pch', '-Wdeprecated-copy-dtor', '-Wundef', '-Wdouble-promotion',
  75. '-Warith-conversion', '-Wextra', '-Wtrivial-auto-var-init', '-Wlogical-op',
  76. '-Wall', '-Wenum-conversion'
  77. ])
  78. compile_args = compiler.get_supported_arguments([
  79. '-nostdinc++', '-fno-exceptions', '-fno-rtti', '-fno-threadsafe-statics'
  80. ])
  81. link_args = compiler.get_supported_arguments([
  82. '-nodefaultlibs', '-lc', '-lm'
  83. ])
  84. add_global_arguments('-DLODEPNG_NO_COMPILE_CPP', language : 'cpp')
  85. cmake = import('cmake')
  86. glfw_proj = cmake.subproject('glfw')
  87. glfw_includes = glfw_proj.include_directories('glfw')
  88. glfw_dep = glfw_proj.dependency('glfw')
  89. glew_proj = subproject('glew', default_options: 'default_library=static')
  90. glew_includes = glew_proj.get_variable('glew_include')
  91. glew_dep = glew_proj.get_variable('glew_dep')
  92. thread_dep = dependency('threads', static: true)
  93. gl_dep = dependency('GL')
  94. ws2_32_dep = compiler.find_library('ws2_32', required: false)
  95. winmm_dep = compiler.find_library('winmm', required: false)
  96. glu_dep = compiler.find_library('glu32', required: false)
  97. dl_dep = compiler.find_library('dl', required: false)
  98. gamingcore_include = [include_directories('.'), glfw_includes, glew_includes]
  99. lodepng = static_library('lodepng',
  100. sources: 'libs/lodepng/lodepng.cpp',
  101. cpp_args: compile_args,
  102. link_args: link_args)
  103. lodepng_dep = declare_dependency(link_with: lodepng)
  104. gamingcore = static_library('gamingcore',
  105. sources: src,
  106. include_directories: gamingcore_include,
  107. dependencies: [thread_dep, glfw_dep, glew_dep, gl_dep, ws2_32_dep, winmm_dep, glu_dep, dl_dep, glu_dep, lodepng_dep],
  108. cpp_args: error_args + compile_args,
  109. link_args: link_args)
  110. gamingcore_dep = declare_dependency(
  111. include_directories: gamingcore_include,
  112. link_with: gamingcore)
  113. executable('tests',
  114. sources: src_tests,
  115. dependencies: gamingcore_dep,
  116. cpp_args: error_args + compile_args + ['-DLOG_LEVEL=4'],
  117. link_args: link_args)