diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 91038d567..502683448 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -293,9 +293,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } - exeCleanFiles.push_back(this->Convert(cleanFullPDBName.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::UNCHANGED)); + + // List the PDB for cleaning only when the whole target is + // cleaned. We do not want to delete the .pdb file just before + // linking the target. + this->CleanFiles.push_back + (this->Convert(cleanFullPDBName.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); } // Add a command to remove any existing files for this executable. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 39580ad48..6f6ab2e68 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -401,7 +401,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } - libCleanFiles.push_back + + // List the PDB for cleaning only when the whole target is + // cleaned. We do not want to delete the .pdb file just before + // linking the target. + this->CleanFiles.push_back (this->Convert(cleanFullPDBName.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED));