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