build: Fixed simd options detection
authorMichal Szczecinski <mihashco89@gmail.com>
Wed, 18 Aug 2021 07:49:50 +0000 (09:49 +0200)
committerHermet Park <chuneon.park@samsung.com>
Wed, 18 Aug 2021 10:07:01 +0000 (19:07 +0900)
Change-Id: I58816d8b8a5bedffb9d9986f96f45ddc1ca0069b

meson.build
meson_options.txt
src/meson.build

index cc0ed4e..e03582f 100644 (file)
@@ -40,12 +40,17 @@ if get_option('savers').contains('tvg_beta') == true
     config_h.set10('THORVG_TVG_SAVER_SUPPORT', true)
 endif
 
-if get_option('vectors').contains('avx') == true
-    config_h.set10('THORVG_AVX_VECTOR_SUPPORT', true)
-endif
+cpu_avx = false
+cpu_neon = false
 
-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)
+    cpu_neon = true
+  endif
 endif
 
 if get_option('bindings').contains('capi') == true
@@ -98,8 +103,8 @@ Summary:
         get_option('prefix'),
         get_option('engines').contains('sw'),
         get_option('engines').contains('gl'),
-        get_option('vectors').contains('avx'),
-        get_option('vectors').contains('neon'),
+        cpu_avx,
+        cpu_neon,
         get_option('loaders').contains('tvg_beta'),
         get_option('loaders').contains('svg'),
         get_option('loaders').contains('png'),
index 9c37b53..7ceeb7e 100644 (file)
@@ -16,10 +16,10 @@ option('savers',
    value: ['tvg_beta'],
    description: 'Enable File Savers in thorvg')
 
-option('vectors',
-   type: 'combo',
-   choices: ['', 'avx', 'neon'],
-   value: 'neon',
+
+option('use_simd',
+   type: 'boolean',
+   value: true,
    description: 'Enable CPU Vectorization(SIMD) in thorvg')
 
 option('bindings',
index fc4c352..d0d6f9c 100644 (file)
@@ -2,11 +2,11 @@ compiler_flags = ['-DTVG_BUILD']
 
 cc = meson.get_compiler('cpp')
 if (cc.get_id() != 'msvc')
-    if get_option('vectors').contains('avx')
+    if cpu_avx
         compiler_flags += ['-mavx']
     endif
-    if get_option('vectors').contains('neon')
-        compiler_flags += ['-mfpu=neon-vfpv4']
+    if cpu_neon
+        compiler_flags += ['-mfpu=neon']
     endif
     if get_option('b_sanitize') == 'none'
         compiler_flags += ['-fno-exceptions', '-fno-rtti',