Skip to content

Commit 8ac6025

Browse files
committed
meson: Fix boost static linking logic
Do not attempt to statically link boost for -Ddefault_library=static: -Dprefer_static=true exists now and should be used to statically link external dependencies, while -Ddefault_library=static is meant for internal dependencies. However, if -Dprefer_static=true *is* passed (I'm not aware of any setup where it is, but it doesn't hurt to be correct here), we need to work around two meson bugs here.
1 parent d1dce18 commit 8ac6025

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

meson.build

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,26 @@ deps += dependency('iconv', fallback: ['iconv', 'libiconv_dep'])
106106
deps += dependency('libass', version: '>=0.9.7',
107107
fallback: ['libass', 'libass_dep'])
108108

109+
boost_static = get_option('prefer_static') # boost dependencies do not respect prefer_static https://github.com/mesonbuild/meson/issues/15458
109110
boost_modules = ['chrono', 'locale']
111+
112+
if boost_static
113+
boost_modules += 'thread' # static boost dependencies do not include transitive dependencies https://github.com/mesonbuild/meson/issues/15457
114+
endif
115+
110116
if not get_option('local_boost')
111117
boost_dep = dependency('boost', version: '>=1.70.0',
112118
modules: boost_modules,
113119
required: false,
114-
static: get_option('default_library') == 'static')
120+
static: boost_static)
115121

116122
if boost_dep.version().version_compare('<1.77.0')
117123
# boost regex is header-only since version 1.77.0, and some distributions have stopped shipping the stub module since then.
118124
# So we need to require boost.regex for older versions but can't require it for newer versions.
119125
boost_dep = dependency('boost', version: '>=1.70.0',
120126
modules: boost_modules + ['regex'],
121127
required: false,
122-
static: get_option('default_library') == 'static')
128+
static: boost_static)
123129
endif
124130
endif
125131

0 commit comments

Comments
 (0)