meson.build 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. project('megapixels', 'c', version: '1.5.2')
  2. gnome = import('gnome')
  3. gtkdep = dependency('gtk4')
  4. libfeedback = dependency('libfeedback-0.0')
  5. tiff = dependency('libtiff-4')
  6. zbar = dependency('zbar')
  7. threads = dependency('threads')
  8. # gl = dependency('gl')
  9. epoxy = dependency('epoxy')
  10. # We only build in support for Wayland/X11 if GTK did so
  11. optdeps = []
  12. if gtkdep.get_variable('targets').contains('wayland')
  13. optdeps += dependency('gtk4-wayland')
  14. optdeps += dependency('wayland-client')
  15. endif
  16. if gtkdep.get_variable('targets').contains('x11')
  17. optdeps += dependency('gtk4-x11')
  18. optdeps += dependency('x11')
  19. optdeps += dependency('xrandr')
  20. endif
  21. cc = meson.get_compiler('c')
  22. libm = cc.find_library('m', required: false)
  23. subdir('data')
  24. conf = configuration_data()
  25. conf.set_quoted('DATADIR', join_paths(get_option('prefix'), get_option('datadir')))
  26. conf.set_quoted('SYSCONFDIR', get_option('sysconfdir'))
  27. configure_file(
  28. output: 'config.h',
  29. configuration: conf)
  30. add_global_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'c')
  31. # Define DEBUG for debug builds only (debugoptimized is not included on this one)
  32. if get_option('buildtype') == 'debug'
  33. add_global_arguments('-DDEBUG', language: 'c')
  34. endif
  35. # Workaround for libtiff having ABI changes but not changing the internal
  36. # version number
  37. if get_option('tiffcfapattern')
  38. add_global_arguments('-DLIBTIFF_CFA_PATTERN', language: 'c')
  39. endif
  40. executable('megapixels',
  41. 'src/camera.c',
  42. 'src/camera_config.c',
  43. 'src/device.c',
  44. 'src/flash.c',
  45. 'src/gl_util.c',
  46. 'src/gles2_debayer.c',
  47. 'src/ini.c',
  48. 'src/io_pipeline.c',
  49. 'src/main.c',
  50. 'src/matrix.c',
  51. 'src/mode.c',
  52. 'src/pipeline.c',
  53. 'src/process_pipeline.c',
  54. 'src/zbar_pipeline.c',
  55. resources,
  56. include_directories: 'src/',
  57. dependencies: [gtkdep, libfeedback, libm, tiff, zbar, threads, epoxy] + optdeps,
  58. install: true,
  59. link_args: '-Wl,-ldl')
  60. install_data(
  61. [
  62. 'config/pine64,pinephone-1.0.ini',
  63. 'config/pine64,pinephone-1.1.ini',
  64. 'config/pine64,pinephone-1.2.ini',
  65. 'config/pine64,pinetab.ini',
  66. 'config/xiaomi,scorpio.ini',
  67. ],
  68. install_dir: get_option('datadir') / 'megapixels/config/')
  69. # Tools
  70. executable('megapixels-list-devices',
  71. 'tools/list_devices.c',
  72. 'src/device.c',
  73. 'src/mode.c',
  74. include_directories: 'src/',
  75. dependencies: [gtkdep],
  76. install: true)
  77. executable('megapixels-camera-test',
  78. 'tools/camera_test.c',
  79. 'src/camera.c',
  80. 'src/device.c',
  81. 'src/mode.c',
  82. include_directories: 'src/',
  83. dependencies: [gtkdep],
  84. install: true)
  85. # Formatting
  86. clang_format = find_program('clang-format-14', required: false)
  87. if clang_format.found()
  88. format_files = [
  89. 'data/blit.frag',
  90. 'data/blit.vert',
  91. 'data/debayer.frag',
  92. 'data/debayer.vert',
  93. 'data/solid.frag',
  94. 'data/solid.vert',
  95. 'src/camera.c',
  96. 'src/camera.h',
  97. 'src/camera_config.c',
  98. 'src/camera_config.h',
  99. 'src/device.c',
  100. 'src/device.h',
  101. 'src/flash.c',
  102. 'src/flash.h',
  103. 'src/gl_util.c',
  104. 'src/gl_util.h',
  105. 'src/gles2_debayer.c',
  106. 'src/gles2_debayer.h',
  107. 'src/io_pipeline.c',
  108. 'src/io_pipeline.h',
  109. 'src/main.c',
  110. 'src/main.h',
  111. 'src/matrix.c',
  112. 'src/matrix.h',
  113. 'src/mode.c',
  114. 'src/mode.h',
  115. 'src/pipeline.c',
  116. 'src/pipeline.h',
  117. 'src/process_pipeline.c',
  118. 'src/process_pipeline.h',
  119. 'src/zbar_pipeline.c',
  120. 'src/zbar_pipeline.h',
  121. 'tools/camera_test.c',
  122. 'tools/list_devices.c',
  123. ]
  124. run_target('clang-format',
  125. command: ['clang-format.sh', '-i'] + format_files)
  126. run_target('clang-format-check',
  127. command: ['clang-format.sh', '-n', '-Werror'] + format_files)
  128. endif