throw when no cmake.toml is found

self-hosting
MoAlyousef 4 years ago
parent b64d5a370d
commit 7ec2279a77

@ -1,6 +1,7 @@
#include "cmake.hpp"
#include <filesystem>
#include <stdexcept>
#include <toml.hpp>
namespace fs = std::filesystem;
@ -19,7 +20,9 @@ std::vector<std::string> to_string_vec(
} // namespace detail
CMake::CMake(const std::string &path, bool build) {
if (fs::exists(fs::path(path) / "cmake.toml")) {
if (!fs::exists(fs::path(path) / "cmake.toml")) {
throw std::runtime_error("No cmake.toml was found!");
}
if (build) {
const auto toml = toml::parse("cmake.toml");
if (toml.contains("cmake")) {
@ -92,8 +95,7 @@ CMake::CMake(const std::string &path, bool build) {
}
if (bin.contains("link-libs")) {
b.link_libs =
detail::to_string_vec(toml::find(bin, "link-libs").as_array());
b.link_libs = detail::to_string_vec(toml::find(bin, "link-libs").as_array());
}
if (bin.contains("features")) {
@ -107,6 +109,5 @@ CMake::CMake(const std::string &path, bool build) {
}
}
}
}
}
} // namespace cmkr::cmake

Loading…
Cancel
Save