VS10: Load projects with obj "source" files (#11147)
WriteCLSources should skip source files with "obj" extensions since WriteObjSources has already written them into the vcxproj file. Likewise, WriteGroupSources should skip source files with "obj" extensions to avoid receiving "item ... already exists under the filter" project-load-time error messages from Visual Studio.
This commit is contained in:
parent
00a0929c04
commit
0cde56dda4
|
@ -598,6 +598,10 @@ WriteGroupSources(const char* name,
|
||||||
s != sources.end(); ++s)
|
s != sources.end(); ++s)
|
||||||
{
|
{
|
||||||
cmSourceFile* sf = *s;
|
cmSourceFile* sf = *s;
|
||||||
|
if(sf->GetExtension() == "obj")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
std::string const& source = sf->GetFullPath();
|
std::string const& source = sf->GetFullPath();
|
||||||
cmSourceGroup& sourceGroup =
|
cmSourceGroup& sourceGroup =
|
||||||
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
|
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
|
||||||
|
@ -666,55 +670,56 @@ void cmVisualStudio10TargetGenerator::WriteCLSources()
|
||||||
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
|
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
|
||||||
source != sources.end(); ++source)
|
source != sources.end(); ++source)
|
||||||
{
|
{
|
||||||
// if it is not a custom command then add it as a c/c++ file,
|
std::string ext = (*source)->GetExtension();
|
||||||
// TODO: need to check for idl or rc
|
if((*source)->GetCustomCommand() || ext == "obj")
|
||||||
if(!(*source)->GetCustomCommand())
|
|
||||||
{
|
{
|
||||||
bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
|
continue;
|
||||||
|| this->GlobalGenerator->IgnoreFile
|
}
|
||||||
((*source)->GetExtension().c_str());
|
// If it is not a custom command and it is not a pre-built obj file,
|
||||||
const char* lang = (*source)->GetLanguage();
|
// then add it as a source (c/c++/header/rc/idl) file
|
||||||
bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0);
|
bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
|
||||||
bool rc = lang && (strcmp(lang, "RC") == 0);
|
|| this->GlobalGenerator->IgnoreFile(ext.c_str());
|
||||||
bool idl = (*source)->GetExtension() == "idl";
|
const char* lang = (*source)->GetLanguage();
|
||||||
std::string sourceFile = (*source)->GetFullPath();
|
bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0);
|
||||||
sourceFile = cmSystemTools::RelativePath(
|
bool rc = lang && (strcmp(lang, "RC") == 0);
|
||||||
this->Makefile->GetCurrentOutputDirectory(),
|
bool idl = ext == "idl";
|
||||||
sourceFile.c_str());
|
std::string sourceFile = (*source)->GetFullPath();
|
||||||
this->ConvertToWindowsSlash(sourceFile);
|
sourceFile = cmSystemTools::RelativePath(
|
||||||
// output the source file
|
this->Makefile->GetCurrentOutputDirectory(),
|
||||||
if(header)
|
sourceFile.c_str());
|
||||||
{
|
this->ConvertToWindowsSlash(sourceFile);
|
||||||
this->WriteString("<ClInclude Include=\"", 2);
|
// output the source file
|
||||||
}
|
if(header)
|
||||||
else if(cl)
|
{
|
||||||
{
|
this->WriteString("<ClInclude Include=\"", 2);
|
||||||
this->WriteString("<ClCompile Include=\"", 2);
|
}
|
||||||
}
|
else if(cl)
|
||||||
else if(rc)
|
{
|
||||||
{
|
this->WriteString("<ClCompile Include=\"", 2);
|
||||||
this->WriteString("<ResourceCompile Include=\"", 2);
|
}
|
||||||
}
|
else if(rc)
|
||||||
else if(idl)
|
{
|
||||||
{
|
this->WriteString("<ResourceCompile Include=\"", 2);
|
||||||
this->WriteString("<Midl Include=\"", 2);
|
}
|
||||||
}
|
else if(idl)
|
||||||
else
|
{
|
||||||
{
|
this->WriteString("<Midl Include=\"", 2);
|
||||||
this->WriteString("<None Include=\"", 2);
|
}
|
||||||
}
|
else
|
||||||
(*this->BuildFileStream ) << sourceFile << "\"";
|
{
|
||||||
// ouput any flags specific to this source file
|
this->WriteString("<None Include=\"", 2);
|
||||||
if(!header && cl && this->OutputSourceSpecificFlags(*source))
|
}
|
||||||
{
|
(*this->BuildFileStream ) << sourceFile << "\"";
|
||||||
// if the source file has specific flags the tag
|
// ouput any flags specific to this source file
|
||||||
// is ended on a new line
|
if(!header && cl && this->OutputSourceSpecificFlags(*source))
|
||||||
this->WriteString("</ClCompile>\n", 2);
|
{
|
||||||
}
|
// if the source file has specific flags the tag
|
||||||
else
|
// is ended on a new line
|
||||||
{
|
this->WriteString("</ClCompile>\n", 2);
|
||||||
(*this->BuildFileStream ) << " />\n";
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
(*this->BuildFileStream ) << " />\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->WriteString("</ItemGroup>\n", 1);
|
this->WriteString("</ItemGroup>\n", 1);
|
||||||
|
|
Loading…
Reference in New Issue