build: collapse duplicated SHARED/STATIC add_library branches into VIZ_LIBRARY_TYPE - #147
Closed
chiliec wants to merge 1 commit into
Closed
build: collapse duplicated SHARED/STATIC add_library branches into VIZ_LIBRARY_TYPE#147chiliec wants to merge 1 commit into
chiliec wants to merge 1 commit into
Conversation
…Z_LIBRARY_TYPE
Every library and plugin CMakeLists carried the full source + header list twice:
once under add_library(<name> SHARED ...) and once under add_library(<name>
STATIC ...), inside an if(BUILD_SHARED_LIBRARIES)/else()/endif(). 26 files, with
the source list duplicated in each — a standing drift hazard.
Introduce a single VIZ_LIBRARY_TYPE variable at root scope (SHARED when
BUILD_SHARED_LIBRARIES is ON, STATIC otherwise) and replace each dual-branch
block with one add_library(<name> ${VIZ_LIBRARY_TYPE} ...). Net -220 lines.
The duplication had already drifted in libraries/chain: the SHARED branch listed
invite_evaluator.cpp twice and was missing include/graphene/chain/invite_objects.hpp,
while the STATIC branch was correct. Collapsing onto the STATIC list fixes both.
Verification:
- For all 26 targets the collapsed source/header set is byte-set-identical to the
original STATIC branch (which is what the default build, Docker images, and CI
all use via -DBUILD_SHARED_LIBRARIES=FALSE), so static-build behavior is
unchanged.
- Configured a minimal reproduction with real cmake covering both the
explicit-source pattern (chain/time) and the ${CURRENT_TARGET_SOURCES} plugin
pattern: BUILD_SHARED_LIBRARIES=OFF yields STATIC_LIBRARY targets, ON yields
SHARED_LIBRARY targets, matching the previous if/else semantics. graphene::
ALIAS targets still resolve.
No source code touched; BUILD_SHARED_LIBRARIES option and its default (FALSE) are
unchanged. build-mac.sh (which defaults SHARED_LIBS=ON) keeps a working shared
path — now with the chain drift fixed.
On1x
added a commit
that referenced
this pull request
Aug 11, 2026
…RY_TYPE # Conflicts: # libraries/chain/CMakeLists.txt
Member
|
Folded into the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the
BUILD_SHARED_LIBRARIESduplication (F035 in the tech-debt audit). No source code touched.Problem
Every library and plugin
CMakeLists.txtcarried its full source + header list twice — once underadd_library(<name> SHARED ...)and once underadd_library(<name> STATIC ...), wrapped inif(BUILD_SHARED_LIBRARIES)/else()/endif(). 26 files, ~identical lists duplicated per file. Every source added to a library had to be added in two places, which is a standing drift hazard.Why collapse rather than drop the option
The option is still live:
build-mac.shdefaultsSHARED_LIBS=ON, so macOS local dev builds actually exercise the SHARED path. Dropping shared support would break that. So this keeps the option and removes only the duplication.Change
VIZ_LIBRARY_TYPEvariable at root scope:SHAREDwhenBUILD_SHARED_LIBRARIESis ON,STATICotherwise.add_library(<name> ${VIZ_LIBRARY_TYPE} ...).Drift fix (bonus)
The duplication had already drifted in
libraries/chain/CMakeLists.txt: the SHARED branch listedinvite_evaluator.cpptwice and was missinginclude/graphene/chain/invite_objects.hpp, while the STATIC branch was correct. Collapsing onto the STATIC list fixes both — shared builds of the chain lib were previously missing a header from the target's file list.Verification
-DBUILD_SHARED_LIBRARIES=FALSE, static-build behavior is provably unchanged.chain/time) and the${CURRENT_TARGET_SOURCES}plugin pattern.BUILD_SHARED_LIBRARIES=OFF→STATIC_LIBRARYtargets;=ON→SHARED_LIBRARYtargets — matching the previousif/elsesemantics.graphene::<name>ALIAS targets still resolve.(Full end-to-end compile not run in my environment — no Boost dev libs / submodules available — but the transformation is a mechanical branch-collapse with configure-level validation and set-level equivalence to the shipping static path.)