Add comment for files generated by cmkr

self-hosting
MoAlyousef 4 years ago
parent c306fc01d0
commit 95b0ee8d40

@ -1,3 +1,5 @@
# This file was generated automatically by cmkr.
cmake_minimum_required(VERSION 3.14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

@ -11,7 +11,7 @@ namespace cmkr::cmake {
namespace detail {
std::vector<std::string> to_string_vec(
const std::vector<toml::basic_value<toml::discard_comments, std::unordered_map, std::vector>>
vals) {
&vals) {
std::vector<std::string> temp;
for (const auto &val : vals)
temp.push_back(val.as_string());
@ -23,8 +23,8 @@ CMake::CMake(const std::string &path, bool build) {
if (!fs::exists(fs::path(path) / "cmake.toml")) {
throw std::runtime_error("No cmake.toml was found!");
}
const auto toml = toml::parse(fs::path(path) / "cmake.toml");
if (build) {
const auto toml = toml::parse("cmake.toml");
if (toml.contains("cmake")) {
const auto &cmake = toml::find(toml, "cmake");
@ -41,7 +41,6 @@ CMake::CMake(const std::string &path, bool build) {
}
}
} else {
const auto toml = toml::parse((fs::path(path) / "cmake.toml").string());
if (toml.contains("cmake")) {
const auto &cmake = toml::find(toml, "cmake");
cmake_version = toml::find(cmake, "minimum").as_string();

@ -22,7 +22,7 @@ inline std::string to_upper(const std::string &str) {
std::string temp;
temp.reserve(str.size());
for (auto c : str) {
temp.push_back(toupper(c));
temp.push_back(::toupper(c));
}
return temp;
}
@ -76,7 +76,8 @@ int generate_cmake(const char *path) {
if (fs::exists(fs::path(path) / "cmake.toml")) {
cmake::CMake cmake(path, false);
std::stringstream ss;
ss << "# This file was generated automatically by cmkr.\n\n";
if (!cmake.cmake_version.empty()) {
ss << "cmake_minimum_required(VERSION " << cmake.cmake_version << ")\n\n";

Loading…
Cancel
Save