Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/SMCE/Toolchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
**/
Expand Down
39 changes: 29 additions & 10 deletions src/SMCE/Toolchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
Expand Down