mirror of
https://github.com/build-cpp/cmkr
synced 2026-06-08 13:22:55 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13a7a8788a | |||
| 45ca74099c | |||
| ae3d73896e | |||
| 57042565d1 | |||
| d02ee3ed24 | |||
| 4a15d2ba55 |
Generated
+1
-1
@@ -22,7 +22,7 @@ project(cmkr
|
||||
LANGUAGES
|
||||
CXX
|
||||
VERSION
|
||||
0.2.35
|
||||
0.2.36
|
||||
DESCRIPTION
|
||||
"CMakeLists generator from TOML"
|
||||
)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ cmkr-include = false
|
||||
|
||||
[project]
|
||||
name = "cmkr"
|
||||
version = "0.2.35"
|
||||
version = "0.2.36"
|
||||
description = "CMakeLists generator from TOML"
|
||||
languages = ["CXX"]
|
||||
include-after = [
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ include_guard()
|
||||
|
||||
# Change these defaults to point to your infrastructure if desired
|
||||
set(CMKR_REPO "https://github.com/build-cpp/cmkr" CACHE STRING "cmkr git repository" FORCE)
|
||||
set(CMKR_TAG "v0.2.35" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
||||
set(CMKR_TAG "v0.2.36" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
||||
set(CMKR_COMMIT_HASH "" CACHE STRING "cmkr git commit hash (optional)" FORCE)
|
||||
|
||||
# To bootstrap/generate a cmkr project: cmake -P cmkr.cmake
|
||||
|
||||
@@ -163,12 +163,15 @@ Variables emit a [`set`](https://cmake.org/cmake/help/latest/command/set.html) a
|
||||
version = "2024.03.25"
|
||||
url = "https://github.com/microsoft/vcpkg/archive/refs/tags/2024.03.25.tar.gz"
|
||||
packages = ["fmt", "zlib"]
|
||||
overlay-ports = ["my-ports"]
|
||||
```
|
||||
|
||||
The vcpkg `version` will automatically generate the `url` from the [official repository](https://github.com/microsoft/vcpkg/releases). For a custom registry you can specify your own `url` (and omit the `version`). You can browse available packages on [vcpkg.io](https://vcpkg.io/en/packages.html).
|
||||
|
||||
To specify package features you can use the following syntax: `imgui[docking-experimental,freetype,sdl2-binding,opengl3-binding]`.
|
||||
|
||||
The `overlay-ports` feature allows you to embed vcpkg ports inside your project, without having to fork the main vcpkg registry or creating a custom registry. You can find more information in the relevant [documentation](https://learn.microsoft.com/en-us/vcpkg/concepts/overlay-ports).
|
||||
|
||||
## Packages
|
||||
|
||||
```toml
|
||||
|
||||
@@ -48,6 +48,7 @@ struct Vcpkg {
|
||||
};
|
||||
|
||||
std::vector<Package> packages;
|
||||
std::vector<std::string> overlay_ports;
|
||||
|
||||
bool enabled() const {
|
||||
return !packages.empty();
|
||||
|
||||
+33
-5
@@ -761,7 +761,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
||||
cmd("set_property")("GLOBAL", "PROPERTY", "USE_FOLDERS", "ON").endl();
|
||||
|
||||
comment("Create a configure-time dependency on cmake.toml to improve IDE support");
|
||||
cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY");
|
||||
if (project.cmake_minimum_version(3, 0)) {
|
||||
cmd("set_property")("DIRECTORY", "APPEND", "PROPERTY", "CMAKE_CONFIGURE_DEPENDS", "cmake.toml");
|
||||
} else {
|
||||
cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY");
|
||||
}
|
||||
|
||||
if (project.project_msvc_runtime != parser::msvc_last) {
|
||||
cmd("if")("NOT", "DEFINED", "CMAKE_MSVC_RUNTIME_LIBRARY");
|
||||
@@ -785,12 +789,14 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
||||
create_file(cmkr_include, resources::cmkr);
|
||||
}
|
||||
} else {
|
||||
// clang-format off
|
||||
comment("Create a configure-time dependency on cmake.toml to improve IDE support");
|
||||
cmd("if")("CMKR_ROOT_PROJECT");
|
||||
if (project.cmake_minimum_version(3, 0)) {
|
||||
cmd("set_property")("DIRECTORY", "APPEND", "PROPERTY", "CMAKE_CONFIGURE_DEPENDS", "cmake.toml");
|
||||
} else {
|
||||
cmd("configure_file")("cmake.toml", "cmake.toml", "COPYONLY");
|
||||
}
|
||||
cmd("endif")().endl();
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
// TODO: remove support and replace with global compile-features
|
||||
@@ -930,7 +936,7 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
||||
ofs << R"({
|
||||
"$cmkr": "This file is automatically generated from cmake.toml - DO NOT EDIT",
|
||||
"$cmkr-url": "https://github.com/build-cpp/cmkr",
|
||||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
||||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
|
||||
"dependencies": [
|
||||
)";
|
||||
|
||||
@@ -987,7 +993,29 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
|
||||
ofs << " ],\n";
|
||||
ofs << " \"description\": \"" << escape(project.project_description) << "\",\n";
|
||||
ofs << " \"name\": \"" << escape(vcpkg_escape_identifier(project.project_name)) << "\",\n";
|
||||
ofs << R"( "version-string": "")" << '\n';
|
||||
ofs << " \"version-string\": \"none\"";
|
||||
const auto &overlay_ports = project.vcpkg.overlay_ports;
|
||||
if (!overlay_ports.empty()) {
|
||||
ofs << ",\n";
|
||||
// Reference: https://learn.microsoft.com/en-us/vcpkg/reference/vcpkg-json#vcpkg-configuration
|
||||
ofs << " \"vcpkg-configuration\": {\n";
|
||||
ofs << " \"overlay-ports\": [\n";
|
||||
for (size_t i = 0; i < overlay_ports.size(); i++) {
|
||||
const auto &directory = overlay_ports[i];
|
||||
if (!fs::is_directory(directory)) {
|
||||
throw std::runtime_error("[vcpkg].overlay-ports is not a directory: " + directory);
|
||||
}
|
||||
ofs << " \"" << escape(directory) << "\"";
|
||||
if (i > 0) {
|
||||
ofs << ",";
|
||||
}
|
||||
ofs << "\n";
|
||||
}
|
||||
ofs << " ]\n";
|
||||
ofs << " }\n";
|
||||
} else {
|
||||
ofs << "\n";
|
||||
}
|
||||
ofs << "}\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -550,6 +550,14 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
|
||||
algo.push_back(ch);
|
||||
}
|
||||
key = "URL_HASH";
|
||||
if (value.empty()) {
|
||||
throw_key_error("Empty hash value", argItr.first, argItr.second);
|
||||
}
|
||||
for (char c : value) {
|
||||
if (!std::isxdigit(c)) {
|
||||
throw_key_error("Hash value must be a hex string", argItr.first, argItr.second);
|
||||
}
|
||||
}
|
||||
value = algo + "=" + value;
|
||||
} else if (key == "hash") {
|
||||
key = "URL_HASH";
|
||||
@@ -846,6 +854,8 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
|
||||
}
|
||||
vcpkg.packages.emplace_back(std::move(package));
|
||||
}
|
||||
|
||||
v.optional("overlay-ports", vcpkg.overlay_ports);
|
||||
}
|
||||
|
||||
checker.check(conditions, true);
|
||||
|
||||
Reference in New Issue
Block a user