meson.build 3.2 KB

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