zeehio
zeehio

Reputation: 4138

Add compiler flag only if --default-library=shared is used

The meson build system allows to either build shared or static libraries with the option --default-library. However I am not able to know if a shared or static library is being built and I need that to pass at least a define. Is there a way to query the library type?

This was my guess:

libtype = get_option('default-library')
if libtype = 'shared'
  build_dll = ['-DBUILDING_DLL', '-fvisibility=hidden']
else
  build_dll = ''
endif

But apparently I get:

Meson encountered an error in file meson.build, line 10, column 0:
Tried to access unknown option "default-library".

Upvotes: 2

Views: 1239

Answers (1)

zeehio
zeehio

Reputation: 4138

In case someone else has this issue, the solution is simple:

libtype = get_option('default_library')

(note the underscore instead of the dash)

(Credit for the answer goes to jpakkane (the creator of meson), who answered on IRC)

Upvotes: 2

Related Questions