BUG: don't run strip on OPTIONAL install targets if the file doesn't exist

Alex
This commit is contained in:
Alexander Neundorf 2007-06-15 11:12:07 -04:00
parent fe45c19666
commit 69d3628461
2 changed files with 34 additions and 18 deletions

View File

@ -177,13 +177,15 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
this->AddInstallNamePatchRule(os, destination.c_str());
}
std::string destinationFilename = destination;
destinationFilename += "/";
destinationFilename += cmSystemTools::GetFilenameName(fromFile);
std::string quotedFullDestinationFilename = "\"$ENV{DESTDIR}";
quotedFullDestinationFilename += destination;
quotedFullDestinationFilename += "/";
quotedFullDestinationFilename += cmSystemTools::GetFilenameName(fromFile);
quotedFullDestinationFilename += "\"";
this->AddRanlibRule(os, type, destinationFilename);
this->AddRanlibRule(os, type, quotedFullDestinationFilename);
this->AddStripRule(os, destinationFilename);
this->AddStripRule(os, quotedFullDestinationFilename, optional);
}
//----------------------------------------------------------------------------
@ -451,7 +453,8 @@ void cmInstallTargetGenerator
}
void cmInstallTargetGenerator::AddStripRule(std::ostream& os,
const std::string& destinationFilename)
const std::string& quotedFullDestinationFilename,
bool optional)
{
// Don't handle OSX Bundles.
@ -466,16 +469,26 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os,
return;
}
os << "IF(CMAKE_INSTALL_DO_STRIP)\n";
os << " EXECUTE_PROCESS(COMMAND \"";
os << this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP");
os << "\" \"$ENV{DESTDIR}" << destinationFilename << "\" )\n";
os << "ENDIF(CMAKE_INSTALL_DO_STRIP)\n";
os << "IF(CMAKE_INSTALL_DO_STRIP";
if (optional)
{
os << " AND EXISTS " << quotedFullDestinationFilename;
}
os << ")\n";
os << " EXECUTE_PROCESS(COMMAND \""
<< this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
<< "\" " << quotedFullDestinationFilename << " )\n";
os << "ENDIF(CMAKE_INSTALL_DO_STRIP";
if (optional)
{
os << " AND EXISTS " << quotedFullDestinationFilename;
}
os << ")\n";
}
void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
cmTarget::TargetType type,
const std::string& destinationFilename)
const std::string& quotedFullDestinationFilename)
{
// Static libraries need ranlib on this platform.
if(type != cmTarget::STATIC_LIBRARY)
@ -499,5 +512,5 @@ void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
os << "EXECUTE_PROCESS(COMMAND \"";
os << ranlib;
os << "\" \"$ENV{DESTDIR}" << destinationFilename << "\" )\n";
os << "\" " << quotedFullDestinationFilename << " )\n";
}

View File

@ -44,9 +44,12 @@ protected:
std::string GetScriptReference(cmTarget* target, const char* place,
bool useSOName);
void AddInstallNamePatchRule(std::ostream& os, const char* destination);
void AddStripRule(std::ostream& os, const std::string& destinationFilename);
void AddRanlibRule(std::ostream& os, cmTarget::TargetType type,
const std::string& destinationFilename);
void AddStripRule(std::ostream& os,
const std::string& quotedFullDestinationFilename,
bool optional);
void AddRanlibRule(std::ostream& os,
cmTarget::TargetType type,
const std::string& quotedFullDestinationFilename);
cmTarget* Target;
std::string Destination;