Merge topic 'fix_vs10_object_files'

9a6ff95 Fix for bug where VS2010 did not use .obj files as part of the build.
This commit is contained in:
Brad King 2011-04-05 14:28:55 -04:00 committed by CMake Topic Stage
commit e560bf4ba3
2 changed files with 27 additions and 5 deletions

View File

@ -449,6 +449,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
bool header = (*s)->GetPropertyAsBool("HEADER_FILE_ONLY") bool header = (*s)->GetPropertyAsBool("HEADER_FILE_ONLY")
|| this->GlobalGenerator->IgnoreFile || this->GlobalGenerator->IgnoreFile
((*s)->GetExtension().c_str()); ((*s)->GetExtension().c_str());
std::string ext =
cmSystemTools::LowerCase((*s)->GetExtension());
if(!lang) if(!lang)
{ {
lang = "None"; lang = "None";
@ -469,7 +471,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
{ {
headers.push_back(sf); headers.push_back(sf);
} }
else if(sf->GetExtension() == "idl") else if(ext == "idl")
{ {
idls.push_back(sf); idls.push_back(sf);
} }
@ -636,14 +638,28 @@ void cmVisualStudio10TargetGenerator::WriteObjSources()
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((*source)->GetExtension() == "obj") std::string ext =
cmSystemTools::LowerCase((*source)->GetExtension());
if(ext == "obj" || ext == "o")
{ {
if(first) if(first)
{ {
this->WriteString("<ItemGroup>\n", 1); this->WriteString("<ItemGroup>\n", 1);
first = false; first = false;
} }
this->WriteString("<None Include=\"", 2); // If an object file is generated, then vs10
// will use it in the build, and we have to list
// it as None instead of Object
if((*source)->GetPropertyAsBool("GENERATED"))
{
this->WriteString("<None Include=\"", 2);
}
// If it is not a generated object then we have
// to use the Object type
else
{
this->WriteString("<Object Include=\"", 2);
}
(*this->BuildFileStream ) << (*source)->GetFullPath() << "\" />\n"; (*this->BuildFileStream ) << (*source)->GetFullPath() << "\" />\n";
} }
} }
@ -665,8 +681,8 @@ 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)
{ {
std::string ext = (*source)->GetExtension(); std::string ext = cmSystemTools::LowerCase((*source)->GetExtension());
if((*source)->GetCustomCommand() || ext == "obj") if((*source)->GetCustomCommand() || ext == "o" || ext == "obj")
{ {
continue; continue;
} }

View File

@ -51,5 +51,11 @@ ADD_CUSTOM_COMMAND(
DEPENDS ${EXTERNAL_OBJECT} DEPENDS ${EXTERNAL_OBJECT}
) )
message("${EXTERNAL_OBJECT}")
# Build an executable using the external object file. # Build an executable using the external object file.
ADD_EXECUTABLE(ExternalOBJ executable.cxx ${CUSTOM_OBJECT}) ADD_EXECUTABLE(ExternalOBJ executable.cxx ${CUSTOM_OBJECT})
# A bug showed up in VS2010 where an object file that was
# part of a custom commad output worked, but ones that were
# not didn't work. So, repeat the executable using the object
# directly and not from the output of the copy.
ADD_EXECUTABLE(ExternalOBJ2 executable.cxx ${EXTERNAL_OBJECT})