@@ -149,8 +149,17 @@ foreach L : LD
149149 endforeach
150150
151151 if plugins != empty_dict
152+ # Same rationale as the example executables: the module library (link_with)
153+ # propagates this_deps' link args, so pass only their compile/include part to
154+ # the plugins to avoid duplicate -l flags; zlib is linked once explicitly.
155+ # (computed here, before 'sources' is rebound by the plugin loop below.)
156+ if sources.contains('' )
157+ plugin_base_deps = [this_deps, zlib_dep]
158+ else
159+ plugin_base_deps = [declare_dependency (dependencies : this_deps).partial_dependency(compile_args : true , includes : true ), zlib_dep]
160+ endif
152161 foreach name, sources : plugins
153- this_plugin_dependencies = [this_deps, zlib_dep]
162+ this_plugin_dependencies = plugin_base_deps
154163 if plugin_dependencies.has_key(name)
155164 this_plugin_dependencies += plugin_dependencies[name]
156165 endif
@@ -205,7 +214,17 @@ foreach L : LD
205214 example_sources = sources_and_arguments[0 ] + qrc_examples_compiled_sources
206215 arguments = sources_and_arguments[1 ]
207216
208- example_deps = this_deps + [zlib_dep]
217+ # The module library (link_with) already propagates the link args of
218+ # this_deps, so only the compile/include part is needed here. Re-passing
219+ # the full deps duplicates -l flags and makes ld warn "ignoring duplicate
220+ # libraries: -lsqlite3". expat/zlib are geant4's static-link needs and are
221+ # not module deps, so they are linked here exactly once.
222+ if sources.contains('' )
223+ example_deps = this_deps + [expat_dep, zlib_dep]
224+ else
225+ example_compile_deps = declare_dependency (dependencies : this_deps).partial_dependency(compile_args : true , includes : true )
226+ example_deps = [example_compile_deps, expat_dep, zlib_dep]
227+ endif
209228 exe = executable (
210229 name,
211230 example_sources,
@@ -245,7 +264,7 @@ gemc = executable(
245264 gemc_sources + qrc_gemc_sources,
246265 install : true ,
247266 install_dir : get_option (' bindir' ),
248- dependencies : [yaml_cpp_dep, qt6_deps, clhep_deps, geant4_deps, ogl_deps, assimp_dep, zlib_dep],
267+ dependencies : [yaml_cpp_dep, qt6_deps, clhep_deps, geant4_deps, ogl_deps, assimp_dep, expat_dep, zlib_dep],
249268 include_directories : all_includes,
250269 link_with : all_libs,
251270 override_options : [' b_pie=true' ]
@@ -258,7 +277,7 @@ pkg.generate(
258277 description : project_description,
259278 version : meson .project_version(),
260279 libraries : all_libs,
261- libraries_private : [yaml_cpp_dep, clhep_deps, geant4_core_deps, zlib_dep],
280+ libraries_private : [yaml_cpp_dep, clhep_deps, geant4_core_deps, expat_dep, zlib_dep],
262281)
263282
264283# test gemc options. Adjust root to fit the geometry
0 commit comments