meson.build 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. project(
  2. 'Little-CMS',
  3. 'c',
  4. version: '2.16',
  5. meson_version: '>=0.49.0',
  6. default_options: ['c_std=gnu11']
  7. )
  8. version_components = meson.project_version().split('.')
  9. library_version = '@0@.0.@1@'.format(
  10. version_components.get(0, 0),
  11. version_components.get(1, 0),
  12. )
  13. version_cfg = configuration_data()
  14. version_cfg.set('LCMS2_VERSION_MAJOR', version_components.get(0, 0))
  15. version_cfg.set('LCMS2_VERSION_MINOR', version_components.get(1, 0))
  16. version_cfg.set('LCMS2_VERSION_MICRO', version_components.get(2, 0))
  17. version_cfg.set_quoted('LCMS2_VERSION', meson.project_version())
  18. cc = meson.get_compiler('c')
  19. is_visual_studio = cc.get_argument_syntax() == 'msvc'
  20. cargs = []
  21. if not is_visual_studio and cc.has_function_attribute('visibility:hidden')
  22. cargs += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1'
  23. endif
  24. if host_machine.endian() == 'big'
  25. cargs += '-DWORDS_BIGENDIAN=1'
  26. endif
  27. # Check for threadsafe variants of gmtime
  28. # MinGW needs _POSIX_C_SOURCE or _POSIX_THREAD_SAFE_FUNCTIONS defined
  29. # to make gmtime_r and pthread_time.h available
  30. if host_machine.system() == 'windows' and not is_visual_studio
  31. cargs += ['-D_POSIX_C_SOURCE=199503L']
  32. endif
  33. if cc.has_header_symbol(
  34. 'time.h',
  35. 'gmtime_r',
  36. args: cargs,
  37. )
  38. cargs += '-DHAVE_GMTIME_R=1'
  39. elif cc.has_header_symbol('time.h', 'gmtime_s')
  40. if cc.links(
  41. '''
  42. #include <time.h>
  43. int main() {
  44. time_t t;
  45. struct tm m;
  46. gmtime_s(&m, &t);
  47. return 0;
  48. }
  49. ''',
  50. name: 'gmtime_s can be used',
  51. )
  52. cargs += '-DHAVE_GMTIME_S=1'
  53. endif
  54. endif
  55. jpeg_dep = dependency('libjpeg', required: get_option('jpeg'))
  56. tiff_dep = dependency('libtiff-4', required: get_option('tiff'))
  57. if (
  58. not cc.compiles(
  59. '''
  60. #include <emmintrin.h>
  61. int main() { __m128i n = _mm_set1_epi8(42); }
  62. ''',
  63. name: 'supports SSE2 intrinsics',
  64. )
  65. )
  66. cargs += '-DCMS_DONT_USE_SSE2=1'
  67. endif
  68. if is_visual_studio
  69. m_dep = []
  70. threads_dep = []
  71. deps = []
  72. else
  73. m_dep = cc.find_library('m', required: false)
  74. threads_dep = dependency('threads')
  75. if cc.has_function('pthread_mutex_lock', dependencies: threads_dep)
  76. cargs += '-DHasTHREADS=1'
  77. else
  78. cargs += '-DHasTHREADS=0'
  79. endif
  80. deps = [m_dep, threads_dep]
  81. endif
  82. if cc.has_header_symbol('time.h', 'timespec_get')
  83. cargs += '-DHAVE_TIMESPEC_GET=1'
  84. endif
  85. win = import('windows')
  86. subdir('include')
  87. subdir('src')
  88. subdir('testbed')
  89. if get_option('utils')
  90. subdir('utils')
  91. endif
  92. if get_option('samples')
  93. subdir('utils/samples')
  94. endif
  95. extra_libraries = []
  96. subdir('plugins')
  97. pkg = import('pkgconfig')
  98. pkg.generate(liblcms2_lib,
  99. description: 'LCMS Color Management Library',
  100. libraries: extra_libraries
  101. )