Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure empty target properties are emitted correctly #173

Merged
merged 1 commit into from
Jan 19, 2025
Merged
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
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
Loading