VS10: Escape double quote chars in defines for rc files (#11695)
To get rc defines to work in the VS10 IDE requires \" when constructing PreprocessorDefinitions strings. This is different than defines for cl. Also, per-file rc defines were not being generated. Fix that, too.
This commit is contained in:
parent
0cde56dda4
commit
662756036e
|
@ -755,7 +755,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
||||||
}
|
}
|
||||||
fout << "\"\n";
|
fout << "\"\n";
|
||||||
targetOptions.OutputFlagMap(fout, "\t\t\t\t");
|
targetOptions.OutputFlagMap(fout, "\t\t\t\t");
|
||||||
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n");
|
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
|
||||||
fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
|
fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
|
||||||
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
|
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
|
||||||
if(targetBuilds)
|
if(targetBuilds)
|
||||||
|
@ -789,7 +789,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
||||||
}
|
}
|
||||||
// add the -D flags to the RC tool
|
// add the -D flags to the RC tool
|
||||||
fout << "\"";
|
fout << "\"";
|
||||||
targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "");
|
targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC");
|
||||||
fout << "/>\n";
|
fout << "/>\n";
|
||||||
tool = "VCMIDLTool";
|
tool = "VCMIDLTool";
|
||||||
if(this->FortranProject)
|
if(this->FortranProject)
|
||||||
|
@ -1462,6 +1462,7 @@ void cmLocalVisualStudio7Generator
|
||||||
else if(!fcinfo.FileConfigMap.empty())
|
else if(!fcinfo.FileConfigMap.empty())
|
||||||
{
|
{
|
||||||
const char* aCompilerTool = "VCCLCompilerTool";
|
const char* aCompilerTool = "VCCLCompilerTool";
|
||||||
|
const char* lang = "CXX";
|
||||||
if(this->FortranProject)
|
if(this->FortranProject)
|
||||||
{
|
{
|
||||||
aCompilerTool = "VFFortranCompilerTool";
|
aCompilerTool = "VFFortranCompilerTool";
|
||||||
|
@ -1479,6 +1480,7 @@ void cmLocalVisualStudio7Generator
|
||||||
if(ext == "rc")
|
if(ext == "rc")
|
||||||
{
|
{
|
||||||
aCompilerTool = "VCResourceCompilerTool";
|
aCompilerTool = "VCResourceCompilerTool";
|
||||||
|
lang = "RC";
|
||||||
if(this->FortranProject)
|
if(this->FortranProject)
|
||||||
{
|
{
|
||||||
aCompilerTool = "VFResourceCompilerTool";
|
aCompilerTool = "VFResourceCompilerTool";
|
||||||
|
@ -1520,7 +1522,7 @@ void cmLocalVisualStudio7Generator
|
||||||
fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n");
|
fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n");
|
||||||
fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
|
fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
|
||||||
fileOptions.OutputPreprocessorDefinitions(fout,
|
fileOptions.OutputPreprocessorDefinitions(fout,
|
||||||
"\t\t\t\t\t", "\n");
|
"\t\t\t\t\t", "\n", lang);
|
||||||
}
|
}
|
||||||
if(!fc.AdditionalDeps.empty())
|
if(!fc.AdditionalDeps.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -717,6 +717,10 @@ void cmVisualStudio10TargetGenerator::WriteCLSources()
|
||||||
// is ended on a new line
|
// is ended on a new line
|
||||||
this->WriteString("</ClCompile>\n", 2);
|
this->WriteString("</ClCompile>\n", 2);
|
||||||
}
|
}
|
||||||
|
else if(!header && rc && this->OutputSourceSpecificFlags(*source))
|
||||||
|
{
|
||||||
|
this->WriteString("</ResourceCompile>\n", 2);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*this->BuildFileStream ) << " />\n";
|
(*this->BuildFileStream ) << " />\n";
|
||||||
|
@ -853,8 +857,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||||
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
||||||
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
||||||
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream,
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream,
|
||||||
" ", "\n");
|
" ", "\n", lang);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hasFlags;
|
return hasFlags;
|
||||||
|
@ -1120,7 +1123,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||||
}
|
}
|
||||||
|
|
||||||
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
||||||
"\n");
|
"\n", "CXX");
|
||||||
this->WriteString("<AssemblerListingLocation>", 3);
|
this->WriteString("<AssemblerListingLocation>", 3);
|
||||||
*this->BuildFileStream << configName
|
*this->BuildFileStream << configName
|
||||||
<< "</AssemblerListingLocation>\n";
|
<< "</AssemblerListingLocation>\n";
|
||||||
|
@ -1155,7 +1158,7 @@ WriteRCOptions(std::string const& configName,
|
||||||
this->WriteString("<ResourceCompile>\n", 2);
|
this->WriteString("<ResourceCompile>\n", 2);
|
||||||
Options& clOptions = *(this->ClOptions[configName]);
|
Options& clOptions = *(this->ClOptions[configName]);
|
||||||
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
||||||
"\n");
|
"\n", "RC");
|
||||||
this->OutputIncludes(includes);
|
this->OutputIncludes(includes);
|
||||||
this->WriteString("</ResourceCompile>\n", 2);
|
this->WriteString("</ResourceCompile>\n", 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,8 @@ void
|
||||||
cmVisualStudioGeneratorOptions
|
cmVisualStudioGeneratorOptions
|
||||||
::OutputPreprocessorDefinitions(std::ostream& fout,
|
::OutputPreprocessorDefinitions(std::ostream& fout,
|
||||||
const char* prefix,
|
const char* prefix,
|
||||||
const char* suffix)
|
const char* suffix,
|
||||||
|
const char* lang)
|
||||||
{
|
{
|
||||||
if(this->Defines.empty())
|
if(this->Defines.empty())
|
||||||
{
|
{
|
||||||
|
@ -251,6 +252,11 @@ cmVisualStudioGeneratorOptions
|
||||||
if(this->Version == 10)
|
if(this->Version == 10)
|
||||||
{
|
{
|
||||||
define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str());
|
define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str());
|
||||||
|
|
||||||
|
if(0 == strcmp(lang, "RC"))
|
||||||
|
{
|
||||||
|
cmSystemTools::ReplaceString(define, "\"", "\\\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,7 +54,8 @@ public:
|
||||||
// Write options to output.
|
// Write options to output.
|
||||||
void OutputPreprocessorDefinitions(std::ostream& fout,
|
void OutputPreprocessorDefinitions(std::ostream& fout,
|
||||||
const char* prefix,
|
const char* prefix,
|
||||||
const char* suffix);
|
const char* suffix,
|
||||||
|
const char* lang);
|
||||||
void OutputFlagMap(std::ostream& fout, const char* indent);
|
void OutputFlagMap(std::ostream& fout, const char* indent);
|
||||||
void OutputAdditionalOptions(std::ostream& fout,
|
void OutputAdditionalOptions(std::ostream& fout,
|
||||||
const char* prefix,
|
const char* prefix,
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
cmake_minimum_required (VERSION 2.6)
|
cmake_minimum_required(VERSION 2.8.3.20110118)
|
||||||
project (VSResource)
|
project (VSResource)
|
||||||
add_definitions(/DCMAKE_RCDEFINE="test.txt")
|
|
||||||
string(REPLACE "/INCREMENTAL:YES" ""
|
string(REPLACE "/INCREMENTAL:YES" ""
|
||||||
CMAKE_EXE_LINKER_FLAGS_DEBUG
|
CMAKE_EXE_LINKER_FLAGS_DEBUG
|
||||||
"${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
"${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.txt
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/test with spaces.txt" COPYONLY)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
add_definitions(/DCMAKE_RCDEFINE="test with spaces.txt")
|
||||||
|
|
||||||
add_executable(VSResource main.cpp test.rc)
|
add_executable(VSResource main.cpp test.rc)
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#ifdef CMAKE_RCDEFINE
|
#ifdef CMAKE_RCDEFINE
|
||||||
hello TEXT DISCARDABLE CMAKE_RCDEFINE
|
hello TEXT DISCARDABLE CMAKE_RCDEFINE
|
||||||
|
|
||||||
|
STRINGTABLE
|
||||||
|
BEGIN
|
||||||
|
1 CMAKE_RCDEFINE
|
||||||
|
END
|
||||||
#else
|
#else
|
||||||
#error "resource compiler did not get defines from command line!"
|
#error "resource compiler did not get defines from command line!"
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue