build-cpp / cmkr

Modern build system based on CMake and TOML.
https://cmkr.build
MIT License
431 stars 27 forks source link

Replace PMM with `vcpkg.json` generation + bootstrapping #23

Closed mrexodia closed 3 years ago

mrexodia commented 3 years ago

PMM is awfully complicated and does not work properly. Replace it with modern vcpkg.

[project]
name = "my_project"
version = "1.2"

[vcpkg]
version = "2021.05.12"
packages = ["fmt", "sqlite3"]

Should generate vcpkg.json (take care of the vcpkg identifiers not allowing capital letters or underscores):

{
  "name": "vcpkg_template",
  "version": "0.0.1",
  "dependencies": ["fmt", "sqlite3"]
}

And (right after the project):

include(FetchContent)

message(STATUS "Fetching vcpkg...")
FetchContent_Declare(
    vcpkg
    URL
        https://github.com/microsoft/vcpkg/archive/refs/tags/2021.05.12.tar.gz
)
FetchContent_MakeAvailable(vcpkg)

include(${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake)

See: https://github.com/build-cpp/vcpkg_template/tree/simplified-vscode. It also needs some kind of handling for subprojects (that scenario is not supported by vcpkg according to one of the authors) and it would be best if you get error messages that certain packages need to be specified in the root project for it to work.

MoAlyousef commented 3 years ago

Hi I've created a new branch called "manifest" with support for vcpkg manifest mode. I chose (& vendored) nlohmann/json for vcpkg.json generation. I think the next step is to also support versions and features for each dependency:

{
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
  "name": "my-application",
  "version": "0.15.2",
  "dependencies": [
    "boost-system",
    {
      "name": "cpprestsdk",
      "default-features": false
    },
    "libxml2",
    "yajl"
  ]
}
mrexodia commented 3 years ago

Awesome, I’ll take a look! Maybe open a PR so it’s easier to review?