From a32eb66df42a6acd070c0f2da2756a30434b34e0 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 19 Jan 2025 14:53:50 +0100 Subject: [PATCH] Make sure empty target properties are emitted correctly --- src/cmake_generator.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index 793f3a8..6949a66 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -289,6 +289,10 @@ struct RawArg { } std::string arg; + + bool empty() const { + return arg.empty(); + } }; // Credit: JustMagic @@ -406,7 +410,7 @@ struct Command { } bool print_arg(const RawArg &arg) { - if (arg.arg.empty()) { + if (arg.empty()) { return true; } @@ -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 &properties) { + tsl::ordered_map 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); }); }