From c778a5fe2b8af5050e3e0a9d805c952e25b28181 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 11 Feb 2022 02:42:20 +0100 Subject: [PATCH] Do not omit non-optional documentation in option() --- src/cmake_generator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index 2a86a06..ba253db 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -162,6 +162,10 @@ struct Command { } static std::string quote(const std::string &str) { + // Quote an empty string + if (str.empty()) { + return "\"\""; + } // Don't quote arguments that don't need quoting if (str.find(' ') == std::string::npos && str.find('\"') == std::string::npos && str.find('/') == std::string::npos && str.find(';') == std::string::npos) { @@ -562,7 +566,7 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { if (!project.options.empty()) { comment("Options"); for (const auto &opt : project.options) { - cmd("option")(opt.name, opt.comment, opt.val ? "ON" : "OFF"); + cmd("option")(opt.name, RawArg(Command::quote(opt.comment)), opt.val ? "ON" : "OFF"); } endl(); }