BUG: Fixed cmLocalVisualStudio7Generator to deal with quotes in macro definitions properly. This addresses bug#4983.

This commit is contained in:
Brad King 2007-05-09 10:18:31 -04:00
parent e701ef77d8
commit adcd87c976
7 changed files with 53 additions and 12 deletions

View File

@ -502,9 +502,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
// Add a definition for the configuration name. // Add a definition for the configuration name.
std::string configDefine = "CMAKE_INTDIR=\\\""; std::string configDefine = "CMAKE_INTDIR=\"";
configDefine += configName; configDefine += configName;
configDefine += "\\\""; configDefine += "\"";
targetOptions.AddDefine(configDefine); targetOptions.AddDefine(configDefine);
// Add the export symbol definition for shared library objects. // Add the export symbol definition for shared library objects.
@ -1836,14 +1836,13 @@ cmLocalVisualStudio7GeneratorOptions
for(std::vector<cmStdString>::const_iterator di = this->Defines.begin(); for(std::vector<cmStdString>::const_iterator di = this->Defines.begin();
di != this->Defines.end(); ++di) di != this->Defines.end(); ++di)
{ {
// Escape this flag for the IDE.
std::string define =
cmLocalVisualStudio7GeneratorEscapeForXML(di->c_str());
// Old comment:
// Double-quotes in the value of the definition must be escaped // Double-quotes in the value of the definition must be escaped
// with a backslash. The entire definition should be quoted in // with a backslash.
// the generated xml attribute to avoid confusing the VS parser. std::string define = di->c_str();
cmSystemTools::ReplaceString(define, "\"", "\\\"");
// Escape this flag for the IDE.
define = cmLocalVisualStudio7GeneratorEscapeForXML(define.c_str());
// Write this flag. Quote it if the definition is not // Write this flag. Quote it if the definition is not
// alphanumeric. // alphanumeric.

View File

@ -87,7 +87,8 @@ ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD
"${Complex_BINARY_DIR}/Executable/postbuild2.txt") "${Complex_BINARY_DIR}/Executable/postbuild2.txt")
SET_SOURCE_FILES_PROPERTIES(complex SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" COMPILE_FLAGS
"-DFILE_HAS_EXTRA_COMPILE_FLAGS -DFILE_DEFINE_STRING=\\\"hello\\\""
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
) )
SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG") SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")

View File

@ -1139,6 +1139,19 @@ int main()
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
#endif #endif
#ifndef FILE_DEFINE_STRING
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag");
#else
if(strcmp(FILE_DEFINE_STRING, "hello") != 0)
{
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly");
}
else
{
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag");
}
#endif
#ifndef FILE_HAS_ABSTRACT #ifndef FILE_HAS_ABSTRACT
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag");
#else #else

View File

@ -87,7 +87,8 @@ ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD
"${Complex_BINARY_DIR}/Executable/postbuild2.txt") "${Complex_BINARY_DIR}/Executable/postbuild2.txt")
SET_SOURCE_FILES_PROPERTIES(complex SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" COMPILE_FLAGS
"-DFILE_HAS_EXTRA_COMPILE_FLAGS -DFILE_DEFINE_STRING=\\\"hello\\\""
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
) )
SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG") SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")

View File

@ -1139,6 +1139,19 @@ int main()
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
#endif #endif
#ifndef FILE_DEFINE_STRING
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag");
#else
if(strcmp(FILE_DEFINE_STRING, "hello") != 0)
{
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly");
}
else
{
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag");
}
#endif
#ifndef FILE_HAS_ABSTRACT #ifndef FILE_HAS_ABSTRACT
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag");
#else #else

View File

@ -87,7 +87,8 @@ ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD
"${Complex_BINARY_DIR}/Executable/postbuild2.txt") "${Complex_BINARY_DIR}/Executable/postbuild2.txt")
SET_SOURCE_FILES_PROPERTIES(complex SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" COMPILE_FLAGS
"-DFILE_HAS_EXTRA_COMPILE_FLAGS -DFILE_DEFINE_STRING=\\\"hello\\\""
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
) )
SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG") SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")

View File

@ -1139,6 +1139,19 @@ int main()
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
#endif #endif
#ifndef FILE_DEFINE_STRING
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag");
#else
if(strcmp(FILE_DEFINE_STRING, "hello") != 0)
{
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly");
}
else
{
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag");
}
#endif
#ifndef FILE_HAS_ABSTRACT #ifndef FILE_HAS_ABSTRACT
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag");
#else #else