Skip to content

Commit c79d875

Browse files
committed
removed unecessary library links from build system
1 parent 3ff152d commit c79d875

4 files changed

Lines changed: 32 additions & 7 deletions

File tree

gemc/gdetector/meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ LD += {
3333
'gdetector_options.h'
3434
),
3535

36-
'dependencies' : [yaml_cpp_dep, clhep_deps, geant4_core_deps, expat_dep],
36+
# expat is a geant4 static-link need (no source here compiles against it);
37+
# it is linked once at the final executables to avoid duplicate -lexpat.
38+
'dependencies' : [yaml_cpp_dep, clhep_deps, geant4_core_deps],
3739
'internal_dependencies' : internal_deps,
3840

3941
'geo_build' : {

gemc/gparticle/meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ LD += {
3030
'gparticleConventions.h'
3131
),
3232

33-
'dependencies' : [yaml_cpp_dep, clhep_deps, geant4_core_deps, expat_dep, zlib_dep],
33+
# expat/zlib are geant4's static-link needs (no source here compiles against them);
34+
# they are linked once at the final executables to avoid duplicate -lexpat/-lz.
35+
'dependencies' : [yaml_cpp_dep, clhep_deps, geant4_core_deps],
3436
'internal_dependencies' : internal_deps,
3537

3638
'examples' : {

gemc/gphysics/meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ LD += {
1818
'gphysicsConventions.h'
1919
),
2020

21-
'dependencies' : [yaml_cpp_dep, clhep_deps, geant4_core_deps, expat_dep, zlib_dep],
21+
# expat/zlib are geant4's static-link needs (no source here compiles against them);
22+
# they are linked once at the final executables to avoid duplicate -lexpat/-lz.
23+
'dependencies' : [yaml_cpp_dep, clhep_deps, geant4_core_deps],
2224
'internal_dependencies' : internal_deps,
2325

2426
'examples' : {

meson.build

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)