Skip to content

[Discussion] Install-based caching for libraries not suited for add_subdirectory #689

@TobiasWallner

Description

@TobiasWallner

First off i really enjoy your project and it has helped me tremendously in the past.

However, sometimes i come across a library that is not written to be used with add_subdirectory, it is written to be installed and used with find_package.

If not used with find_package all sorts off issues can arise from:

  • are not designed to be consumed via add_subdirectory
  • assume they are the top-level project
  • expose un-namespaced targets that clash with other dependencies
  • rely on install-time configuration logic
  • enable tests/examples by default when included as a subproject

So based on CPM.cmakes source caching and CMake only idea i experimented with a small complementary tool: https://github.com/TobiasWallner/BPM.cmake

It provides: BPMInstallPackage with:

  • Git source caching (similar to CPM)
  • A manifest-based hash derived from: compiler ID + version, toolchain file (if present), build flags, user-provided CMake arguments, etc. (all things CMake knows)
  • Install directories per hash
  • find_package(... CONFIG NO_DEFAULT_PATH) against that install

This effectively creates an light weight install cache per build configuration, while keeping CPM available for normal source-based dependencies.

I’m currently using it alongside CPM as an opt-in for libraries that don’t behave well as subprojects.

I would be interested in your thoughts:

  • Do you see value in this pattern (fingerprinted installs and maybe even build caches) for CPM.cmake?
  • Would it make sense to document this as an advanced/opt-in integration strategy?
  • Or do you feel this is outside the intended scope of CPM?

Thanks again for the great tool.

Looking forward.

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