Meson: How do I choose which compiler Meson will use?

Created on 7 May 2017  路  9Comments  路  Source: mesonbuild/meson

The default is cc and I want to use clang, but there doesn't seem to be an option in mesonconf...

Most helpful comment

Yes, or create a second build directory for clang

I often do:

meson build-gcc
CC=clang CXX=clang++ meson build-clang

All 9 comments

env CC=clang meson ...

Error during basic setup:

Trying to run Meson on a build directory that has already been configured.
If you want to build it, just run your build command (e.g. ninja) inside the
build directory. Meson will autodetect any changes in your setup and regenerate
itself as required.

If you want to change option values, use the mesonconf tool instead.

So I have to delete my build directory?

Yes, or create a second build directory for clang

I often do:

meson build-gcc
CC=clang CXX=clang++ meson build-clang

Alright then.

I'm interested in having a directive inside the meson.build file to force the compiler to a specific option.
Is there something upstream which can help me achieve this or if not, would it be useful to have this upstream ?

For instance, bazel can be configured to use a specific toolchain

I'm interested in having a directive inside the meson.build file to force the compiler to a specific option.

Can you give an example of what you're looking for? Most of this is already possible in Meson.

I'm looking for a way to have my meson.build not depend on environment variables and have everything it needs in itself.

You're looking for the native file feature: https://mesonbuild.com/Release-notes-for-0-49-0.html#native-config-files

Was this page helpful?
0 / 5 - 0 ratings