2

I basically want to do something like this

if get_option('buildtype') == 'debug'
    add_project_arguments('-fsanitize=address', language : 'c')
    add_project_link_arguments('-fsanitize=address', language : 'c')
endif

except using the b_sanitize=address option since the above generates warnings. Is this possible? I have a suspicion it might not be seeing as you can't change options outside of project() but I'm hoping there's a way to do it.

Scoopta
  • 987
  • 1
  • 9
  • 22
  • 1
    What do you mean by "you can't change options outside of project()"? What you've written should work. – bool3max Dec 29 '19 at 14:58
  • Provided that those functions are called before any others that utilize their result, e.g. any `executable` call that uses the same language. – bool3max Dec 29 '19 at 15:06
  • @bool3max I can do that however meson gives me a warning telling me that I shouldn't do that but should instead set the meson flag `b_sanitize=address` which will cause meson to set the appropriate compiler flags for me. The problem is meson options such as `b_sanitize` can only be set in the project declaration as far as I know. My question is, is there a way to do this the meson recommended way or do I have to live with the warnings caused by manually setting those compiler flags – Scoopta Dec 30 '19 at 20:52
  • Check my answer – bool3max Dec 31 '19 at 08:53
  • (He never posted an answer :( ) – Fredrick Brennan Jun 15 '21 at 02:38

0 Answers0