Skip to content

fix(cmake): Update outdated FetchContent fallback GIT_TAGs in UnifiedDependencies.cmake #509

Description

@kcenon

Part of kcenon/common_system#454

What

cmake/UnifiedDependencies.cmake defaults FetchContent fallback GIT_TAG to v0.1.0 for all kcenon ecosystem dependencies. This is outdated — common_system is at v0.2.0 and thread_system is at v0.3.1.

  • Current: Default GIT_TAG is v0.1.0 (line 232) when not explicitly overridden by the caller
  • Expected: Default GIT_TAG should match the minimum compatible version for each dependency, or at minimum warn when the hardcoded default is used
  • Scope: cmake/UnifiedDependencies.cmake lines 231-234

Why

When find_package fails and FetchContent is used as a fallback (controlled by UNIFIED_ALLOW_FETCHCONTENT_FALLBACK), the dependency is fetched at v0.1.0. This means:

  • common_system v0.1.0 is fetched instead of v0.2.0 — may lack APIs that logger_system v0.1.3 depends on
  • thread_system v0.1.0 is fetched instead of v0.3.1 — significant API changes between these versions
  • Silent ABI mismatch if the consumer also has newer versions of these libraries elsewhere

The fallback is intended as a development convenience, but fetching an incompatible version defeats the purpose.

Where

Location Current Expected
cmake/UnifiedDependencies.cmake:232 set(_UFD_GIT_TAG "v0.1.0") Version-aware default or per-dependency map
FetchContent repo config (lines 98-110) Maps dependency names to GitHub repos Correct, but missing version info

How

Technical Approach

Option A (Minimal fix): Update the hardcoded default to the minimum required versions per dependency using the existing _UNIFIED_VERSIONS map pattern:

# Per-dependency version defaults
set(_UNIFIED_DEFAULT_TAGS
    "common_system=v0.2.0"
    "thread_system=v0.3.1"
)

if(NOT _UFD_GIT_TAG)
    # Look up per-dependency default, fall back to generic default
    foreach(_entry IN LISTS _UNIFIED_DEFAULT_TAGS)
        string(REGEX MATCH "^${DEP_NAME}=(.+)$" _match "${_entry}")
        if(_match)
            set(_UFD_GIT_TAG "${CMAKE_MATCH_1}")
            break()
        endif()
    endforeach()
    if(NOT _UFD_GIT_TAG)
        set(_UFD_GIT_TAG "v0.1.0")
    endif()
endif()

Option B (Simpler): Just update the single default from v0.1.0 to the lowest common compatible version, and add a warning when the default is used.

Acceptance Criteria

  • FetchContent fallback for common_system uses v0.2.0 or later
  • FetchContent fallback for thread_system uses v0.3.1 or later
  • Warning is emitted when the default GIT_TAG is used (already partially present at line 235-240)
  • Explicit GIT_TAG parameter in unified_find_dependency() calls still takes precedence

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions