Skip to content

Commit ea2ff31

Browse files
authored
Merge pull request #173 from build-cpp/fix-empty-properties
Make sure empty target properties are emitted correctly
2 parents 9b85833 + a32eb66 commit ea2ff31

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cmake_generator.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ struct RawArg {
289289
}
290290

291291
std::string arg;
292+
293+
bool empty() const {
294+
return arg.empty();
295+
}
292296
};
293297

294298
// Credit: JustMagic
@@ -406,7 +410,7 @@ struct Command {
406410
}
407411

408412
bool print_arg(const RawArg &arg) {
409-
if (arg.arg.empty()) {
413+
if (arg.empty()) {
410414
return true;
411415
}
412416

@@ -1461,14 +1465,17 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
14611465
}
14621466

14631467
gen.handle_condition(props, [&](const std::string &, const tsl::ordered_map<std::string, std::string> &properties) {
1468+
tsl::ordered_map<std::string, RawArg> raw_properties;
14641469
for (const auto &propItr : properties) {
14651470
if (propItr.first == "MSVC_RUNTIME_LIBRARY") {
14661471
if (project_root->project_msvc_runtime == parser::msvc_last) {
14671472
throw_target_error("You cannot set msvc-runtime without setting the root [project].msvc-runtime");
14681473
}
14691474
}
1475+
// NOTE: We need to make sure that empty strings do not get omitted
1476+
raw_properties.emplace(propItr.first, Command::quote(propItr.second));
14701477
}
1471-
cmd("set_target_properties")(target.name, "PROPERTIES", properties);
1478+
cmd("set_target_properties")(target.name, "PROPERTIES", raw_properties);
14721479
});
14731480
}
14741481

0 commit comments

Comments
 (0)