diff --git a/CMakeLists.txt b/CMakeLists.txt index d8b705a..7fbd3e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,5 @@ +# This file was generated automatically by cmkr. + cmake_minimum_required(VERSION 3.14) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/src/cmake.cpp b/src/cmake.cpp index a4c88ae..840bac8 100644 --- a/src/cmake.cpp +++ b/src/cmake.cpp @@ -11,7 +11,7 @@ namespace cmkr::cmake { namespace detail { std::vector to_string_vec( const std::vector> - vals) { + &vals) { std::vector 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(); diff --git a/src/gen.cpp b/src/gen.cpp index 54128e6..73c136f 100644 --- a/src/gen.cpp +++ b/src/gen.cpp @@ -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";