[Meson] Add a fallback mechanism for build dependency on iniparser
authorWook Song <wook16.song@samsung.com>
Mon, 1 Jun 2020 07:21:10 +0000 (16:21 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 1 Jun 2020 09:37:45 +0000 (18:37 +0900)
The upstream of iniparser does not provide .pc or .cmake files.
Therefore, in order to distribute the development package for iniparser,
providing those files is up to the package maintainers for various
platforms. This is the reason why some platforms have the .pc file for
iniparser and others don't. To resolve this issue, this patch adds a
fallback mechanism for build dependency on iniparser to the meson build
script.

Signed-off-by: Wook Song <wook16.song@samsung.com>
meson.build

index b792ea1..9154404 100644 (file)
@@ -72,7 +72,19 @@ ne_host_inc = include_directories('include/host')
 libdl_dep = cc.find_library('dl') # DL library
 libm_dep = cc.find_library('m') # math library
 thread_dep = dependency('threads') # pthread library
-iniparser_dep = dependency('iniparser') # iniparser library
+iniparser_dep = dependency('iniparser', required: false) # iniparser library
+if not iniparser_dep.found()
+  libiniparser = cpp.find_library('iniparser')
+  if libiniparser.found() and cpp.has_header('iniparser.h',\
+      args : '-I/usr/include/iniparser')
+    iniparser_dep = declare_dependency(
+      compile_args : '-I/usr/include/iniparser',
+      dependencies: libiniparser,
+    )
+  else
+    error('Failed to resovle dependency on libiniparser')
+  endif
+endif
 
 if get_option('enable_npu_emul')
   add_project_arguments('-I/opt/trinity/include', language: ['c', 'cpp'])