介子构建系统允许使用选项--default-library
构建共享库或静态库。但是,我无法知道是否正在构建共享库或静态库,我需要它至少通过一个定义。有没有办法查询库类型?
这是我的猜测:
libtype = get_option('default-library')
if libtype = 'shared'
build_dll = ['-DBUILDING_DLL', '-fvisibility=hidden']
else
build_dll = ''
endif
但显然我得到:
Meson encountered an error in file meson.build, line 10, column 0:
Tried to access unknown option "default-library".
如果其他人遇到此问题,解决方案很简单:
libtype = get_option('default_library')
(注意下划线而不是破折号(
(答案归功于jpakkane(介子的创造者(,他在IRC上回答(