[Meson] Clean code in meson build scripts
authorWook Song <wook16.song@samsung.com>
Thu, 28 Nov 2019 04:16:48 +0000 (13:16 +0900)
committer함명주/On-Device Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Fri, 29 Nov 2019 00:38:38 +0000 (09:38 +0900)
This patchs cleans code in meson build scripts.

Signed-off-by: Wook Song <wook16.song@samsung.com>
meson.build
src/core/npu/meson.build

index 17dd7a4..1c9ed5a 100644 (file)
@@ -1,7 +1,7 @@
 # Do NOT enable C in core
 # C++ is only allowed inside test directory for gtest.
 
-project('npu-engine', 'c',
+project('npu-engine', ['c', 'cpp'],
   version: '0.0.3',
   license: ['Proprietary'],
   meson_version: '>=0.42.0',
@@ -9,13 +9,12 @@ project('npu-engine', 'c',
     'werror=true',
     'warning_level=1',
     'c_std=gnu89',
+    'cpp_std=gnu++11',
   ]
 )
 
-add_project_arguments('-DVERSION="' + meson.project_version() + '"',
-  language: ['c'])
-
 cc = meson.get_compiler('c')
+cpp = meson.get_compiler('cpp')
 
 warning_c_flags = [
   '-Wmissing-declarations',
@@ -28,7 +27,9 @@ warning_c_flags = [
 
 foreach extra_arg : warning_c_flags
   if cc.has_argument (extra_arg)
-    add_project_arguments([extra_arg], language: 'c')
+    add_project_arguments([extra_arg], language : 'c')
+  elif cpp.has_argument (extra_arg)
+    add_project_arguments([extra_arg], language : 'cpp')
   endif
 endforeach
 
@@ -51,12 +52,8 @@ thread_dep = dependency('threads') # pthread library
 iniparser_dep = dependency('iniparser') # iniparser library
 
 if get_option('enable_npu_emul')
-  npuvision_dep = dependency('libnpuvision') # npuvision library
-
-  add_project_arguments('-I/opt/trinity/include', language: 'c')
-  add_project_arguments('-I/opt/trinity/include', language: 'cpp')
-  add_project_arguments('-DENABLE_EMUL', language: 'c')
-  add_project_arguments('-DENABLE_EMUL', language: 'cpp')
+  add_project_arguments('-I/opt/trinity/include', language: ['c', 'cpp'])
+  add_project_arguments('-DENABLE_EMUL', language: ['c', 'cpp'])
 endif
 
 subdir('src')
index 8232341..d6a8bdb 100644 (file)
@@ -1,12 +1,9 @@
 ne_core_npu_inc = include_directories('.')
 
-if get_option('enable_npu_emul') and npuvision_dep.found()
-  add_languages('cpp')
-  add_project_arguments('-std=c++11', language: 'cpp')
-
+if get_option('enable_npu_emul')
   ne_core_npu_dep = declare_dependency(
     sources : ['NPUdrvAPI.c', 'NPUemul.cpp'],
-    dependencies : [ne_core_utils_dep, ne_core_gem_dep, npuvision_dep],
+    dependencies : [ne_core_utils_dep, ne_core_gem_dep, dependency('libnpuvision')],
     include_directories : [ne_common_inc, ne_core_npu_inc])
 else
   ne_core_npu_dep = declare_dependency(