Skip to content

Commit c7925e7

Browse files
authored
Merge pull request #52 from build-cpp/fix-options
Do not omit non-optional documentation in option()
2 parents 16b2cbb + c778a5f commit c7925e7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cmake_generator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ struct Command {
162162
}
163163

164164
static std::string quote(const std::string &str) {
165+
// Quote an empty string
166+
if (str.empty()) {
167+
return "\"\"";
168+
}
165169
// Don't quote arguments that don't need quoting
166170
if (str.find(' ') == std::string::npos && str.find('\"') == std::string::npos && str.find('/') == std::string::npos &&
167171
str.find(';') == std::string::npos) {
@@ -562,7 +566,7 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
562566
if (!project.options.empty()) {
563567
comment("Options");
564568
for (const auto &opt : project.options) {
565-
cmd("option")(opt.name, opt.comment, opt.val ? "ON" : "OFF");
569+
cmd("option")(opt.name, RawArg(Command::quote(opt.comment)), opt.val ? "ON" : "OFF");
566570
}
567571
endl();
568572
}

0 commit comments

Comments
 (0)