1 project('nntrainer', 'c', 'cpp',
3 license: ['apache-2.0'],
4 meson_version: '>=0.50.0',
12 add_project_arguments('-DMIN_CPP_VERSION=201402', language:['c','cpp'])
14 cc = meson.get_compiler('c')
15 cxx = meson.get_compiler('cpp')
18 if get_option('enable-tizen')
19 # Pass __TIZEN__ to the compiler
20 build_platform = 'tizen'
21 add_project_arguments('-D__TIZEN__=1', language:['c','cpp'])
23 if get_option('enable-tizen-feature-check')
24 add_project_arguments('-D__FEATURE_CHECK_SUPPORT__', language: ['c', 'cpp'])
32 '-Wformat-nonliteral',
45 '-Wmissing-declarations',
46 '-Wmissing-include-dirs',
47 '-Wmissing-prototypes',
50 '-Wold-style-definition',
51 '-Wdeclaration-after-statement',
55 foreach extra_arg : warning_flags
56 if cc.has_argument (extra_arg)
57 add_project_arguments([extra_arg], language: 'c')
59 if cxx.has_argument (extra_arg)
60 add_project_arguments([extra_arg], language: 'cpp')
64 foreach extra_arg : warning_c_flags
65 if cc.has_argument (extra_arg)
66 add_project_arguments([extra_arg], language: 'c')
71 nntrainer_prefix = get_option('prefix')
72 nntrainer_libdir = nntrainer_prefix / get_option('libdir')
73 nntrainer_bindir = nntrainer_prefix / get_option('bindir')
74 nntrainer_includedir = nntrainer_prefix / get_option('includedir')
75 nntrainer_inidir = get_option('sysconfdir')
76 application_install_dir = nntrainer_bindir / 'applications'
78 # Set default configuration
79 nntrainer_conf = configuration_data()
80 nntrainer_conf.set('VERSION', meson.project_version())
81 nntrainer_conf.set('PREFIX', nntrainer_prefix)
82 nntrainer_conf.set('EXEC_PREFIX', nntrainer_bindir)
83 nntrainer_conf.set('LIB_INSTALL_DIR', nntrainer_libdir)
84 nntrainer_conf.set('INCLUDE_INSTALL_DIR', nntrainer_includedir)
86 dummy_dep = dependency('', required: false)
90 if get_option('enable-cublas')
91 add_project_arguments('-DUSE_CUBLAS=1', language:['c','cpp'])
94 if get_option('enable-blas')
95 add_project_arguments('-DUSE_BLAS=1', language:['c','cpp'])
96 if build_platform == 'tizen'
97 blas_dep = dependency('openblas')
99 blas_dep = dependency('blas-openblas', required:false)
101 if not blas_dep.found()
102 blas_dep = dependency('openblas')
107 if get_option('enable-profile')
108 add_project_arguments('-DPROFILE=1', language:['c', 'cpp'])
111 if get_option('use_gym')
112 add_project_arguments('-DUSE_GYM=1', language:['c','cpp'])
115 if get_option('enable-logging')
116 add_project_arguments('-D__LOGGING__=1', language:['c','cpp'])
119 if get_option('enable-test')
120 add_project_arguments('-DENABLE_TEST=1', language:['c','cpp'])
123 libm_dep = cxx.find_library('m') # cmath library
124 libdl_dep = cxx.find_library('dl') # DL library
125 thread_dep = dependency('threads') # pthread for tensorflow-lite
126 iniparser_dep = dependency('iniparser', required : false) # iniparser
127 if not iniparser_dep.found()
128 message('falling back to find libiniparser library and header files')
129 libiniparser_dep = cxx.find_library('iniparser')
130 if libiniparser_dep.found() and cxx.has_header('iniparser.h', \
131 args : '-I/usr/include/iniparser')
132 iniparser_dep = declare_dependency (dependencies : libiniparser_dep,
133 compile_args : '-I/usr/include/iniparser')
137 nnstreamer_capi_dep = dependency('capi-nnstreamer', required:false)
138 if nnstreamer_capi_dep.found()
139 add_project_arguments('-DNNSTREAMER_AVAILABLE=1', language:['c','cpp'])
142 if get_option('enable-nnstreamer-backbone')
143 add_project_arguments('-DENABLE_NNSTREAMER_BACKBONE=1', language:['c','cpp'])
146 tflite_dep = dependency('tensorflow-lite', required: false)
147 if get_option('enable-tflite-backbone')
148 add_project_arguments('-DENABLE_TFLITE_BACKBONE=1', language:['c','cpp'])
151 gtest_dep = dependency('gtest', required: false)
154 configure_file(input: 'nntrainer.pc.in', output: 'nntrainer.pc',
155 install_dir: nntrainer_libdir / 'pkgconfig',
156 configuration: nntrainer_conf
165 if get_option('enable-app')
166 jsoncpp_dep = dependency('jsoncpp') # jsoncpp
167 libcurl_dep = dependency('libcurl')
168 if not tflite_dep.found()
169 error('Tensorflow-Lite dependency not found')
171 subdir('Applications')
174 if get_option('enable-test')
178 if get_option('enable-nnstreamer-tensor-filter')
179 nnstreamer_dep = dependency('nnstreamer', required: true)
180 subdir('nnstreamer/tensor_filter')
183 if get_option('enable-android')
185 ndk_build = find_program('ndk-build', required : true)
186 jni_root = meson.current_source_dir() / 'jni'
187 jni_build_root = meson.current_build_dir() / 'jni'
190 'NDK_PROJECT_PATH': jni_root,
191 'APP_BUILD_SCRIPT': jni_root / 'Android.mk',
192 'NDK_APPLICATION_MK': jni_root / 'Application.mk',
193 'NDK_LIBS_OUT': jni_build_root / 'libs',
194 'NDK_OUT': jni_build_root / 'objs',
195 'ENABLE_PROFILE': get_option('enable-profile') ? 1 : 0,
196 'ENABLE_BLAS': get_option('enable-blas') ? 1 : 0,
199 num_threads = run_command('grep', '-c', '^processor', '/proc/cpuinfo').stdout().strip()
200 message('num processor are: ' + num_threads)
202 thread_opt_flag = '-j' + num_threads
204 ndk_additional_flags = [thread_opt_flag]
206 ndk_build_command = [ndk_build]
207 foreach key, val : ndk_args
208 ndk_build_command += '@0@=@1@'.format(key, val)
210 ndk_build_command += ndk_additional_flags
212 android_build_target = custom_target('android',
214 build_by_default: true,
215 command: ndk_build_command