Skip to content

Extend dfetch import to detect CMake FetchContent & ExternalProject #1085

@ben-edna

Description

@ben-edna

Description

dfetch import currently generates a manifest by scanning Git submodules and SVN externals only.
Many modern CMake‑based projects manage dependencies via: [dfetch.rea...thedocs.io]

  • FetchContent_Declare()
  • FetchContent_MakeAvailable()
  • ExternalProject_Add()

It would be extremely helpful if Dfetch could detect these CMake dependency declarations and convert them into dfetch.yaml entries.

Requested Feature

Add optional CMake parsing to dfetch import, for example:

dfetch import --detect-cmake

This should:

  1. Parse CMakeLists.txt and included .cmake files.
  2. Extract URL, GIT_REPOSITORY, and GIT_TAG information (preferablly all options [externalproject_add](of https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add).
  3. Generate equivalent projects: entries in the manifest.
  4. Avoid modifying CMake files unless a future flag (--patch-cmake) is introduced.

Example

From:

FetchContent_Declare(json
    GIT_REPOSITORY https://github.com/nlohmann/json.git
    GIT_TAG v3.11.2
)

To:

projects:
  - name: json
    url: https://github.com/nlohmann/json.git
    tag: v3.11.2

Why

This allows seamless migration from CMake‑managed dependencies to Dfetch’s unified, VCS‑agnostic vendoring approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions