Skip to content

Commit

Permalink
Merge pull request #173 from build-cpp/fix-empty-properties
Browse files Browse the repository at this point in the history
Make sure empty target properties are emitted correctly
  • Loading branch information
mrexodia authored Jan 19, 2025
2 parents 9b85833 + a32eb66 commit ea2ff31
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cmake_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ struct RawArg {
}

std::string arg;

bool empty() const {
return arg.empty();
}
};

// Credit: JustMagic
Expand Down Expand Up @@ -406,7 +410,7 @@ struct Command {
}

bool print_arg(const RawArg &arg) {
if (arg.arg.empty()) {
if (arg.empty()) {
return true;
}

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

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

Expand Down

0 comments on commit ea2ff31

Please sign in to comment.