build: Fixed simd options detection

This commit is contained in:
Michal Szczecinski 2021-08-18 09:49:50 +02:00 committed by Hermet Park
parent 1dd5e5c2ea
commit e3eaa05548
3 changed files with 17 additions and 13 deletions

View file

@ -40,12 +40,17 @@ if get_option('savers').contains('tvg_beta') == true
config_h.set10('THORVG_TVG_SAVER_SUPPORT', true) config_h.set10('THORVG_TVG_SAVER_SUPPORT', true)
endif endif
if get_option('vectors').contains('avx') == true cpu_avx = false
config_h.set10('THORVG_AVX_VECTOR_SUPPORT', true) cpu_neon = false
endif
if get_option('vectors').contains('neon') == true if get_option('use_simd') == true
if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'
config_h.set10('THORVG_AVX_VECTOR_SUPPORT', true)
cpu_avx = true
elif host_machine.cpu_family() == 'arm'
config_h.set10('THORVG_NEON_VECTOR_SUPPORT', true) config_h.set10('THORVG_NEON_VECTOR_SUPPORT', true)
cpu_neon = true
endif
endif endif
if get_option('bindings').contains('capi') == true if get_option('bindings').contains('capi') == true
@ -98,8 +103,8 @@ Summary:
get_option('prefix'), get_option('prefix'),
get_option('engines').contains('sw'), get_option('engines').contains('sw'),
get_option('engines').contains('gl'), get_option('engines').contains('gl'),
get_option('vectors').contains('avx'), cpu_avx,
get_option('vectors').contains('neon'), cpu_neon,
get_option('loaders').contains('tvg_beta'), get_option('loaders').contains('tvg_beta'),
get_option('loaders').contains('svg'), get_option('loaders').contains('svg'),
get_option('loaders').contains('png'), get_option('loaders').contains('png'),

View file

@ -16,10 +16,9 @@ option('savers',
value: [''], value: [''],
description: 'Enable File Savers in thorvg') description: 'Enable File Savers in thorvg')
option('vectors', option('use_simd',
type: 'combo', type: 'boolean',
choices: ['', 'avx', 'neon'], value: true,
value: '',
description: 'Enable CPU Vectorization(SIMD) in thorvg') description: 'Enable CPU Vectorization(SIMD) in thorvg')
option('bindings', option('bindings',

View file

@ -2,11 +2,11 @@ compiler_flags = ['-DTVG_BUILD']
cc = meson.get_compiler('cpp') cc = meson.get_compiler('cpp')
if (cc.get_id() != 'msvc') if (cc.get_id() != 'msvc')
if get_option('vectors').contains('avx') if cpu_avx
compiler_flags += ['-mavx'] compiler_flags += ['-mavx']
endif endif
if get_option('vectors').contains('neon') if cpu_neon
compiler_flags += ['-mfpu=neon-vfpv4'] compiler_flags += ['-mfpu=neon']
endif endif
if get_option('b_sanitize') == 'none' if get_option('b_sanitize') == 'none'
compiler_flags += ['-fno-exceptions', '-fno-rtti', compiler_flags += ['-fno-exceptions', '-fno-rtti',