Skip to content

Commit e06f3df

Browse files
Leonardo FioreEmmanuelP
authored andcommitted
meson: avoid symbol export when building statically with MSVC
Ensures that __declspec(dllexport) is not applied when Aravis is built statically with MSVC. Avoids unintended .exp/.lib files when building user executables.
1 parent 453a8a9 commit e06f3df

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

meson.build

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,21 @@ elif cc.get_id()=='msvc'
4747
add_project_arguments(cc.get_supported_arguments(warning_c_args), language: 'c')
4848
endif
4949

50+
build_shared = get_option('default_library') == 'shared'
51+
5052
if cc.get_id() == 'msvc'
51-
cc_export_define = '__declspec(dllexport) extern'
53+
if build_shared
54+
cc_export_define = '__declspec(dllexport) extern'
55+
else
56+
cc_export_define = 'extern' # static build: no export
57+
endif
5258
elif cc.has_argument('-fvisibility=hidden')
53-
add_project_arguments('-fvisibility=hidden', language: 'c')
54-
cc_export_define = 'extern __attribute__ ((visibility ("default")))'
59+
if build_shared
60+
add_project_arguments('-fvisibility=hidden', language: 'c')
61+
cc_export_define = 'extern __attribute__ ((visibility ("default")))'
62+
else
63+
cc_export_define = 'extern'
64+
endif
5565
else
5666
cc_export_define = 'extern'
5767
endif

0 commit comments

Comments
 (0)