mirror of
https://github.com/build-cpp/cmkr
synced 2026-06-08 13:22:55 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 760b2a8511 | |||
| fb9af0213b | |||
| 264e4ace18 | |||
| b6ab584a1a |
+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 "archive_eaf03eb7" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
||||
set(CMKR_TAG "archive_264e4ace" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE)
|
||||
|
||||
# Set these from the command line to customize for development/debugging purposes
|
||||
set(CMKR_EXECUTABLE "" CACHE FILEPATH "cmkr executable")
|
||||
|
||||
+17
-7
@@ -412,6 +412,13 @@ struct Generator {
|
||||
}
|
||||
};
|
||||
|
||||
static bool vcpkg_valid_identifier(const std::string &name) {
|
||||
const std::regex reserved("prn|aux|nul|con|lpt[1-9]|com[1-9]|core|default");
|
||||
const std::regex ok("[a-z0-9]+(-[a-z0-9]+)*");
|
||||
std::cmatch m;
|
||||
return !std::regex_match(name.c_str(), m, reserved) && std::regex_match(name.c_str(), m, ok);
|
||||
}
|
||||
|
||||
static std::string vcpkg_escape_identifier(const std::string &name) {
|
||||
// Do a reasonable effort to escape the project name for use with vcpkg
|
||||
std::string escaped;
|
||||
@@ -427,14 +434,10 @@ static std::string vcpkg_escape_identifier(const std::string &name) {
|
||||
escaped += std::tolower(ch);
|
||||
}
|
||||
|
||||
const std::regex reserved("prn|aux|nul|con|lpt[1-9]|com[1-9]|core|default");
|
||||
const std::regex ok("[a-z0-9]+(-[a-z0-9]+)*");
|
||||
std::cmatch m;
|
||||
if (!std::regex_match(escaped.c_str(), m, reserved) && std::regex_match(escaped.c_str(), m, ok)) {
|
||||
return escaped;
|
||||
} else {
|
||||
if (!vcpkg_valid_identifier(escaped)) {
|
||||
throw std::runtime_error("The escaped project name '" + escaped + "' is not usable with [vcpkg]");
|
||||
}
|
||||
return escaped;
|
||||
}
|
||||
|
||||
int generate_cmake(const char *path, bool root) {
|
||||
@@ -565,6 +568,13 @@ int generate_cmake(const char *path, bool root) {
|
||||
url = "https://github.com/microsoft/vcpkg/archive/refs/tags/" + project.vcpkg.version + ".tar.gz";
|
||||
}
|
||||
|
||||
// Show a nicer error than vcpkg when specifying an invalid package name
|
||||
for (const auto &package : project.vcpkg.packages) {
|
||||
if (!vcpkg_valid_identifier(package)) {
|
||||
throw std::runtime_error("Invalid [vcpkg].packages name '" + package + "' (needs to be lowercase alphanumeric)");
|
||||
}
|
||||
}
|
||||
|
||||
// CMake to bootstrap vcpkg and download the packages
|
||||
// clang-format off
|
||||
cmd("if")("CMKR_ROOT_PROJECT", "AND", "NOT", "CMKR_DISABLE_VCPKG");
|
||||
@@ -906,7 +916,7 @@ int generate_cmake(const char *path, bool root) {
|
||||
fs::path subpath;
|
||||
for (const auto &p : sub) {
|
||||
subpath /= p;
|
||||
if (parser::is_root_path(subpath.string())) {
|
||||
if (parser::is_root_path((path / subpath).string())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user