diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ec9c125a9..2596d7340 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -572,6 +572,12 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, sep = ";"; } (*this->BuildFileStream ) << "\n"; + if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) + { + // VS >= 11 let us turn off linking of custom command outputs. + this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3); + (*this->BuildFileStream ) << "false\n"; + } } this->WriteString("\n", 2); } @@ -879,14 +885,23 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - for(std::vector::const_iterator - si = this->GeneratorTarget->ExternalObjects.begin(); - si != this->GeneratorTarget->ExternalObjects.end(); ++si) + if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) + { + // For VS >= 11 we use LinkObjects to avoid linking custom command + // outputs. Use Object for all external objects, generated or not. + this->WriteSources("Object", this->GeneratorTarget->ExternalObjects); + } + else { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. - std::vector const* d = this->Target->GetSourceDepends(*si); - this->WriteSource((d && !d->empty())? "None":"Object", *si); + for(std::vector::const_iterator + si = this->GeneratorTarget->ExternalObjects.begin(); + si != this->GeneratorTarget->ExternalObjects.end(); ++si) + { + std::vector const* d=this->Target->GetSourceDepends(*si); + this->WriteSource((d && !d->empty())? "None":"Object", *si); + } } this->WriteSources("None", this->GeneratorTarget->ExtraSources);