diff options
-rw-r--r-- | docs/markdown/Compiler-properties.md | 2 | ||||
-rw-r--r-- | docs/markdown/Wrap-dependency-system-manual.md | 1 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 6 | ||||
-rw-r--r-- | test cases/common/140 get define/meson.build | 9 |
4 files changed, 14 insertions, 4 deletions
diff --git a/docs/markdown/Compiler-properties.md b/docs/markdown/Compiler-properties.md index d6ee823..50615a1 100644 --- a/docs/markdown/Compiler-properties.md +++ b/docs/markdown/Compiler-properties.md @@ -140,7 +140,7 @@ In older versions (<= 0.30) meson would error out if the size could not be deter Does a function exist? == -Just having a header does say anything about its contents. Sometimes you need to explicitly check if some function exists. This is how we would check whether the function `somefunc` exists in header `someheader.h` +Just having a header doesn't say anything about its contents. Sometimes you need to explicitly check if some function exists. This is how we would check whether the function `somefunc` exists in header `someheader.h` ```meson if compiler.has_function('somefunc', prefix : '#include<someheader.h>') diff --git a/docs/markdown/Wrap-dependency-system-manual.md b/docs/markdown/Wrap-dependency-system-manual.md index fe5a566..fc41b61 100644 --- a/docs/markdown/Wrap-dependency-system-manual.md +++ b/docs/markdown/Wrap-dependency-system-manual.md @@ -69,6 +69,7 @@ To use a subproject simply do this in your top level `meson.build`. ```meson foobar_sp = subproject('foobar') +``` Usually dependencies consist of some header files plus a library to link against. To do this you would declare this internal dependency like this: diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 3d2cd96..406c719 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -782,7 +782,7 @@ class CCompiler(Compiler): return self.exelist[:] def get_preprocess_only_args(self): - return ['-E'] + return ['-E', '-P'] def get_compile_only_args(self): return ['-c'] @@ -1139,10 +1139,10 @@ class CCompiler(Compiler): delim = '"MESON_GET_DEFINE_DELIMITER"' fargs = {'prefix': prefix, 'define': dname, 'delim': delim} code = ''' + {prefix} #ifndef {define} # define {define} #endif - {prefix} {delim}\n{define}''' args = self._get_compiler_check_args(env, extra_args, dependencies, mode='preprocess').to_native() @@ -2135,7 +2135,7 @@ class VisualStudioCCompiler(CCompiler): return ['/FI' + base, '/Yu' + base, '/Fp' + os.path.join(pch_dir, pchname)] def get_preprocess_only_args(self): - return ['/E'] + return ['/EP'] def get_compile_only_args(self): return ['/c'] diff --git a/test cases/common/140 get define/meson.build b/test cases/common/140 get define/meson.build index 339e37a..9342340 100644 --- a/test cases/common/140 get define/meson.build +++ b/test cases/common/140 get define/meson.build @@ -20,6 +20,15 @@ foreach lang : ['c', 'cpp'] error('Please report a bug and help us improve support for this platform') endif + if cc.find_library('z', required : false).found() + # When a C file containing #include <foo.h> is pre-processed and foo.h is + # found in the compiler's default search path, GCC inserts an extra comment + # between the delimiter and the define which causes a parsing error. + # https://github.com/mesonbuild/meson/issues/1726 + ver = cc.get_define('ZLIB_VER_MAJOR', prefix : '#include <zlib.h>') + assert(ver == '1', 'ZLIB_VER_MAJOR value is "@0@" instead of "1"'.format(ver)) + endif + # Check that an undefined value is empty. have = cc.get_define('MESON_FAIL_VALUE') assert(have == '', 'MESON_FAIL_VALUE value is "@0@" instead of ""'.format(have)) |