Eable Logging
[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 ]
35
36 warning_c_flags = [
37   '-Wmissing-declarations',
38   '-Wmissing-include-dirs',
39   '-Wmissing-prototypes',
40   '-Wnested-externs',
41   '-Waggregate-return',
42   '-Wold-style-definition',
43   '-Wdeclaration-after-statement'
44 ]
45
46 foreach extra_arg : warning_flags
47   if cc.has_argument (extra_arg)
48     add_project_arguments([extra_arg], language: 'c')
49   endif
50   if cxx.has_argument (extra_arg)
51     add_project_arguments([extra_arg], language: 'cpp')
52   endif
53 endforeach
54
55 foreach extra_arg : warning_c_flags
56   if cc.has_argument (extra_arg)
57     add_project_arguments([extra_arg], language: 'c')
58   endif
59 endforeach
60
61 # Set install path
62 nntrainer_prefix = get_option('prefix')
63 nntrainer_libdir = join_paths(nntrainer_prefix, get_option('libdir'))
64 nntrainer_bindir = join_paths(nntrainer_prefix, get_option('bindir'))
65 nntrainer_includedir = join_paths(nntrainer_prefix, get_option('includedir'))
66 nntrainer_inidir = get_option('sysconfdir')
67 application_install_dir = join_paths(nntrainer_bindir, 'applications')
68
69
70 # Set default configuration
71 nntrainer_conf = configuration_data()
72 nntrainer_conf.set('VERSION', meson.project_version())
73 nntrainer_conf.set('PREFIX', nntrainer_prefix)
74 nntrainer_conf.set('EXEC_PREFIX', nntrainer_bindir)
75 nntrainer_conf.set('LIB_INSTALL_DIR', nntrainer_libdir)
76 nntrainer_conf.set('INCLUDE_INSTALL_DIR', nntrainer_includedir)
77
78 # Dependencies
79 if get_option('enable-blas')
80   add_project_arguments('-DUSE_BLAS=1', language:['c','cpp'])
81   if build_platform == 'tizen'
82     blas_dep = dependency('openblas')
83   else
84     blas_dep = dependency('blas-openblas')
85   endif
86 endif
87
88 if get_option('use_gym')
89    add_project_arguments('-DUSE_GYM=1', language:['c','cpp'])
90 endif
91
92 if get_option('enable-logging')
93    add_project_arguments('-D__LOGGING__=1', language:['c','cpp'])
94 endif
95
96 libm_dep = cxx.find_library('m') # cmath library
97 libdl_dep = cxx.find_library('dl') # DL library
98 thread_dep = dependency('threads') # pthread for tensorflow-lite
99 iniparser_dep = dependency('iniparser', required : false) # iniparser
100 if not iniparser_dep.found()
101   message('falling back to find libiniparser library and header files')
102   libiniparser_dep = cxx.find_library('iniparser')
103   if libiniparser_dep.found() and cxx.has_header('iniparser.h', \
104         args : '-I/usr/include/iniparser')
105     iniparser_dep = declare_dependency (dependencies : libiniparser_dep,
106       compile_args : '-I/usr/include/iniparser')
107   endif
108 endif
109
110 jsoncpp_dep = dependency('jsoncpp') # jsoncpp
111 libcurl_dep = dependency('libcurl')
112
113 # Install .pc
114 configure_file(input: 'nntrainer.pc.in', output: 'nntrainer.pc',
115   install_dir: join_paths(nntrainer_libdir, 'pkgconfig'),
116   configuration: nntrainer_conf
117 )
118
119 # Build nntrainer
120 subdir('nntrainer')
121
122 if get_option('enable-app')
123   tflite_dep = dependency('tensorflow-lite', required: true)
124   subdir('Applications')
125 endif
126
127 # Build api
128 subdir('api')
129
130 if get_option('enable-test')
131    subdir('test')
132 endif