meson icon indicating copy to clipboard operation
meson copied to clipboard

Dependency compile_args cannot carry language-specific arguments

Open mitchgrout opened this issue 9 months ago • 2 comments

Currently, a dep object created via declare_dependency can supply compilation arguments through the compile_args: field. These appear to be applied the same regardless of the language of the build target. This can be a problem in mixed C/C++ builds for example:

foo_dep = declare_dependency(
  link_with: foo_lib,
  compile_args: [
    '-Wno-register', # Valid for `g++` where `register` isn't a keyword; invalid for `gcc` though
  ],
)

c_lib   = library(..., dependency: foo_dep) # Breaks due to `-Wregister`
cpp_lib = library(..., dependency: foo_dep) # No problems

What's the motivation behind compile_args? Would it be possible to introduce a per-language version of compile_args, e.g. by using the same <lang>_args syntax available to build-target calls? Or, is it simply recommended to avoid the use of compile_args itself?

mitchgrout avatar Feb 21 '25 02:02 mitchgrout

There is an issue open somewhere about this that I'm assigned to...

Long story short this is known and I'm going to fix it.

dcbaker avatar Feb 21 '25 04:02 dcbaker

The longer story is this is a leaky abstraction over pkg-config

dcbaker avatar Feb 21 '25 17:02 dcbaker

#5723

bruchar1 avatar Mar 06 '25 13:03 bruchar1

Perhaps close this as a duplicate of gh-5723?

rgommers avatar Jul 17 '25 14:07 rgommers