|
| 1 | +project( |
| 2 | + 'exiv2', |
| 3 | + 'cpp', |
| 4 | + version: '1.0.0', |
| 5 | + meson_version: '>=0.49.0', |
| 6 | + default_options: ['warning_level=1', 'cpp_std=c++17'], |
| 7 | +) |
| 8 | + |
| 9 | +cargs = [] |
| 10 | +cpp = meson.get_compiler('cpp') |
| 11 | +if host_machine.system() == 'windows' and get_option('default_library') != 'static' |
| 12 | + cargs += '-DEXIV2API=__declspec(dllexport)' |
| 13 | +elif cpp.has_function_attribute('visibility') |
| 14 | + cargs += '-DEXIV2API=__attribute__((visibility("default")))' |
| 15 | +else |
| 16 | + cargs += '-DEXIV2API=' |
| 17 | +endif |
| 18 | + |
| 19 | +if host_machine.system() == 'windows' |
| 20 | + if cpp.get_argument_syntax() == 'gcc' |
| 21 | + add_project_arguments('-D__USE_MINGW_ANSI_STDIO', '-D__MINGW_USE_VC2005_COMPAT', language: 'cpp') |
| 22 | + else |
| 23 | + add_project_arguments('-DNOMINMAX', language: 'cpp') |
| 24 | + endif |
| 25 | +endif |
| 26 | + |
| 27 | +exiv_api = configuration_data() |
| 28 | +exiv_conf = configure_file(output: 'exiv2lib_export.h', configuration: exiv_api) |
| 29 | + |
| 30 | +cdata = configuration_data() |
| 31 | +cdata.set('EXV_PACKAGE_NAME', meson.project_name()) |
| 32 | +ver = meson.project_version().split('.') |
| 33 | +cdata.set('PROJECT_VERSION_MAJOR', ver[0]) |
| 34 | +cdata.set('PROJECT_VERSION_MINOR', ver[1]) |
| 35 | +cdata.set('PROJECT_VERSION_PATCH', ver[2]) |
| 36 | +cdata.set('PROJECT_VERSION_TWEAK', 9) |
| 37 | +cdata.set('PROJECT_VERSION', '@0@.@1@'.format(meson.project_version(), cdata.get('PROJECT_VERSION_TWEAK'))) |
| 38 | +cdata.set('EXV_PACKAGE_VERSION', '@0@.@1@'.format(meson.project_version(), cdata.get('PROJECT_VERSION_TWEAK'))) |
| 39 | +cdata.set('EXV_PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), cdata.get('PROJECT_VERSION'))) |
| 40 | + |
| 41 | +cdata.set('EXV_HAVE_MMAP', cpp.has_function('mmap')) |
| 42 | +cdata.set('EXV_HAVE_MUNMAP', cpp.has_function('munmap')) |
| 43 | +cdata.set('EXV_HAVE_STRERROR_R', cpp.has_function('strerror_r')) |
| 44 | +cdata.set('EXV_STRERROR_R_CHAR_P', not cpp.compiles('#include <string.h>\nint strerror_r(int,char*,size_t);int main(){}')) |
| 45 | + |
| 46 | +cdata.set('EXV_ENABLE_BMFF', get_option('bmff')) |
| 47 | +cdata.set('EXV_HAVE_LENSDATA', get_option('lensdata')) |
| 48 | +cdata.set('EXV_ENABLE_VIDEO', get_option('video')) |
| 49 | + |
| 50 | +deps = [] |
| 51 | +deps += cpp.find_library('ws2_32', required: host_machine.system() == 'windows') |
| 52 | + |
| 53 | +# This makes assumptions that the libcpp is the GNU one on Linux systems |
| 54 | +if cpp.get_argument_syntax() == 'gcc' and cpp.version().version_compare('<9') |
| 55 | + if host_machine.system() == 'linux' |
| 56 | + deps += cpp.find_library('stdc++fs') |
| 57 | + elif cpp.get_id() == 'clang' |
| 58 | + deps += cpp.find_library('c++fs') |
| 59 | + endif |
| 60 | +endif |
| 61 | + |
| 62 | +brotli_dep = dependency('libbrotlidec', disabler: true, required: false) |
| 63 | +if brotli_dep.found() |
| 64 | + deps += brotli_dep |
| 65 | +endif |
| 66 | + |
| 67 | +curl_dep = dependency('libcurl', disabler: true, required: get_option('curl')) |
| 68 | +if curl_dep.found() |
| 69 | + deps += curl_dep |
| 70 | +endif |
| 71 | + |
| 72 | +expat_dep = dependency('expat', disabler: true, required: get_option('xmp')) |
| 73 | +if expat_dep.found() |
| 74 | + deps += expat_dep |
| 75 | +endif |
| 76 | + |
| 77 | +inih_dep = dependency('INIReader', disabler: true, required: get_option('inih')) |
| 78 | +if inih_dep.found() |
| 79 | + deps += inih_dep |
| 80 | +endif |
| 81 | + |
| 82 | +zlib_dep = dependency('zlib', disabler: true, required: get_option('png')) |
| 83 | +if zlib_dep.found() |
| 84 | + deps += zlib_dep |
| 85 | +endif |
| 86 | + |
| 87 | +if meson.version().version_compare('>= 0.60') |
| 88 | + iconv_dep = dependency('iconv', disabler: true, required: get_option('iconv')) |
| 89 | +else |
| 90 | + iconv_dep = dependency('', disabler: true, required: false) |
| 91 | +endif |
| 92 | +if iconv_dep.found() |
| 93 | + deps += iconv_dep |
| 94 | +endif |
| 95 | + |
| 96 | +if meson.version().version_compare('>= 0.60') |
| 97 | + intl_dep = dependency('intl', required: get_option('nls')) |
| 98 | +else |
| 99 | + intl_dep = dependency('', required: false) |
| 100 | +endif |
| 101 | +if intl_dep.found() |
| 102 | + add_project_arguments('-DEXV_LOCALEDIR="@0@"'.format(get_option('prefix') / get_option('localedir')), language: 'cpp') |
| 103 | + deps += intl_dep |
| 104 | +endif |
| 105 | + |
| 106 | +cdata.set('EXV_ENABLE_INIH', inih_dep.found()) |
| 107 | +cdata.set('EXV_HAVE_XMP_TOOLKIT', expat_dep.found()) |
| 108 | +cdata.set('EXV_HAVE_BROTLI', brotli_dep.found()) |
| 109 | +cdata.set('EXV_HAVE_ICONV', iconv_dep.found()) |
| 110 | +cdata.set('EXV_HAVE_LIBZ', zlib_dep.found()) |
| 111 | +cdata.set('EXV_USE_CURL', curl_dep.found()) |
| 112 | +cdata.set('EXV_ENABLE_NLS', intl_dep.found()) |
| 113 | +cdata.set('EXV_ENABLE_WEBREADY', curl_dep.found()) |
| 114 | + |
| 115 | +cfile = configure_file( |
| 116 | + input: 'cmake/config.h.cmake', |
| 117 | + output: 'exv_conf.h', |
| 118 | + format: 'cmake@', |
| 119 | + configuration: cdata, |
| 120 | +) |
| 121 | + |
| 122 | +base_lib = files( |
| 123 | + 'src/asfvideo.cpp', |
| 124 | + 'src/basicio.cpp', |
| 125 | + 'src/bmffimage.cpp', |
| 126 | + 'src/bmpimage.cpp', |
| 127 | + 'src/convert.cpp', |
| 128 | + 'src/cr2image.cpp', |
| 129 | + 'src/crwimage.cpp', |
| 130 | + 'src/datasets.cpp', |
| 131 | + 'src/easyaccess.cpp', |
| 132 | + 'src/epsimage.cpp', |
| 133 | + 'src/error.cpp', |
| 134 | + 'src/exif.cpp', |
| 135 | + 'src/futils.cpp', |
| 136 | + 'src/gifimage.cpp', |
| 137 | + 'src/http.cpp', |
| 138 | + 'src/image.cpp', |
| 139 | + 'src/iptc.cpp', |
| 140 | + 'src/jp2image.cpp', |
| 141 | + 'src/jpgimage.cpp', |
| 142 | + 'src/matroskavideo.cpp', |
| 143 | + 'src/metadatum.cpp', |
| 144 | + 'src/mrwimage.cpp', |
| 145 | + 'src/orfimage.cpp', |
| 146 | + 'src/pgfimage.cpp', |
| 147 | + 'src/photoshop.cpp', |
| 148 | + 'src/preview.cpp', |
| 149 | + 'src/properties.cpp', |
| 150 | + 'src/psdimage.cpp', |
| 151 | + 'src/quicktimevideo.cpp', |
| 152 | + 'src/rafimage.cpp', |
| 153 | + 'src/riffvideo.cpp', |
| 154 | + 'src/rw2image.cpp', |
| 155 | + 'src/tags.cpp', |
| 156 | + 'src/tgaimage.cpp', |
| 157 | + 'src/tiffimage.cpp', |
| 158 | + 'src/types.cpp', |
| 159 | + 'src/value.cpp', |
| 160 | + 'src/version.cpp', |
| 161 | + 'src/webpimage.cpp', |
| 162 | + 'src/xmp.cpp', |
| 163 | + 'src/xmpsidecar.cpp', |
| 164 | +) |
| 165 | + |
| 166 | +int_lib = files( |
| 167 | + 'src/canonmn_int.cpp', |
| 168 | + 'src/casiomn_int.cpp', |
| 169 | + 'src/cr2header_int.cpp', |
| 170 | + 'src/crwimage_int.cpp', |
| 171 | + 'src/fujimn_int.cpp', |
| 172 | + 'src/helper_functions.cpp', |
| 173 | + 'src/image_int.cpp', |
| 174 | + 'src/jp2image_int.cpp', |
| 175 | + 'src/makernote_int.cpp', |
| 176 | + 'src/minoltamn_int.cpp', |
| 177 | + 'src/nikonmn_int.cpp', |
| 178 | + 'src/olympusmn_int.cpp', |
| 179 | + 'src/orfimage_int.cpp', |
| 180 | + 'src/panasonicmn_int.cpp', |
| 181 | + 'src/pentaxmn_int.cpp', |
| 182 | + 'src/rw2image_int.cpp', |
| 183 | + 'src/samsungmn_int.cpp', |
| 184 | + 'src/sigmamn_int.cpp', |
| 185 | + 'src/sonymn_int.cpp', |
| 186 | + 'src/tags_int.cpp', |
| 187 | + 'src/tiffcomposite_int.cpp', |
| 188 | + 'src/tiffimage_int.cpp', |
| 189 | + 'src/tiffvisitor_int.cpp', |
| 190 | + 'src/utils.cpp', |
| 191 | +) |
| 192 | + |
| 193 | +headers = files( |
| 194 | + 'include/exiv2/basicio.hpp', |
| 195 | + 'include/exiv2/bmffimage.hpp', |
| 196 | + 'include/exiv2/bmpimage.hpp', |
| 197 | + 'include/exiv2/config.h', |
| 198 | + 'include/exiv2/convert.hpp', |
| 199 | + 'include/exiv2/cr2image.hpp', |
| 200 | + 'include/exiv2/crwimage.hpp', |
| 201 | + 'include/exiv2/datasets.hpp', |
| 202 | + 'include/exiv2/easyaccess.hpp', |
| 203 | + 'include/exiv2/epsimage.hpp', |
| 204 | + 'include/exiv2/error.hpp', |
| 205 | + 'include/exiv2/exif.hpp', |
| 206 | + 'include/exiv2/exiv2.hpp', |
| 207 | + 'include/exiv2/futils.hpp', |
| 208 | + 'include/exiv2/gifimage.hpp', |
| 209 | + 'include/exiv2/http.hpp', |
| 210 | + 'include/exiv2/image.hpp', |
| 211 | + 'include/exiv2/image_types.hpp', |
| 212 | + 'include/exiv2/iptc.hpp', |
| 213 | + 'include/exiv2/jp2image.hpp', |
| 214 | + 'include/exiv2/jpgimage.hpp', |
| 215 | + 'include/exiv2/metadatum.hpp', |
| 216 | + 'include/exiv2/mrwimage.hpp', |
| 217 | + 'include/exiv2/orfimage.hpp', |
| 218 | + 'include/exiv2/pgfimage.hpp', |
| 219 | + 'include/exiv2/photoshop.hpp', |
| 220 | + 'include/exiv2/pngimage.hpp', |
| 221 | + 'include/exiv2/preview.hpp', |
| 222 | + 'include/exiv2/properties.hpp', |
| 223 | + 'include/exiv2/psdimage.hpp', |
| 224 | + 'include/exiv2/rafimage.hpp', |
| 225 | + 'include/exiv2/rw2image.hpp', |
| 226 | + 'include/exiv2/slice.hpp', |
| 227 | + 'include/exiv2/tags.hpp', |
| 228 | + 'include/exiv2/tgaimage.hpp', |
| 229 | + 'include/exiv2/tiffimage.hpp', |
| 230 | + 'include/exiv2/types.hpp', |
| 231 | + 'include/exiv2/value.hpp', |
| 232 | + 'include/exiv2/version.hpp', |
| 233 | + 'include/exiv2/webpimage.hpp', |
| 234 | + 'include/exiv2/xmp_exiv2.hpp', |
| 235 | + 'include/exiv2/xmpsidecar.hpp', |
| 236 | +) |
| 237 | + |
| 238 | +headers += exiv_conf |
| 239 | +headers += cfile |
| 240 | + |
| 241 | +libinc = include_directories('include/exiv2') |
| 242 | +xmp_lib = files() |
| 243 | +if expat_dep.found() |
| 244 | + libinc = include_directories('include/exiv2', 'xmpsdk/include') |
| 245 | + xmp_lib = files( |
| 246 | + 'xmpsdk/src/ExpatAdapter.cpp', |
| 247 | + 'xmpsdk/src/MD5.cpp', |
| 248 | + 'xmpsdk/src/ParseRDF.cpp', |
| 249 | + 'xmpsdk/src/UnicodeConversions.cpp', |
| 250 | + 'xmpsdk/src/WXMPIterator.cpp', |
| 251 | + 'xmpsdk/src/WXMPMeta.cpp', |
| 252 | + 'xmpsdk/src/WXMPUtils.cpp', |
| 253 | + 'xmpsdk/src/XML_Node.cpp', |
| 254 | + 'xmpsdk/src/XMPCore_Impl.cpp', |
| 255 | + 'xmpsdk/src/XMPIterator.cpp', |
| 256 | + 'xmpsdk/src/XMPMeta-GetSet.cpp', |
| 257 | + 'xmpsdk/src/XMPMeta-Parse.cpp', |
| 258 | + 'xmpsdk/src/XMPMeta-Serialize.cpp', |
| 259 | + 'xmpsdk/src/XMPMeta.cpp', |
| 260 | + 'xmpsdk/src/XMPUtils-FileInfo.cpp', |
| 261 | + 'xmpsdk/src/XMPUtils.cpp', |
| 262 | + ) |
| 263 | +endif |
| 264 | + |
| 265 | +if zlib_dep.found() |
| 266 | + base_lib += files('src/pngimage.cpp') |
| 267 | + int_lib += files('src/pngchunk_int.cpp') |
| 268 | + headers += files('include/exiv2/photoshop.hpp') |
| 269 | +endif |
| 270 | + |
| 271 | +install_man('man/man1/exiv2.1') |
| 272 | + |
| 273 | +install_headers( |
| 274 | + headers, |
| 275 | + subdir: 'exiv2', |
| 276 | +) |
| 277 | + |
| 278 | +exiv2 = library( |
| 279 | + 'exiv2', |
| 280 | + base_lib, |
| 281 | + int_lib, |
| 282 | + xmp_lib, |
| 283 | + cpp_args: cargs, |
| 284 | + version: meson.project_version(), |
| 285 | + gnu_symbol_visibility: 'hidden', |
| 286 | + dependencies: deps, |
| 287 | + include_directories: libinc, |
| 288 | + install: true, |
| 289 | +) |
| 290 | + |
| 291 | +dllapi = '-DEXIV2API=' |
| 292 | +if host_machine.system() == 'windows' and get_option('default_library') != 'static' |
| 293 | + dllapi = '-DEXIV2API=__declspec(dllimport)' |
| 294 | +endif |
| 295 | + |
| 296 | +depinc = include_directories('include') |
| 297 | +exiv2_dep = declare_dependency( |
| 298 | + compile_args: dllapi, |
| 299 | + dependencies: intl_dep, |
| 300 | + include_directories: depinc, |
| 301 | + link_with: exiv2, |
| 302 | +) |
| 303 | + |
| 304 | +pkg = import('pkgconfig') |
| 305 | +pkg.generate( |
| 306 | + exiv2, |
| 307 | + description: 'Exif/IPTC/Xmp C++ metadata library and tools plus ICC Profiles, Previews and more.', |
| 308 | + url: 'https://exiv2.org', |
| 309 | +) |
| 310 | + |
| 311 | +exiv2inc = include_directories('include/exiv2', 'src') |
| 312 | + |
| 313 | +exiv2_sources = files( |
| 314 | + 'app/actions.cpp', |
| 315 | + 'app/app_utils.cpp', |
| 316 | + 'app/exiv2.cpp', |
| 317 | + 'app/getopt.cpp', |
| 318 | +) |
| 319 | + |
| 320 | +if host_machine.system() == 'windows' |
| 321 | + exiv2_sources += files('app/wmain.cpp') |
| 322 | +endif |
| 323 | + |
| 324 | +executable( |
| 325 | + 'exiv2', |
| 326 | + exiv2_sources, |
| 327 | + include_directories: exiv2inc, |
| 328 | + dependencies: exiv2_dep, |
| 329 | + install: true, |
| 330 | +) |
0 commit comments