Skip to content

Commit bb7a0bc

Browse files
committed
signal failure to write a vcpkg.json file
1 parent dd0003f commit bb7a0bc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/gen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,15 @@ int generate_cmake(const char *path, bool root) {
533533
j["$schema"] = "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json";
534534
j["name"] = cmake.project_name;
535535
if (cmake.project_version.empty())
536-
throw std::runtime_error("vcpkg manifest mode requires that the project have a version string");
536+
throw std::runtime_error("vcpkg manifest mode requires that the project have a version string!");
537537
j["version"] = cmake.project_version;
538538
j["dependencies"] = cmake.vcpkg.packages;
539539
std::ofstream ofs("vcpkg.json");
540+
if (!ofs) {
541+
throw std::runtime_error("Failed to create a vcpkg.json manifest file!");
542+
}
540543
ofs << std::setw(4) << j << std::endl;
544+
ofs.close();
541545
}
542546

543547
if (!cmake.packages.empty()) {

0 commit comments

Comments
 (0)