Skip to content

Idea: CPM.cmake-based dependency management #1

@TheLartians

Description

@TheLartians

Hey @Neumann-A, great work on this project! I believe that simple json-based project manifests would be a huge improvement to the CMake ecosystem.

It may be interesting to see if this project can be combined with CPM.cmake for a simple CMake dependency management solution. Dependencies could be defined in an object using a { "<target-name>": <source-string> } syntax, where <source-string> is a string using CPM's single-argument syntax or is an object containing CPM.cmake parameters. This would allow for a simple and reproducible dependency management solution for many git-based dependencies without the need for any external tools or system-dependent package managers.

Example

{
    "homepage" : "<someurl>",
    "description" : "<somedescription>",
    "version" : "0.1.0",
    "languages" : ["CXX"],
    "dependencies" : {
        "Catch2": "gh:catchorg/Catch2@2.13.4",
        "linenoise": "gh:antirez/linenoise#1.0",
        "Boost::boost": "gh:Orphis/boost-cmake@1.67.0",
        "fmt": {
            "git_tag": "7.1.3",
            "github_repository": "fmtlib/fmt",
            "options": ["FMT_INSTALL YES"]
        }
    }
}

Implementation

Without having looked at the details of CMakeJSON, I believe the implementation should be very simple. After CPM.cmake has been included, we would only need to call CPMAddPackage(<source-string>) and afterwards target_link_libraries(target <target-name>) for each dependency - in the single argument case. In the object case, we would need to transform the parameters into a single string that can be forwarded to CPMAddPacakge.

While I don't have much time to work on it atm, I'd be happy to support where I can, if you are interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions