[CMake] Double quotes being removed Windows removing compiler flags

François Best francois.best at eiosis.com
Thu Jul 12 02:20:50 EDT 2012


I was able to fix my problem by adding the replacement of "\\\"" (escaped
quote) before the actual replacement of the non-escaped quote in the
generator.

Here is the patch:

diff --git a/Source/cmVisualStudioGeneratorOptions.cxx
b/Source/cmVisualStudioGeneratorOptions.cxx
index 9369af6..5371d0f 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -16,6 +16,7 @@ inline std::string
cmVisualStudioGeneratorOptionsEscapeForXML(const char* s)
 {
   std::string ret = s;
   cmSystemTools::ReplaceString(ret, "&", "&");
+  cmSystemTools::ReplaceString(ret, "\\\"", """);
   cmSystemTools::ReplaceString(ret, "\"", """);
   cmSystemTools::ReplaceString(ret, "<", "&lt;");
   cmSystemTools::ReplaceString(ret, ">", "&gt;");

Best,

François Best
Hardware & Software Engineer

Eiosis - http://www.eiosis.com/



2012/7/12 François Best <francois.best at eiosis.com>

> Okay, none of these solutions give the expected result..
>
> What is strange is that the ampersand character is correctly expanded into
> the &amp; tag, and in  cmVisualStudioGeneratorOptions.cxx I can see that
> replacement, as well as the quote being transformed (theoretically) into
> the &quot; tag..
>
> Another thing to note is that the list of options in the generated project
> looks like a CMake list, semicolon separated, with every element
> encapsulated into escaped quotes. While this is a safe way to handle spaces
> for every element, it prevents from using quotes in the options
> themselves..
> Basically, the tool I'm using is expecting quotes around the value of the
> option only.
>
> The only other way I see to do this is to process the generated solution
> file post-generation. As I didn't see such a thing in CMake, maybe a script
> launching both the CMake generation and the replacement of (let's say)
> @quote@ tags could do the trick, although this needs to be done in every
> project in the tree, damn..
>
> I'll run a debug build of CMake tomorrow to follow the generation, to have
> a better understanding of the problem.
>
> Best,
>
> François Best
> Hardware & Software Engineer
>
> Eiosis - http://www.eiosis.com/
>
>
>
> 2012/7/11 François Best <francois.best at eiosis.com>
>
>> Hi David,
>>
>> Unfortunately, even that syntax still removes the quotes in the generated
>> project, but thanks for the heads up!
>>
>> @Andreas: I'm going to check your solution, thanks!
>>
>> Best,
>>
>> François Best
>> Hardware & Software Engineer
>>
>>  Eiosis - http://www.eiosis.com/
>>
>>
>>
>> 2012/7/11 David Cole <david.cole at kitware.com>
>>
>>>  The syntax in your original post is incorrect.
>>>
>>>
>>>   set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} /Test1:"Test1")
>>>
>>> should be:
>>>
>>>
>>>   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Test1:\"Test1\"")
>>>
>>> i.e., to CMake, the set call should look like two arguments here: the
>>> variable name and a double quoted string with any nested quotes escaped
>>> with a \ character
>>>
>>> The C and CXX flags variables are all single string values with multiple
>>> flags separated by spaces. With your original syntax, all the spaces get
>>> turned into semi-colons because there are multiple (more than just 2)
>>> arguments to the set command.
>>>
>>>
>>> HTH,
>>> David
>>>
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120712/ab8c26ca/attachment.htm>


More information about the CMake mailing list