From cf980261078d1f6a5905885c9db8a708b92ff9fa Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 3 Nov 2021 17:30:13 +0100 Subject: [PATCH] Added seperate method for CMake check in toolchain added method for cmake check fixed bug more testing testing the test testing the tests that havent been tested plz temp print for bug fixing removed printouts. changed default CMake path changed default CMake path again. Changed default CMake path once again and another time... attempted fix for find cmake method fix so that cmake on path can be found --- include/SMCE/Toolchain.hpp | 1 + src/SMCE/Toolchain.cpp | 39 ++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/include/SMCE/Toolchain.hpp b/include/SMCE/Toolchain.hpp index 3f2aac89..c6c327d5 100644 --- a/include/SMCE/Toolchain.hpp +++ b/include/SMCE/Toolchain.hpp @@ -90,6 +90,7 @@ class SMCE_API Toolchain { **/ [[nodiscard]] std::error_code check_suitable_environment() noexcept; + [[nodiscard]] std::error_code check_cmake_availability() noexcept; /** * Compile a sketch **/ diff --git a/src/SMCE/Toolchain.cpp b/src/SMCE/Toolchain.cpp index 03c92d02..dec93edf 100644 --- a/src/SMCE/Toolchain.cpp +++ b/src/SMCE/Toolchain.cpp @@ -257,16 +257,10 @@ std::error_code Toolchain::do_build(Sketch& sketch) noexcept { else if (ec) return ec; - if (m_cmake_path != "cmake") { - if (std::error_code ec; stdfs::is_empty(m_cmake_path, ec)) - return toolchain_error::cmake_not_found; - else if (ec) - return ec; - } else { - m_cmake_path = bp::search_path(m_cmake_path).string(); - if (m_cmake_path.empty()) - return toolchain_error::cmake_not_found; - } + std::error_code ec = check_cmake_availability(); + if(ec) + return ec; + bp::ipstream cmake_out; // clang-format off const int cmres = bp::system( @@ -290,6 +284,31 @@ std::error_code Toolchain::do_build(Sketch& sketch) noexcept { return {}; } +[[nodiscard]] std::error_code Toolchain::check_cmake_availability() noexcept { + if (m_cmake_path != "cmake") { + if (std::error_code ec; stdfs::is_empty(m_cmake_path, ec)) { + return toolchain_error::cmake_not_found; + } + else if (ec) { + return ec; + } + } else { + m_cmake_path = bp::search_path(m_cmake_path).string(); + if (m_cmake_path.empty()) { + if (std::error_code ec; stdfs::is_empty((m_res_dir / "RtResources/CMake/bin/cmake.exe").string(), ec)) { + return toolchain_error::cmake_not_found; + } + else if (ec) { + return ec; + } + else { + m_cmake_path = (m_res_dir / "RtResources/CMake/bin/cmake.exe").string(); + } + } + } + return {}; +} + std::error_code Toolchain::compile(Sketch& sketch) noexcept { sketch.m_built = false; std::error_code ec;