diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-10-16 10:03:13 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-11-03 18:10:36 +0200 |
commit | 63f4f9481ebc865b11a06aeecf0c624104d46afd (patch) | |
tree | 13ff86bcf410ae872ebc1c33cac851104d21ecf0 /docs/markdown/snippets | |
parent | 8cd7f7871bc99e5ed709d4f0ec54997047f3e335 (diff) | |
download | meson-63f4f9481ebc865b11a06aeecf0c624104d46afd.zip meson-63f4f9481ebc865b11a06aeecf0c624104d46afd.tar.gz meson-63f4f9481ebc865b11a06aeecf0c624104d46afd.tar.bz2 |
Add new compiler.get_argument_syntax method
Some compilers try very had to pretend they're another compiler (ICC
pretends to be GCC and Linux and MacOS, and MSVC on windows), Clang
behaves much like GCC, but now also has clang-cl, which behaves like MSVC.
This method provides an easy way to determine whether testing for MSVC
like arguments `/w1234` or gcc like arguments `-Wfoo` are likely to
succeed, without having to check for dozens of compilers and the host
operating system, (as you would otherwise have to do with ICC).
Diffstat (limited to 'docs/markdown/snippets')
-rw-r--r-- | docs/markdown/snippets/compiler_argument_syntax.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/markdown/snippets/compiler_argument_syntax.md b/docs/markdown/snippets/compiler_argument_syntax.md new file mode 100644 index 0000000..6ae32d4 --- /dev/null +++ b/docs/markdown/snippets/compiler_argument_syntax.md @@ -0,0 +1,22 @@ +## new compiler method `get_argument_syntax` + +The compiler object now has `get_argument_syntax` method, which returns a +string value of `gcc`, `msvc`, or an undefined value string value. This can be +used to determine if a compiler uses gcc syntax (`-Wfoo`), msvc syntax +(`/w1234`), or some other kind of arguments. + +```meson +cc = meson.get_compiler('c') + +if cc.get_argument_syntax() == 'msvc' + if cc.has_argument('/w1235') + add_project_arguments('/w1235', language : ['c']) + endif +elif cc.get_argument_syntax() == 'gcc' + if cc.has_argument('-Wfoo') + add_project_arguments('-Wfoo', language : ['c']) + endif +elif cc.get_id() == 'some other compiler' + add_project_arguments('--error-on-foo', language : ['c']) +endif +``` |