90ede2715a1255bf49bddfe6f8b4082c061b06b7
[platform/adaptation/npu/trix-engine.git] / meson.build
1 # Do NOT enable C in core
2 # C++ is only allowed inside test directory for gtest.
3
4 project('npu-engine', ['c', 'cpp'],
5   version: '1.1.4',
6   license: ['Proprietary'],
7   meson_version: '>=0.50.0',
8   default_options: [
9     'werror=true',
10     'warning_level=1',
11     'c_std=gnu89',
12     'cpp_std=gnu++11',
13   ]
14 )
15
16 cc = meson.get_compiler('c')
17 cpp = meson.get_compiler('cpp')
18
19 warning_c_flags = [
20   '-Wmissing-declarations',
21   '-Wmissing-prototypes',
22   '-Wnested-externs',
23   '-Waggregate-return',
24   '-Wold-style-definition',
25   '-Wdeclaration-after-statement',
26   '-Wno-format-truncation',
27 ]
28
29 foreach extra_arg : warning_c_flags
30   if cc.has_argument (extra_arg)
31     add_project_arguments([extra_arg], language : 'c')
32   elif cpp.has_argument (extra_arg)
33     add_project_arguments([extra_arg], language : 'cpp')
34   endif
35 endforeach
36
37 # Add version arguments
38 version = meson.project_version().split('.')
39 add_project_arguments('-DVER_NE_MAJOR=' + version[0], language: ['c', 'cpp'])
40 add_project_arguments('-DVER_NE_MINOR=' + version[1], language: ['c', 'cpp'])
41 add_project_arguments('-DVER_NE_EXTRA=' + version[2], language: ['c', 'cpp'])
42
43 # Install Paths
44 ne_prefix = get_option('prefix')
45 ne_libdir = join_paths(ne_prefix, get_option('libdir'))
46 ne_bindir = join_paths(ne_prefix, get_option('bindir'))
47 ne_includedir = join_paths(ne_prefix, get_option('includedir'))
48 ne_inidir = get_option('sysconfdir')
49 add_project_arguments('-DNE_INIDIR="' + ne_inidir + '"', language: ['c', 'cpp'])
50 ne_datadir = join_paths(ne_prefix, join_paths(get_option('datadir'), 'npu-engine'))
51
52 ne_common_inc = include_directories('include/common')
53 ne_host_inc = include_directories('include/host')
54
55 libdl_dep = cc.find_library('dl') # DL library
56 libm_dep = cc.find_library('m') # math library
57 libdrm_dep = dependency('libdrm') # libdrm library
58 thread_dep = dependency('threads') # pthread library
59 iniparser_dep = dependency('iniparser') # iniparser library
60
61 if get_option('enable_npu_emul')
62   add_project_arguments('-I/opt/trinity/include', language: ['c', 'cpp'])
63   add_project_arguments('-DENABLE_EMUL', language: ['c', 'cpp'])
64 endif
65 if get_option('enable_data_manip')
66   add_project_arguments('-DENABLE_MANIP', language: ['c', 'cpp'])
67 endif
68 if get_option('enable_buffering')
69   add_project_arguments('-DENABLE_BUFFERING', language: ['c', 'cpp'])
70 endif
71
72 subdir('src')
73 subdir('tests')
74
75 # Set configuration to install .ini
76 ne_install_conf = configuration_data()
77
78 ne_install_conf.set('VERSION', meson.project_version())
79 ne_install_conf.set('PREFIX', ne_prefix)
80 ne_install_conf.set('EXEC_PREFIX', ne_bindir)
81 ne_install_conf.set('LIB_INSTALL_DIR', ne_libdir)
82 ne_install_conf.set('INCLUDE_INSTALL_DIR', ne_includedir)
83
84 ne_install_conf.set('RESV_MEM_SIZE', get_option('resv_mem_size'))
85 ne_install_conf.set('WORKING_DIR', get_option('working_dir'))
86 ne_install_conf.set('LOG_DIR', get_option('log_dir'))
87
88 # Install .ini
89 configure_file(input: 'npu-engine.ini.in', output: 'npu-engine.ini',
90   install_dir: ne_inidir,
91   configuration: ne_install_conf)
92
93 # Install .pc
94 configure_file(input: 'npu-engine.pc.in', output: 'npu-engine.pc',
95   install_dir: join_paths(ne_libdir, 'pkgconfig'),
96   configuration: ne_install_conf)
97
98 # Install headers
99 ne_install_headers = [
100   'include/common/npubinfmt.h',
101   'include/common/typedef.h',
102   'include/host/libnpuhost.h',
103 ]
104
105 install_headers(ne_install_headers, subdir: 'npu-engine')