[ccapi] Initial draft for c++ API
[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 add_project_arguments('-DMIN_CPP_VERSION=201402', language:['c','cpp'])
13
14 cc = meson.get_compiler('c')
15 cxx = meson.get_compiler('cpp')
16 build_platform = ''
17
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'])
22
23   if get_option('enable-tizen-feature-check')
24     add_project_arguments('-D__FEATURE_CHECK_SUPPORT__', language: ['c', 'cpp'])
25   endif
26 endif
27
28 warning_flags = [
29   '-Wredundant-decls',
30   '-Wwrite-strings',
31   '-Wformat',
32   '-Wformat-nonliteral',
33   '-Wformat-security',
34   '-Winit-self',
35   '-Waddress',
36   '-Wno-multichar',
37   '-Wvla',
38   '-Wpointer-arith',
39   '-Wno-error=varargs',
40   '-O2',
41   '-ftree-vectorize'
42 ]
43
44 warning_c_flags = [
45   '-Wmissing-declarations',
46   '-Wmissing-include-dirs',
47   '-Wmissing-prototypes',
48   '-Wnested-externs',
49   '-Waggregate-return',
50   '-Wold-style-definition',
51   '-Wdeclaration-after-statement',
52   '-Wno-error=varargs'
53 ]
54
55 foreach extra_arg : warning_flags
56   if cc.has_argument (extra_arg)
57     add_project_arguments([extra_arg], language: 'c')
58   endif
59   if cxx.has_argument (extra_arg)
60     add_project_arguments([extra_arg], language: 'cpp')
61   endif
62 endforeach
63
64 foreach extra_arg : warning_c_flags
65   if cc.has_argument (extra_arg)
66     add_project_arguments([extra_arg], language: 'c')
67   endif
68 endforeach
69
70 # Set install path
71 nntrainer_prefix = get_option('prefix')
72 nntrainer_libdir = join_paths(nntrainer_prefix, get_option('libdir'))
73 nntrainer_bindir = join_paths(nntrainer_prefix, get_option('bindir'))
74 nntrainer_includedir = join_paths(nntrainer_prefix, get_option('includedir'))
75 nntrainer_inidir = get_option('sysconfdir')
76 application_install_dir = join_paths(nntrainer_bindir, 'applications')
77
78
79 # Set default configuration
80 nntrainer_conf = configuration_data()
81 nntrainer_conf.set('VERSION', meson.project_version())
82 nntrainer_conf.set('PREFIX', nntrainer_prefix)
83 nntrainer_conf.set('EXEC_PREFIX', nntrainer_bindir)
84 nntrainer_conf.set('LIB_INSTALL_DIR', nntrainer_libdir)
85 nntrainer_conf.set('INCLUDE_INSTALL_DIR', nntrainer_includedir)
86
87 dummy_dep = dependency('', required: false)
88 openmp_dep = dependency('openmp')
89
90 blas_dep = dummy_dep
91 # Dependencies
92 if get_option('enable-cublas')
93    add_project_arguments('-DUSE_CUBLAS=1', language:['c','cpp'])
94 endif
95
96 if get_option('enable-blas')
97   add_project_arguments('-DUSE_BLAS=1', language:['c','cpp'])
98   if build_platform == 'tizen'
99     blas_dep = dependency('openblas')
100   else
101     blas_dep = dependency('blas-openblas')
102   endif
103 endif
104
105 if get_option('use_gym')
106    add_project_arguments('-DUSE_GYM=1', language:['c','cpp'])
107 endif
108
109 if get_option('enable-logging')
110    add_project_arguments('-D__LOGGING__=1', language:['c','cpp'])
111 endif
112
113 if get_option('enable-test')
114   add_project_arguments('-DENABLE_TEST=1', language:['c','cpp'])
115 endif
116
117 libm_dep = cxx.find_library('m') # cmath library
118 libdl_dep = cxx.find_library('dl') # DL library
119 thread_dep = dependency('threads') # pthread for tensorflow-lite
120 iniparser_dep = dependency('iniparser', required : false) # iniparser
121 if not iniparser_dep.found()
122   message('falling back to find libiniparser library and header files')
123   libiniparser_dep = cxx.find_library('iniparser')
124   if libiniparser_dep.found() and cxx.has_header('iniparser.h', \
125         args : '-I/usr/include/iniparser')
126     iniparser_dep = declare_dependency (dependencies : libiniparser_dep,
127       compile_args : '-I/usr/include/iniparser')
128   endif
129 endif
130
131 jsoncpp_dep = dependency('jsoncpp') # jsoncpp
132 libcurl_dep = dependency('libcurl')
133 gtest_dep = dependency('gtest', required: false)
134
135 # Install .pc
136 configure_file(input: 'nntrainer.pc.in', output: 'nntrainer.pc',
137   install_dir: join_paths(nntrainer_libdir, 'pkgconfig'),
138   configuration: nntrainer_conf
139 )
140
141 # Build nntrainer
142 subdir('nntrainer')
143
144 # Build api
145 subdir('api')
146
147 if get_option('enable-app')
148   tflite_dep = dependency('tensorflow-lite', required: true)
149   subdir('Applications')
150 endif
151
152 if get_option('enable-test')
153    subdir('test')
154 endif
155
156 if get_option('enable-nnstreamer-tensor-filter')
157    nnstreamer_dep = dependency('nnstreamer', required: true)
158    subdir('nnstreamer/tensor_filter')
159 endif