meson.build 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. project('cglm', 'c',
  2. version : '0.9.0',
  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/euler.c',
  25. 'src/affine.c',
  26. 'src/io.c',
  27. 'src/quat.c',
  28. 'src/cam.c',
  29. 'src/vec2.c',
  30. 'src/ivec2.c',
  31. 'src/vec3.c',
  32. 'src/ivec3.c',
  33. 'src/vec4.c',
  34. 'src/ivec4.c',
  35. 'src/mat2.c',
  36. 'src/mat3.c',
  37. 'src/mat4.c',
  38. 'src/plane.c',
  39. 'src/frustum.c',
  40. 'src/box.c',
  41. 'src/project.c',
  42. 'src/sphere.c',
  43. 'src/ease.c',
  44. 'src/curve.c',
  45. 'src/bezier.c',
  46. 'src/ray.c',
  47. 'src/affine2d.c',
  48. 'src/clipspace/ortho_lh_no.c',
  49. 'src/clipspace/ortho_lh_zo.c',
  50. 'src/clipspace/ortho_rh_no.c',
  51. 'src/clipspace/ortho_rh_zo.c',
  52. 'src/clipspace/persp_lh_no.c',
  53. 'src/clipspace/persp_lh_zo.c',
  54. 'src/clipspace/persp_rh_no.c',
  55. 'src/clipspace/persp_rh_zo.c',
  56. 'src/clipspace/view_lh_no.c',
  57. 'src/clipspace/view_lh_zo.c',
  58. 'src/clipspace/view_rh_no.c',
  59. 'src/clipspace/view_rh_zo.c',
  60. 'src/clipspace/project_no.c',
  61. 'src/clipspace/project_zo.c'
  62. )
  63. cglm_lib = library('cglm',
  64. cglm_src,
  65. install : cglm_install,
  66. dependencies : cglm_deps,
  67. c_args : [ build_args, cglm_args ],
  68. version : meson.project_version(),
  69. soversion : '0'
  70. )
  71. cglm_dep = declare_dependency(
  72. link_with : cglm_lib,
  73. dependencies : cglm_deps,
  74. compile_args : cglm_args,
  75. include_directories : cglm_inc,
  76. version : meson.project_version()
  77. )
  78. if meson.version().version_compare('>= 0.54.0')
  79. meson.override_dependency('cglm', cglm_dep)
  80. endif
  81. if cglm_install
  82. install_subdir('include/cglm', install_dir : get_option('includedir'))
  83. pkg = import('pkgconfig')
  84. pkg.generate(
  85. name : 'cglm',
  86. libraries : cglm_lib,
  87. extra_cflags : cglm_args,
  88. version : meson.project_version(),
  89. url : 'https://github.com/recp/cglm',
  90. description : 'OpenGL Mathematics (glm) for C'
  91. )
  92. endif
  93. if get_option('build_tests') == true
  94. test_src = files(
  95. 'test/runner.c',
  96. 'test/src/test_bezier.c',
  97. 'test/src/test_cam.c',
  98. 'test/src/test_cam_lh_no.c',
  99. 'test/src/test_cam_lh_zo.c',
  100. 'test/src/test_cam_rh_no.c',
  101. 'test/src/test_cam_rh_zo.c',
  102. 'test/src/test_clamp.c',
  103. 'test/src/test_common.c',
  104. 'test/src/test_euler.c',
  105. 'test/src/tests.c',
  106. 'test/src/test_struct.c',
  107. )
  108. test_exe = executable('tests',
  109. test_src,
  110. dependencies : cglm_dep,
  111. c_args : '-DGLM_TESTS_NO_COLORFUL_OUTPUT'
  112. )
  113. test('cglm.tests', test_exe)
  114. endif