meson.build 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. project('cglm', 'c',
  2. version : '0.8.5',
  3. license : 'mit',
  4. default_options : [
  5. 'c_std=c11',
  6. 'werror=true',
  7. 'warning_level=2',
  8. 'buildtype=release'
  9. ]
  10. )
  11. cc = meson.get_compiler('c')
  12. cglm_install = get_option('install')
  13. cglm_deps = cc.find_library('m', required : false)
  14. cglm_args = []
  15. build_args = []
  16. if get_option('default_library') == 'static'
  17. cglm_args = '-DCGLM_STATIC'
  18. endif
  19. if host_machine.system() == 'windows'
  20. build_args = '-DCGLM_EXPORTS'
  21. endif
  22. cglm_inc = include_directories('include')
  23. cglm_src = files(
  24. 'src/affine.c',
  25. 'src/affine2d.c',
  26. 'src/bezier.c',
  27. 'src/box.c',
  28. 'src/cam.c',
  29. 'src/curve.c',
  30. 'src/ease.c',
  31. 'src/euler.c',
  32. 'src/frustum.c',
  33. 'src/io.c',
  34. 'src/mat2.c',
  35. 'src/mat3.c',
  36. 'src/mat4.c',
  37. 'src/plane.c',
  38. 'src/project.c',
  39. 'src/quat.c',
  40. 'src/ray.c',
  41. 'src/sphere.c',
  42. 'src/vec2.c',
  43. 'src/vec3.c',
  44. 'src/vec4.c',
  45. 'src/clipspace/ortho_lh_no.c',
  46. 'src/clipspace/ortho_lh_zo.c',
  47. 'src/clipspace/ortho_rh_no.c',
  48. 'src/clipspace/ortho_rh_zo.c',
  49. 'src/clipspace/persp_lh_no.c',
  50. 'src/clipspace/persp_lh_zo.c',
  51. 'src/clipspace/persp_rh_no.c',
  52. 'src/clipspace/persp_rh_zo.c',
  53. 'src/clipspace/view_lh_no.c',
  54. 'src/clipspace/view_lh_zo.c',
  55. 'src/clipspace/view_rh_no.c',
  56. 'src/clipspace/view_rh_zo.c',
  57. )
  58. cglm_lib = library('cglm',
  59. cglm_src,
  60. install : cglm_install,
  61. dependencies : cglm_deps,
  62. c_args : [ build_args, cglm_args ],
  63. version : meson.project_version(),
  64. soversion : '0'
  65. )
  66. cglm_dep = declare_dependency(
  67. link_with : cglm_lib,
  68. dependencies : cglm_deps,
  69. compile_args : cglm_args,
  70. include_directories : cglm_inc,
  71. version : meson.project_version()
  72. )
  73. if meson.version().version_compare('>= 0.54.0')
  74. meson.override_dependency('cglm', cglm_dep)
  75. endif
  76. if cglm_install
  77. install_subdir('include/cglm', install_dir : get_option('includedir'))
  78. pkg = import('pkgconfig')
  79. pkg.generate(
  80. name : 'cglm',
  81. libraries : cglm_lib,
  82. extra_cflags : cglm_args,
  83. version : meson.project_version(),
  84. url : 'https://github.com/recp/cglm',
  85. description : 'OpenGL Mathematics (glm) for C'
  86. )
  87. endif
  88. if get_option('build_tests') == true
  89. test_src = files(
  90. 'test/runner.c',
  91. 'test/src/test_bezier.c',
  92. 'test/src/test_cam.c',
  93. 'test/src/test_cam_lh_no.c',
  94. 'test/src/test_cam_lh_zo.c',
  95. 'test/src/test_cam_rh_no.c',
  96. 'test/src/test_cam_rh_zo.c',
  97. 'test/src/test_clamp.c',
  98. 'test/src/test_common.c',
  99. 'test/src/test_euler.c',
  100. 'test/src/tests.c',
  101. 'test/src/test_struct.c',
  102. )
  103. test_exe = executable('tests',
  104. test_src,
  105. dependencies : cglm_dep,
  106. c_args : '-DGLM_TESTS_NO_COLORFUL_OUTPUT'
  107. )
  108. test('cglm.tests', test_exe)
  109. endif