|
| 1 | +project('libwpe', 'cpp', 'c', |
| 2 | + meson_version: '>=0.49', |
| 3 | + default_options: [ |
| 4 | + 'b_ndebug=if-release', |
| 5 | + 'c_std=c99', |
| 6 | + 'cpp_eh=none', |
| 7 | + 'cpp_std=c++11', |
| 8 | + ], |
| 9 | + license: 'BSD-2-Clause', |
| 10 | + version: '1.7.0', |
| 11 | +) |
| 12 | + |
| 13 | +# This refers to the API level provided. This is modified only with major, |
| 14 | +# breaking changes, which need modifications in programs using the library |
| 15 | +# before they can be compiled again. |
| 16 | +api_version = '1.0' |
| 17 | + |
| 18 | +# Before making a release, the LT_VERSION string should be modified. |
| 19 | +# The string is of the form [C, R, A]. |
| 20 | +# - If interfaces have been changed or added, but binary compatibility has |
| 21 | +# been preserved, change to [C+1, 0, A+1]. |
| 22 | +# - If binary compatibility has been broken (eg removed or changed interfaces) |
| 23 | +# change to [C+1, 0, 0] |
| 24 | +# - If the interface is the same as the previous version, use [C, R+1, A]. |
| 25 | +soversion = [5, 0, 4] |
| 26 | + |
| 27 | +# Split the *project* version into its components. |
| 28 | +version_info = meson.project_version().split('.') |
| 29 | +version_info = { |
| 30 | + 'PROJECT_VERSION_MAJOR': version_info[0], |
| 31 | + 'PROJECT_VERSION_MINOR': version_info[1], |
| 32 | + 'PROJECT_VERSION_PATCH': version_info[2], |
| 33 | +} |
| 34 | + |
| 35 | +# Mangle [C, R, A] into an actual usable *soversion*. |
| 36 | +soversion_major = soversion[0] - soversion[2] # Current-Age |
| 37 | +soversion_minor = soversion[2] # Age |
| 38 | +soversion_micro = soversion[1] # Revision |
| 39 | +soversion = '@0@.@1@.@2@'.format(soversion_major, soversion_minor, soversion_micro) |
| 40 | + |
| 41 | +add_project_arguments('-DWPE_COMPILATION=1', language: ['c', 'cpp']) |
| 42 | + |
| 43 | +# Switch to the 'cpp_rtti=false' default option when updating to Meson 0.53 or newer, see |
| 44 | +# https://mesonbuild.com/FAQ.html#how-do-i-disable-exceptions-and-rtti-in-my-c-project |
| 45 | +add_project_arguments( |
| 46 | + meson.get_compiler('cpp').get_supported_arguments(['-fno-rtti']), |
| 47 | + language: 'cpp' |
| 48 | +) |
| 49 | + |
| 50 | +default_backend = get_option('default-backend').strip() |
| 51 | +if default_backend != '' |
| 52 | + add_project_arguments('-DWPE_BACKEND="@0@"'.format(default_backend), language: ['c', 'cpp']) |
| 53 | +endif |
| 54 | + |
| 55 | +dependencies = [ |
| 56 | + dependency('xkbcommon'), |
| 57 | +] |
| 58 | + |
| 59 | +cc = meson.get_compiler('c') |
| 60 | +if not cc.has_header('EGL/eglplatform.h') |
| 61 | + dependencies += dependency('egl') |
| 62 | +endif |
| 63 | + |
| 64 | +if not cc.has_function('dlopen') |
| 65 | + dependencies += cc.find_library('dl') |
| 66 | +endif |
| 67 | + |
| 68 | +libwpe = library('wpe-' + api_version, |
| 69 | + 'src/input.c', |
| 70 | + 'src/key-unicode.c', |
| 71 | + 'src/loader.c', |
| 72 | + 'src/pasteboard.c', |
| 73 | + 'src/pasteboard-generic.cpp', |
| 74 | + 'src/pasteboard-noop.cpp', |
| 75 | + 'src/renderer-backend-egl.c', |
| 76 | + 'src/renderer-host.c', |
| 77 | + 'src/version.c', |
| 78 | + 'src/view-backend.c', |
| 79 | + install: true, |
| 80 | + dependencies: dependencies, |
| 81 | + version: soversion, |
| 82 | + soversion: soversion_major, |
| 83 | + include_directories: 'include', |
| 84 | +) |
| 85 | + |
| 86 | +api_headers = [ |
| 87 | + 'include/wpe/export.h', |
| 88 | + 'include/wpe/input.h', |
| 89 | + 'include/wpe/keysyms.h', |
| 90 | + 'include/wpe/loader.h', |
| 91 | + 'include/wpe/pasteboard.h', |
| 92 | + 'include/wpe/renderer-backend-egl.h', |
| 93 | + 'include/wpe/renderer-host.h', |
| 94 | + 'include/wpe/view-backend.h', |
| 95 | + 'include/wpe/wpe-egl.h', |
| 96 | + 'include/wpe/wpe.h', |
| 97 | + |
| 98 | + # Generated API headers. |
| 99 | + configure_file( |
| 100 | + input: 'include/wpe/version.h.cmake', |
| 101 | + output: 'version.h', |
| 102 | + configuration: version_info, |
| 103 | + ), |
| 104 | + configure_file( |
| 105 | + input: 'include/wpe/version-deprecated.h.cmake', |
| 106 | + output: 'version-deprecated.h', |
| 107 | + configuration: version_info, |
| 108 | + ), |
| 109 | +] |
| 110 | +install_headers(api_headers, |
| 111 | + subdir: join_paths('wpe-' + api_version, 'wpe'), |
| 112 | +) |
| 113 | + |
| 114 | +import('pkgconfig').generate( |
| 115 | + description: 'The wpe library', |
| 116 | + name: 'wpe-' + api_version, |
| 117 | + subdirs: 'wpe-' + api_version, |
| 118 | + libraries: libwpe, |
| 119 | + version: meson.project_version(), |
| 120 | +) |
| 121 | + |
| 122 | +if get_option('build-docs') |
| 123 | + hotdoc = import('hotdoc') |
| 124 | + assert(hotdoc.has_extensions('c-extension'), |
| 125 | + 'The HotDoc C extension is required.' |
| 126 | + ) |
| 127 | + libwpe_doc = hotdoc.generate_doc(meson.project_name(), |
| 128 | + project_version: api_version, |
| 129 | + dependencies: dependencies, |
| 130 | + index: 'docs/index.md', |
| 131 | + sitemap: 'docs/sitemap.txt', |
| 132 | + console: true, |
| 133 | + install: true, |
| 134 | + build_by_default: true, |
| 135 | + c_smart_index: true, |
| 136 | + c_sources: api_headers, |
| 137 | + c_include_directories: [ |
| 138 | + include_directories('include'), |
| 139 | + meson.current_build_dir() |
| 140 | + ], |
| 141 | + # The space here is relevant, see |
| 142 | + # https://github.com/mesonbuild/meson/issues/5800#issuecomment-552198354 |
| 143 | + extra_c_flags: [' -DWPE_COMPILATION=1'], |
| 144 | + ) |
| 145 | +endif |
0 commit comments