|
|
@ -121,6 +121,15 @@ struct CommandEndl {
|
|
|
|
void endl() { ss << '\n'; }
|
|
|
|
void endl() { ss << '\n'; }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
|
|
|
struct NamedArg {
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
T value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NamedArg() = default;
|
|
|
|
|
|
|
|
NamedArg(std::string name, T value) : name(std::move(name)), value(std::move(value)) {}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Credit: JustMagic
|
|
|
|
// Credit: JustMagic
|
|
|
|
struct Command {
|
|
|
|
struct Command {
|
|
|
|
std::stringstream &ss;
|
|
|
|
std::stringstream &ss;
|
|
|
@ -158,11 +167,12 @@ struct Command {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *indent(int n) {
|
|
|
|
std::string indent(int n) {
|
|
|
|
|
|
|
|
std::string result;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
ss << '\t';
|
|
|
|
result += '\t';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
template <class T>
|
|
|
@ -205,6 +215,32 @@ struct Command {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <class K>
|
|
|
|
|
|
|
|
bool print_arg(const std::pair<K, std::vector<std::string>> &kv) {
|
|
|
|
|
|
|
|
if (kv.second.empty()) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ss << '\n';
|
|
|
|
|
|
|
|
ss << indent(depth + 1) << kv.first << '\n';
|
|
|
|
|
|
|
|
for (const auto &s : kv.second) {
|
|
|
|
|
|
|
|
ss << indent(depth + 2) << quote(s) << '\n';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <class K, class V>
|
|
|
|
|
|
|
|
bool print_arg(const std::pair<K, V> &kv) {
|
|
|
|
|
|
|
|
if (kv.second.empty()) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ss << indent(depth + 1) << kv.first << ' ' << quote(kv.second) << '\n';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
template <class T>
|
|
|
|
bool print_arg(const T &value) {
|
|
|
|
bool print_arg(const T &value) {
|
|
|
|
if (first_arg) {
|
|
|
|
if (first_arg) {
|
|
|
@ -320,11 +356,11 @@ int generate_cmake(const char *path, bool root) {
|
|
|
|
ss << "\")\n\n";
|
|
|
|
ss << "\")\n\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!cmake.project_name.empty() && !cmake.project_version.empty()) {
|
|
|
|
if (!cmake.project_name.empty()) {
|
|
|
|
auto name = cmake.project_name;
|
|
|
|
auto languages = std::make_pair("LANGUAGES", cmake.project_languages);
|
|
|
|
auto version = cmake.project_version;
|
|
|
|
auto version = std::make_pair("VERSION", cmake.project_version);
|
|
|
|
cmd("set")(name + "_PROJECT_VERSION", version);
|
|
|
|
auto description = std::make_pair("DESCRIPTION", cmake.project_description);
|
|
|
|
cmd("project")(name, "VERSION", "${" + name + "_PROJECT_VERSION}").endl();
|
|
|
|
cmd("project")(cmake.project_name, languages, version, description).endl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!cmake.cmake_after.empty()) {
|
|
|
|
if (!cmake.cmake_after.empty()) {
|
|
|
|