[CMake] Double quotes being removed Windows removing compiler flags
Andreas Mohr
andi at lisas.de
Wed Jul 11 12:35:22 EDT 2012
Hi,
On Wed, Jul 11, 2012 at 12:00:08PM -0400, cmake-request at cmake.org wrote:
> Date: Wed, 11 Jul 2012 17:09:01 +0200
> From: Fran?ois Best <francois.best at eiosis.com>
>
> What I'm looking for is a way to achieve the following:
>
> In the project file:
> AdditionalOptions="/foo:"bar""
>
> Interpreted in the command-line as
> /foo:"bar"
>
> We both tried every combination of escaping quotes, but without any success.
My vcproj2cmake scripts have the following semi-related
and possibly helpful explanations:
# WARNING NOTE: the previous implementation called set_target_properties()
# with a strung-together list of properties, as an optimization.
# However since certain input property string payload consisted of semicolons
# (e.g. in the case of """), this went completely haywire
# with contents partially split off at semicolon borders.
# IOW, definitely make sure to set each property precisely separately.
# Well, that's not sufficient! The remaining problem was that the property
# variables SHOULD NOT BE QUOTED, to enable passing of the content as a list,
# thereby implicitly properly passing the original ';' content right to
# the generated .vcproj, in fully correct form!
# Perhaps the previous set_target_properties() code was actually doable after all... (TODO test?)
if(_vs_scc_projectname)
set_property(TARGET ${_target} PROPERTY VS_SCC_PROJECTNAME ${_vs_scc_projectname})
if(_vs_scc_localpath)
#if("${_vs_scc_localpath}" STREQUAL ".")
# set(_vs_scc_localpath "SAK")
#endif("${_vs_scc_localpath}" STREQUAL ".")
set_property(TARGET ${_target} PROPERTY VS_SCC_LOCALPATH ${_vs_scc_localpath})
endif(_vs_scc_localpath)
if(_vs_scc_provider)
set_property(TARGET ${_target} PROPERTY VS_SCC_PROVIDER ${_vs_scc_provider})
endif(_vs_scc_provider)
if(_vs_scc_auxpath)
set_property(TARGET ${_target} PROPERTY VS_SCC_AUXPATH ${_vs_scc_auxpath})
endif(_vs_scc_auxpath)
endif(_vs_scc_projectname)
endfunction(v2c_target_set_properties_vs_scc _target _vs_scc_projectname _vs_scc_localpath _vs_scc_provider _vs_scc_auxpath)
While this may not be helpful enough (probably only applies
to strings containing ';' as implicitly used by CMake string variables) -
maybe it would be successful to add an explicit fully separate helper variable
for the quotes, to avoid any rogue de-escaping?
I.e. use something like:
set(escaped_quotes_helper "\"") # or perhaps need to use "\\"" or "\\\""?
set(quoted_string ${non_quote_string_part1}${escaped_quotes_helper}${non_quote_string_part2}${escaped_quotes_helper})
Well, this would end up as a list variable, thus perhaps use that instead:
set(quoted_string "${non_quote_string_part1}${escaped_quotes_helper}${non_quote_string_part2}${escaped_quotes_helper}")
Or another trick might be to mark all quote positions within the string
with a different marker char and then use some regex replace on that string
to replace those with quotes.
Perhaps the result string then ends up more precise (read: successful)
than the previous fruitless attempts.
HTH,
Andreas Mohr
More information about the CMake
mailing list