2
0

meson.build 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. project('cglm', 'c',
  2. version : '0.9.3',
  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. build_by_default: not meson.is_subproject()
  83. )
  84. cglm_dep = declare_dependency(
  85. link_with : cglm_lib,
  86. dependencies : cglm_deps,
  87. compile_args : cglm_args,
  88. include_directories : cglm_inc,
  89. version : meson.project_version()
  90. )
  91. if meson.version().version_compare('>= 0.54.0')
  92. meson.override_dependency('cglm', cglm_dep)
  93. endif
  94. if cglm_install
  95. install_subdir('include/cglm', install_dir : get_option('includedir'))
  96. pkg = import('pkgconfig')
  97. pkg.generate(
  98. name : 'cglm',
  99. libraries : cglm_lib,
  100. extra_cflags : cglm_args,
  101. version : meson.project_version(),
  102. url : 'https://github.com/recp/cglm',
  103. description : 'OpenGL Mathematics (glm) for C'
  104. )
  105. endif
  106. if get_option('build_tests') == true
  107. test_src = files(
  108. 'test/runner.c',
  109. 'test/src/test_bezier.c',
  110. 'test/src/test_clamp.c',
  111. 'test/src/test_common.c',
  112. 'test/src/test_euler.c',
  113. 'test/src/tests.c',
  114. 'test/src/test_struct.c',
  115. )
  116. test_exe = executable('tests',
  117. test_src,
  118. dependencies : cglm_dep,
  119. c_args : '-DGLM_TESTS_NO_COLORFUL_OUTPUT'
  120. )
  121. test('cglm.tests', test_exe)
  122. endif