Make meson build scripts subprojects friendly
authorMartin Blanchard <tchaik@gmx.com>
Mon, 20 Aug 2018 19:32:10 +0000 (20:32 +0100)
committerNikolaus Rath <Nikolaus@rath.org>
Sat, 25 Aug 2018 19:17:39 +0000 (20:17 +0100)
Multiple meson build scripts improvements including:
 * Bump meson requirement to 0.40.1 (0.40 already required)
 * Declare a dependency object for main library
 * Stop using add_global_arguments()
 * Various minor style fixes

example/meson.build
include/meson.build
lib/meson.build
meson.build

index 7349977e192dae54c3ed41638a2ae6f6e9dba80f..012fda16c4d92cb639a569f8b079f5e46c61b80d 100644 (file)
@@ -20,17 +20,14 @@ threaded_examples = [ 'notify_inval_inode',
 
 foreach ex : examples
     executable(ex, ex + '.c',
-               include_directories: include_dirs,
-               link_with: [ libfuse ],
+               dependencies: [ libfuse_dep ],
                install: false)
 endforeach
 
 
 foreach ex : threaded_examples
     executable(ex, ex + '.c',
-               include_directories: include_dirs,
-               link_with: [ libfuse ],
-               dependencies: thread_dep,
+               dependencies: [ thread_dep, libfuse_dep ],
                install: false)
 endforeach
 
index 417113f041853220814e60cf1237a87e55ceff0c..55cb6f7b5c1c2d4128eeebd6cae224cb1ee4eba0 100644 (file)
@@ -2,4 +2,3 @@ libfuse_headers = [ 'fuse.h', 'fuse_common.h', 'fuse_lowlevel.h',
                    'fuse_opt.h', 'cuse_lowlevel.h' ]
 
 install_headers(libfuse_headers, subdir: 'fuse3')
-
index 0a742caa13f2dd1ab7970e5d34f514531adced24..5dd84508200446411429878ca5931deb9c50569c 100644 (file)
@@ -44,4 +44,6 @@ pkg.generate(libraries: [ libfuse, '-lpthread' ],
              name: 'fuse3',
              description: 'Filesystem in Userspace',
              subdirs: 'fuse3')
-             
+
+libfuse_dep = declare_dependency(include_directories: include_dirs,
+                                 link_with: libfuse, dependencies: deps)
index 0f9ef18ca21390295bd7a5ec780058c185b3d6e8..b6d246cb0927b0e771d1f4f92f8b317b6533ba1f 100644 (file)
@@ -1,5 +1,5 @@
 project('libfuse3', 'c', version: '3.2.5',
-        meson_version: '>= 0.38',
+        meson_version: '>= 0.40.1',
         default_options: [ 'buildtype=debugoptimized' ])
 
 
@@ -63,9 +63,9 @@ configure_file(output: 'config.h',
 #
 # Compiler configuration
 #
-add_global_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-Wall', '-Wextra', '-Wno-sign-compare',
-                     '-Wstrict-prototypes', '-Wmissing-declarations', '-Wwrite-strings',
-                     '-fno-strict-aliasing', language: 'c')
+add_project_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-Wall', '-Wextra', '-Wno-sign-compare',
+                      '-Wstrict-prototypes', '-Wmissing-declarations', '-Wwrite-strings',
+                      '-fno-strict-aliasing', language: 'c')
 
 # Some (stupid) GCC versions warn about unused return values even when they are
 # casted to void. This makes -Wunused-result pretty useless, since there is no
@@ -80,7 +80,7 @@ int main(void) {
 }'''
 if not cc.compiles(code, args: [ '-O0', '-Werror=unused-result' ])
      message('Compiler warns about unused result even when casting to void')
-     add_global_arguments('-Wno-unused-result', language: 'c')
+     add_project_arguments('-Wno-unused-result', language: 'c')
 endif
 
 # '.' will refer to current build directory, which contains config.h