From c4c4bacd14e22b0e3d5e442e23196abfec83fdf7 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 10 Jun 2022 14:09:01 +0200 Subject: [PATCH] Add a way to force system asio to be used --- CHANGELOG.md | 17 +++++++++++++++++ meson.build | 23 ++++++++++++++++++++++- meson_options.txt | 12 ++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7625c09f..9f4a6a88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Added a `system-asio` build option to aid distro packaging. + +### Packaging notes + +- The new `system-asio` build option forces asio to be used from the standard + include directories instead of being defined as a regular Meson dependency. + Asio does not have any pkgconfig or CMake [build + definitions](https://github.com/chriskohlhoff/asio/issues/1071), so it's + impossible to detect its presence and version in a normal way, and as such + Meson will fall back to using the included wrap dependency. Configuring the + project with `meson setup build -Dsystem-asio=true ...` will cause + `` to be used instead. + ## [4.0.0] - 2022-06-09 ### Added diff --git a/meson.build b/meson.build index 8e1b8bfd..a0a66a5e 100644 --- a/meson.build +++ b/meson.build @@ -22,6 +22,7 @@ project( is_64bit_system = build_machine.cpu_family() not in ['x86', 'arm'] with_32bit_libraries = (not is_64bit_system) or get_option('build.cpp_args').contains('-m32') with_bitbridge = get_option('bitbridge') +with_system_asio = get_option('system-asio') with_winedbg = get_option('winedbg') with_vst3 = get_option('vst3') @@ -192,7 +193,27 @@ endif # These are all headers-only libraries, and thus won't require separate 32-bit # and 64-bit versions -asio_dep = dependency('asio', version : '>=1.22.0') +# NOTE: The standalone asio library does not come with a pkgconfig or CMake +# build definition, and Meson thus also won't be able to detect it this +# way. As a workaround for distro packaging, configuring the project with +# `-Dsystem-asio=true` will use `` from the standard include +# directories instead. +if with_system_asio + if not meson.get_compiler('cpp', native : true).check_header('asio.hpp') + error('The \'system-asio\' build option was set, but was not found') + endif + + asio_version = meson.get_compiler('cpp', native : true).get_define('ASIO_VERSION', prefix : '#include ') + if asio_version.to_int() < 102000 + error('Expected version 1.22.0 of the asio library or higher, found @0@ (MMmmrr)'.format(asio_version)) + endif + + # This is a dummy dependency, since the library is only accessible implicitly through the system include path + asio_dep = declare_dependency() +else + asio_dep = dependency('asio', version : '>=1.22.0') +endif + if meson.version().version_compare('>=0.60') # Bitsery's CMake build definition is capitalized for some reason bitsery_dep = dependency('bitsery', 'Bitsery', version : '>=5.2.0') diff --git a/meson_options.txt b/meson_options.txt index 19ce3340..69c5dfce 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,6 +5,18 @@ option( description : 'Build a 32-bit host application for hosting 32-bit plugins. See the readme for full instructions on how to use this.' ) +option( + 'system-asio', + type : 'boolean', + value : false, + description : '''If set to true, then from the standard include + directories will be used in place of a pkgconfig definition, + CMake dependency, or subproject wrap. The asio library does + not come with any build definitions Meson can use to detect + its installed version and location, so this behavior is + behind an option as it's only relevant for distro packaging.''' +) + option( 'vst3', type : 'boolean',