[API] Training API with generator
[platform/core/ml/nntrainer.git] / meson.build
1 project('nntrainer', 'c', 'cpp',
2   version: '0.0.1',
3   license: ['apache-2.0'],
4   meson_version: '>=0.50.0',
5   default_options: [
6     'werror=true',
7     'warning_level=1',
8     'c_std=gnu89',
9     'cpp_std=c++14'
10   ]
11 )
12
13 cc = meson.get_compiler('c')
14 cxx = meson.get_compiler('cpp')
15 build_platform = ''
16
17 if get_option('enable-tizen')
18   # Pass __TIZEN__ to the compiler
19   build_platform = 'tizen'
20   add_project_arguments('-D__TIZEN__=1', language:['c','cpp'])
21 endif
22
23 warning_flags = [
24   '-Wredundant-decls',
25   '-Wwrite-strings',
26   '-Wformat',
27   '-Wformat-nonliteral',
28   '-Wformat-security',
29   '-Winit-self',
30   '-Waddress',
31   '-Wno-multichar',
32   '-Wvla',
33   '-Wpointer-arith',
34   '-Wno-error=varargs'
35 ]
36
37 warning_c_flags = [
38   '-Wmissing-declarations',
39   '-Wmissing-include-dirs',
40   '-Wmissing-prototypes',
41   '-Wnested-externs',
42   '-Waggregate-return',
43   '-Wold-style-definition',
44   '-Wdeclaration-after-statement',
45   '-Wno-error=varargs'  
46 ]
47
48 foreach extra_arg : warning_flags
49   if cc.has_argument (extra_arg)
50     add_project_arguments([extra_arg], language: 'c')
51   endif
52   if cxx.has_argument (extra_arg)
53     add_project_arguments([extra_arg], language: 'cpp')
54   endif
55 endforeach
56
57 foreach extra_arg : warning_c_flags
58   if cc.has_argument (extra_arg)
59     add_project_arguments([extra_arg], language: 'c')
60   endif
61 endforeach
62
63 # Set install path
64 nntrainer_prefix = get_option('prefix')
65 nntrainer_libdir = join_paths(nntrainer_prefix, get_option('libdir'))
66 nntrainer_bindir = join_paths(nntrainer_prefix, get_option('bindir'))
67 nntrainer_includedir = join_paths(nntrainer_prefix, get_option('includedir'))
68 nntrainer_inidir = get_option('sysconfdir')
69 application_install_dir = join_paths(nntrainer_bindir, 'applications')
70
71
72 # Set default configuration
73 nntrainer_conf = configuration_data()
74 nntrainer_conf.set('VERSION', meson.project_version())
75 nntrainer_conf.set('PREFIX', nntrainer_prefix)
76 nntrainer_conf.set('EXEC_PREFIX', nntrainer_bindir)
77 nntrainer_conf.set('LIB_INSTALL_DIR', nntrainer_libdir)
78 nntrainer_conf.set('INCLUDE_INSTALL_DIR', nntrainer_includedir)
79
80 # Dependencies
81 if get_option('enable-blas')
82   add_project_arguments('-DUSE_BLAS=1', language:['c','cpp'])
83   if build_platform == 'tizen'
84     blas_dep = dependency('openblas')
85   else
86     blas_dep = dependency('blas-openblas')
87   endif
88 endif
89
90 if get_option('use_gym')
91    add_project_arguments('-DUSE_GYM=1', language:['c','cpp'])
92 endif
93
94 if get_option('enable-logging')
95    add_project_arguments('-D__LOGGING__=1', language:['c','cpp'])
96 endif
97
98 libm_dep = cxx.find_library('m') # cmath library
99 libdl_dep = cxx.find_library('dl') # DL library
100 thread_dep = dependency('threads') # pthread for tensorflow-lite
101 iniparser_dep = dependency('iniparser', required : false) # iniparser
102 if not iniparser_dep.found()
103   message('falling back to find libiniparser library and header files')
104   libiniparser_dep = cxx.find_library('iniparser')
105   if libiniparser_dep.found() and cxx.has_header('iniparser.h', \
106         args : '-I/usr/include/iniparser')
107     iniparser_dep = declare_dependency (dependencies : libiniparser_dep,
108       compile_args : '-I/usr/include/iniparser')
109   endif
110 endif
111
112 jsoncpp_dep = dependency('jsoncpp') # jsoncpp
113 libcurl_dep = dependency('libcurl')
114
115 # Install .pc
116 configure_file(input: 'nntrainer.pc.in', output: 'nntrainer.pc',
117   install_dir: join_paths(nntrainer_libdir, 'pkgconfig'),
118   configuration: nntrainer_conf
119 )
120
121 # Build nntrainer
122 subdir('nntrainer')
123
124 # Build api
125 subdir('api')
126
127 if get_option('enable-app')
128   tflite_dep = dependency('tensorflow-lite', required: true)
129   subdir('Applications')
130 endif
131
132 if get_option('enable-test')
133    subdir('test')
134 endif