-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
122 lines (107 loc) · 4.11 KB
/
Copy pathmeson.build
File metadata and controls
122 lines (107 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
project('simpletiff', 'cpp',
version : '0.0.1',
license : 'Apache-2.0',
meson_version : '>=1.1',
default_options : [
'warning_level=2',
'cpp_std=c++20',
'default_library=shared',
])
cpp = meson.get_compiler('cpp')
is_wasm = host_machine.cpu_family() == 'wasm32' or host_machine.cpu_family() == 'wasm64'
# ---------------------------------------------------------------------------
# Dependencies
# ---------------------------------------------------------------------------
# aifocore provides the header-only `aifocore/status/result.h` and
# `aifocore/platform/portability.h` used throughout simpletiff. It is not on
# wrapdb, so it is resolved from the standalone NKI-AI/aifocore repo via
# subprojects/aifocore.wrap.
# All wrap files in subprojects/ declare a `[provide]` section, so a plain
# `dependency()` transparently falls back to the bundled wrap when the library
# is not found on the system.
aifocore_dep = dependency('aifocore')
zlib_dep = dependency('zlib')
zstd_dep = dependency('libzstd')
png_dep = dependency('libpng')
simpletiff_deps = [aifocore_dep, zlib_dep, zstd_dep, png_dep]
simpletiff_defines = ['-DSIMPLETIFF_HAS_PNG']
# JPEG decoder backend.
jpeg_extra_inc = []
if get_option('jpeg_decoder') == 'libjpeg'
jpeg_dep = dependency('libjpeg') # libjpeg-turbo wrap provides `libjpeg`
simpletiff_deps += jpeg_dep
jpeg_source = 'src/io_utils_libjpeg.cpp'
else
# jpgd ships in the NKI-AI/jpeg-compressor repo and is pulled in via
# subprojects/jpeg-compressor.wrap (provides the `jpgd` dependency).
jpgd_dep = dependency('jpgd', fallback : ['jpeg-compressor', 'jpgd_dep'])
simpletiff_deps += jpgd_dep
# io_utils_jpgd.cpp includes "jpeg-compressor/jpgd.h", but the subproject
# exports its headers at its own root. The wrap unpacks the repo to
# subprojects/jpeg-compressor/, so add subprojects/ to the include path to
# make the `jpeg-compressor/` prefix resolve.
jpeg_extra_inc = [include_directories('subprojects')]
jpeg_source = 'src/io_utils_jpgd.cpp'
endif
# OpenJPEG (JPEG2000). Not on wrapdb, so this is a system dependency only.
# Always disabled for wasm targets.
openjpeg_opt = get_option('with_openjpeg')
if is_wasm
openjpeg_opt = openjpeg_opt.disable_auto_if(true)
endif
openjpeg_dep = dependency('libopenjp2', required : openjpeg_opt)
if openjpeg_dep.found()
simpletiff_deps += openjpeg_dep
simpletiff_defines += '-DSIMPLETIFF_HAS_OPENJPEG'
endif
# ---------------------------------------------------------------------------
# Library
# ---------------------------------------------------------------------------
inc = include_directories('include')
simpletiff_sources = [
'src/ccitt.cpp',
'src/ccitt_tables.cpp',
'src/deflate.cpp',
'src/image_writer.cpp',
'src/index.cpp',
'src/io_utils_common.cpp',
'src/jpeg2000.cpp',
'src/lzw.cpp',
'src/ndpi_mcu_tiling.cpp',
'src/predictor.cpp',
'src/reader.cpp',
'src/tiff_parser.cpp',
'src/zstd.cpp',
jpeg_source,
]
simpletiff_lib = library('simpletiff',
simpletiff_sources,
include_directories : [inc] + jpeg_extra_inc,
dependencies : simpletiff_deps,
cpp_args : simpletiff_defines + cpp.get_supported_arguments(['-Wno-unused-parameter']),
install : true)
install_subdir('include/simpletiff', install_dir : get_option('includedir'))
# `simpletiff_defines` are public (consumers gate optional includes such as
# `image_writer.h` on `SIMPLETIFF_HAS_PNG`), mirroring Bazel's public `defines`.
simpletiff_dep = declare_dependency(
include_directories : inc,
link_with : simpletiff_lib,
compile_args : simpletiff_defines,
dependencies : simpletiff_deps)
meson.override_dependency('simpletiff', simpletiff_dep)
import('pkgconfig').generate(simpletiff_lib,
name : 'simpletiff',
description : 'Fast TIFF reader library for whole-slide imaging',
subdirs : 'simpletiff')
# ---------------------------------------------------------------------------
# Optional components
# ---------------------------------------------------------------------------
if get_option('build_tests')
subdir('tests')
endif
if get_option('build_examples')
subdir('examples')
endif
if get_option('build_benchmarks')
subdir('benchmarks')
endif