Adding -g, -Wall etc manually
The basic design principle of Meson is that common operations and features should work out of the box without any user intervention. That means that debug information should be enabled for debug builds (which are the default). Similarly basic warning flags should always be on, because anyone coding without -Wall is not doing software development, but practicing astrology.
Many people seem to be burned by existing build systems and add these flags manually as the first thing they do. There is no need, we do it for you. Similarly instead of manually adding flags such as -Wextra, look into changing the option warning_level instead.
Adding these flags manually is also bad for portability because there are compilers that do not support them.
Building full paths to files in the source tree
This pattern looks something like this:
myfiles = files('@0@/@1@'.format(meson.current_source_dir(), 'file.c', [other files here])
This makes sense if you are used to the Make's "everything is a string" semantics. Meson is not like that, it tries to take care of mundane things for you. The simpler version of the above is this:
myfiles = files('file.c', [other files here])
This will verify the existance of the file when called and will store the full location. The output can be used in any other subdirectory in any target and Meson will evaluate the correct path for you. There may be some corners where file objects are not accepted where they should. Please file bugs if you encounter one of these.
The former syntax works currently but is already an error in current Git master.
Using target_machine in cross compilation
Meson supports the full canadian cross environment. It is very powerful but unfortunately quite confusing until you wrap your brain around it. Many people will choose to use target_machine instead of host_machine for their cross compilation, even though that is incorrect and leads to interesting bugs. Fortunately there is a simple rule of thumb which is correct 99% of the time:
- build_machine is the desktop or laptop computer you are using to do your development
- host_machine is the low powered IoT device, ARM board or equivalent that will run your program
Manually setting up dependencies between targets
This happens often when defining custom targets or run targets that operate on the output of other custom targets. In Meson outputs carry dependency information with them. If you use the output of one target as an input to another, Meson will automatically set up all the dependencies. A consistent antipattern that can be seen in projects in the wild is going through strange contortions to build a string representing the path of a target output and then adding the dependency object to the target's extra dependency keyword argument. That is only meant for programs that do not take all their inputs as arguments because, for example, they do file globbing internally.
Like with files there may be cases where using the output object directly fails. These are all bugs, please report them.