comparison mupdf-source/thirdparty/lcms2/meson.build @ 3:2c135c81b16c

MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:44:09 +0200
parents b50eed0cc0ef
children
comparison
equal deleted inserted replaced
0:6015a75abc2d 3:2c135c81b16c
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
9 version_components = meson.project_version().split('.')
10
11 library_version = '@0@.0.@1@'.format(
12 version_components.get(0, 0),
13 version_components.get(1, 0),
14 )
15
16 version_cfg = configuration_data()
17 version_cfg.set('LCMS2_VERSION_MAJOR', version_components.get(0, 0))
18 version_cfg.set('LCMS2_VERSION_MINOR', version_components.get(1, 0))
19 version_cfg.set('LCMS2_VERSION_MICRO', version_components.get(2, 0))
20 version_cfg.set_quoted('LCMS2_VERSION', meson.project_version())
21
22 cc = meson.get_compiler('c')
23
24 is_visual_studio = cc.get_argument_syntax() == 'msvc'
25
26 cargs = []
27
28 if not is_visual_studio and cc.has_function_attribute('visibility:hidden')
29 cargs += '-DHAVE_FUNC_ATTRIBUTE_VISIBILITY=1'
30 endif
31
32 if host_machine.endian() == 'big'
33 cargs += '-DWORDS_BIGENDIAN=1'
34 endif
35
36
37 # Check for threadsafe variants of gmtime
38 # MinGW needs _POSIX_C_SOURCE or _POSIX_THREAD_SAFE_FUNCTIONS defined
39 # to make gmtime_r and pthread_time.h available
40 if host_machine.system() == 'windows' and not is_visual_studio
41 cargs += ['-D_POSIX_C_SOURCE=199503L']
42 endif
43
44 if cc.has_header_symbol(
45 'time.h',
46 'gmtime_r',
47 args: cargs,
48 )
49 cargs += '-DHAVE_GMTIME_R=1'
50 elif cc.has_header_symbol('time.h', 'gmtime_s')
51 if cc.links(
52 '''
53 #include <time.h>
54
55 int main() {
56 time_t t;
57 struct tm m;
58 gmtime_s(&m, &t);
59 return 0;
60 }
61 ''',
62 name: 'gmtime_s can be used',
63 )
64 cargs += '-DHAVE_GMTIME_S=1'
65 endif
66 endif
67
68 jpeg_dep = dependency('libjpeg', required: get_option('jpeg'))
69
70 tiff_dep = dependency('libtiff-4', required: get_option('tiff'))
71
72 if (
73 not cc.compiles(
74 '''
75 #include <emmintrin.h>
76 int main() { __m128i n = _mm_set1_epi8(42); }
77 ''',
78 name: 'supports SSE2 intrinsics',
79 )
80 )
81 cargs += '-DCMS_DONT_USE_SSE2=1'
82 endif
83
84
85 if is_visual_studio
86 m_dep = []
87 threads_dep = []
88 deps = []
89 else
90 m_dep = cc.find_library('m', required: false)
91 threads_dep = dependency('threads')
92
93 if cc.has_function('pthread_mutex_lock', dependencies: threads_dep)
94 cargs += '-DHasTHREADS=1'
95 else
96 cargs += '-DHasTHREADS=0'
97 endif
98
99 deps = [m_dep, threads_dep]
100 endif
101
102
103 if cc.has_header_symbol('time.h', 'timespec_get')
104 cargs += '-DHAVE_TIMESPEC_GET=1'
105 endif
106
107 win = import('windows')
108
109 subdir('include')
110 subdir('src')
111 subdir('testbed')
112
113 if get_option('utils')
114 subdir('utils')
115 endif
116
117 if get_option('samples')
118 subdir('utils/samples')
119 endif
120
121 extra_libraries = []
122 subdir('plugins')
123
124 pkg = import('pkgconfig')
125 pkg.generate(liblcms2_lib,
126 description: 'LCMS Color Management Library',
127 libraries: extra_libraries
128 )