Repository navigation
build: add static dependency preset for distributable binaries - #48
Merged
Merged
Conversation
Development builds keep reusing system packages, but release artifacts must not depend on them: 'vulcal_player' previously linked the system libSDL3/libspdlog/libfmt, so packaged games failed on machines without those libraries installed. - add VULCAL_STATIC_DEPS which sets FETCHCONTENT_TRY_FIND_PACKAGE_MODE=NEVER, forcing every vendored dependency to be built from source - force the SDL_STATIC/SDL_SHARED cache entries so source builds stay static - add a release-static preset (Release, no profiling, no tests) - add a Linux CI job that builds the preset and asserts the Player does not link libSDL3/libspdlog/libfmt dynamically
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.
问题
开发时的构建会静默复用系统包(因为每个
FetchContent_Declare都带FIND_PACKAGE_ARGS),导致vulcal_player动态链接libSDL3.so、libspdlog.so、libfmt.so:而
cmake/third_party_sdl3.cmake里的SDL_STATIC ON只对"从源码构建 SDL"生效,命中系统包时完全不参与。后果:error while loading shared libraries;release-3.2.22对系统包无效(本机实际用了 3.4.18)。改动
VULCAL_STATIC_DEPSoption(默认OFF,开发构建行为不变)FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER,所有 vendor 依赖强制源码构建SDL_STATIC/SDL_SHARED缓存项加FORCE,避免缓存脏值翻转链接方式release-staticpreset:Release +VULCAL_STATIC_DEPS=ON+ 关 profiling + 关测试,输出到build/release-staticldd不含libSDL3/libspdlog/libfmt,防止将来悄悄回退验证
链接行确认:
libSDL3.a libspdlog.a libglm.a libyaml-cpp.a liblua.a libvulcal_miniz.a。体积:7.4 MB(未 strip)/ 6.2 MB(strip)。静态化的目的不是减小体积,而是去掉运行时的 SDL3/spdlog/fmt 依赖。
说明与后续
dlopen),这是预期行为;-ffunction-sections -fdata-sections -Wl,--gc-sections+ strip 进一步压缩体积。