| 1 |
project( |
| 2 |
'mtxclient', |
| 3 |
'cpp', |
| 4 |
version : '0.10.1', |
| 5 |
meson_version : '>=0.57.0', |
| 6 |
license : 'MIT', |
| 7 |
default_options : 'cpp_std=c++20' |
| 8 |
) |
| 9 |
|
| 10 |
cmake = import('cmake') |
| 11 |
|
| 12 |
compiler = meson.get_compiler('cpp') |
| 13 |
if compiler.get_id() == 'msvc' |
| 14 |
add_project_arguments('/bigobj', language: 'cpp') |
| 15 |
endif |
| 16 |
|
| 17 |
coeurl_dep = dependency('coeurl', version: '>=0.3.0', required: true) |
| 18 |
thread_dep = dependency('threads', required: true) |
| 19 |
openssl_dep = dependency('openssl', version: '>=1.1', required: true) |
| 20 |
spdlog_dep = dependency('spdlog', fallback: ['spdlog', 'spdlog_dep']) |
| 21 |
re2_dep = dependency('re2', required: true) |
| 22 |
|
| 23 |
json_dep = dependency('nlohmann_json', version: '>=3.2.0', required: true) |
| 24 |
|
| 25 |
olm_dep = dependency('Olm', method: 'cmake', version: '>=3.2.6', required: get_option('wrap_mode') == 'nofallback') |
| 26 |
|
| 27 |
if (not olm_dep.found() |
| 28 |
or get_option('wrap_mode') == 'forcefallback' |
| 29 |
or 'Olm' in get_option('force_fallback_for')) |
| 30 |
olm_options = cmake.subproject_options() |
| 31 |
olm_options.add_cmake_defines({ |
| 32 |
'BUILD_SHARED_LIBS': false, |
| 33 |
'OLM_TESTS': false, |
| 34 |
}) |
| 35 |
if target_machine.system() != 'windows' |
| 36 |
olm_options.add_cmake_defines({ |
| 37 |
'CMAKE_C_FLAGS': '-fPIC', |
| 38 |
}) |
| 39 |
endif |
| 40 |
olm_options.set_override_option('werror', 'false') |
| 41 |
olm_options.set_override_option('warning_level', '0') |
| 42 |
olm_proj = cmake.subproject('Olm', options: olm_options) |
| 43 |
olm_dep = olm_proj.dependency('olm') |
| 44 |
endif |
| 45 |
|
| 46 |
deps = [ |
| 47 |
coeurl_dep, |
| 48 |
thread_dep, |
| 49 |
olm_dep, |
| 50 |
openssl_dep, |
| 51 |
json_dep, |
| 52 |
spdlog_dep, |
| 53 |
re2_dep, |
| 54 |
] |
| 55 |
|
| 56 |
inc = include_directories('include') |
| 57 |
src = [ |
| 58 |
'lib/crypto/client.cpp', |
| 59 |
'lib/crypto/encoding.cpp', |
| 60 |
'lib/crypto/types.cpp', |
| 61 |
'lib/crypto/utils.cpp', |
| 62 |
'lib/http/client.cpp', |
| 63 |
'lib/log.cpp', |
| 64 |
'lib/structs/common.cpp', |
| 65 |
'lib/structs/errors.cpp', |
| 66 |
'lib/structs/events.cpp', |
| 67 |
'lib/structs/events/account_data/direct.cpp', |
| 68 |
'lib/structs/events/account_data/fully_read.cpp', |
| 69 |
'lib/structs/events/account_data/ignored_users.cpp', |
| 70 |
'lib/structs/events/aliases.cpp', |
| 71 |
'lib/structs/events/avatar.cpp', |
| 72 |
'lib/structs/events/canonical_alias.cpp', |
| 73 |
'lib/structs/events/collections.cpp', |
| 74 |
'lib/structs/events/common.cpp', |
| 75 |
'lib/structs/events/create.cpp', |
| 76 |
'lib/structs/events/encrypted.cpp', |
| 77 |
'lib/structs/events/encryption.cpp', |
| 78 |
'lib/structs/events/ephemeral/receipt.cpp', |
| 79 |
'lib/structs/events/ephemeral/typing.cpp', |
| 80 |
'lib/structs/events/guest_access.cpp', |
| 81 |
'lib/structs/events/history_visibility.cpp', |
| 82 |
'lib/structs/events/join_rules.cpp', |
| 83 |
'lib/structs/events/member.cpp', |
| 84 |
'lib/structs/events/messages/audio.cpp', |
| 85 |
'lib/structs/events/messages/elementeffect.cpp', |
| 86 |
'lib/structs/events/messages/emote.cpp', |
| 87 |
'lib/structs/events/messages/file.cpp', |
| 88 |
'lib/structs/events/messages/image.cpp', |
| 89 |
'lib/structs/events/messages/location.cpp', |
| 90 |
'lib/structs/events/messages/notice.cpp', |
| 91 |
'lib/structs/events/messages/text.cpp', |
| 92 |
'lib/structs/events/messages/unknown.cpp', |
| 93 |
'lib/structs/events/messages/video.cpp', |
| 94 |
'lib/structs/events/mscs/image_packs.cpp', |
| 95 |
'lib/structs/events/name.cpp', |
| 96 |
'lib/structs/events/nheko_extensions/event_expiry.cpp', |
| 97 |
'lib/structs/events/nheko_extensions/hidden_events.cpp', |
| 98 |
'lib/structs/events/nheko_extensions/invite_permissions.cpp', |
| 99 |
'lib/structs/events/pinned_events.cpp', |
| 100 |
'lib/structs/events/policy_rules.cpp', |
| 101 |
'lib/structs/events/power_levels.cpp', |
| 102 |
'lib/structs/events/presence.cpp', |
| 103 |
'lib/structs/events/reaction.cpp', |
| 104 |
'lib/structs/events/redaction.cpp', |
| 105 |
'lib/structs/events/server_acl.cpp', |
| 106 |
'lib/structs/events/spaces.cpp', |
| 107 |
'lib/structs/events/tag.cpp', |
| 108 |
'lib/structs/events/tombstone.cpp', |
| 109 |
'lib/structs/events/topic.cpp', |
| 110 |
'lib/structs/events/unknown.cpp', |
| 111 |
'lib/structs/events/voip.cpp', |
| 112 |
'lib/structs/events/widget.cpp', |
| 113 |
'lib/structs/identifiers.cpp', |
| 114 |
'lib/structs/pushrules.cpp', |
| 115 |
'lib/structs/requests.cpp', |
| 116 |
'lib/structs/responses/capabilities.cpp', |
| 117 |
'lib/structs/responses/common.cpp', |
| 118 |
'lib/structs/responses/create_room.cpp', |
| 119 |
'lib/structs/responses/crypto.cpp', |
| 120 |
'lib/structs/responses/device.cpp', |
| 121 |
'lib/structs/responses/empty.cpp', |
| 122 |
'lib/structs/responses/login.cpp', |
| 123 |
'lib/structs/responses/media.cpp', |
| 124 |
'lib/structs/responses/members.cpp', |
| 125 |
'lib/structs/responses/messages.cpp', |
| 126 |
'lib/structs/responses/notifications.cpp', |
| 127 |
'lib/structs/responses/profile.cpp', |
| 128 |
'lib/structs/responses/public_rooms.cpp', |
| 129 |
'lib/structs/responses/register.cpp', |
| 130 |
'lib/structs/responses/sync.cpp', |
| 131 |
'lib/structs/responses/turn_server.cpp', |
| 132 |
'lib/structs/responses/users.cpp', |
| 133 |
'lib/structs/responses/version.cpp', |
| 134 |
'lib/structs/responses/well-known.cpp', |
| 135 |
'lib/structs/secret_storage.cpp', |
| 136 |
'lib/structs/user_interactive.cpp', |
| 137 |
'lib/utils.cpp', |
| 138 |
] |
| 139 |
|
| 140 |
matrix_client = library('matrix_client', |
| 141 |
src, |
| 142 |
dependencies: deps, |
| 143 |
include_directories : inc, |
| 144 |
install : true) |
| 145 |
|
| 146 |
matrix_client_dep = declare_dependency( |
| 147 |
link_with: matrix_client, |
| 148 |
dependencies: deps, |
| 149 |
include_directories: inc) |
| 150 |
|
| 151 |
meson.override_dependency('mtxclient', matrix_client_dep) |
| 152 |
|
| 153 |
pkg = import('pkgconfig') |
| 154 |
pkg.generate(matrix_client, |
| 155 |
libraries : [matrix_client], |
| 156 |
version : meson.project_version(), |
| 157 |
filebase : meson.project_name(), |
| 158 |
description : 'Client API library for Matrix.', |
| 159 |
url : 'https://github.com/Nheko-Reborn/mtxclient)') |
| 160 |
|
| 161 |
conf = configuration_data() |
| 162 |
|
| 163 |
cmake.write_basic_package_version_file( |
| 164 |
name: 'MatrixClient', |
| 165 |
compatibility: 'AnyNewerVersion', |
| 166 |
version: meson.project_version()) |
| 167 |
cmake.configure_package_config_file( |
| 168 |
name: 'MatrixClient', |
| 169 |
input: 'cmake/MatrixClientConfig.cmake.in', |
| 170 |
configuration: conf) |
| 171 |
|
| 172 |
if get_option('examples') |
| 173 |
subdir('examples') |
| 174 |
endif |
| 175 |
|
| 176 |
if get_option('tests') |
| 177 |
subdir('tests') |
| 178 |
endif |