BUG: Do not report files as installed if they are optional and do not exist.

This commit is contained in:
Brad King 2006-02-19 16:12:29 -05:00
parent 39f4e7f5e0
commit e14d591194
2 changed files with 25 additions and 12 deletions

View File

@ -50,14 +50,24 @@ cmInstallGenerator
void cmInstallGenerator::AddInstallRule(std::ostream& os, void cmInstallGenerator::AddInstallRule(std::ostream& os,
const char* dest, const char* dest,
int type, int type,
const char* files, const char* file,
bool optional /* = false */, bool optional /* = false */,
const char* properties /* = 0 */) const char* properties /* = 0 */)
{ {
// TODO: Make optional files use IF(EXISTS) to not report if not // If the file is optional test its existence before installing.
// installing. const char* indent = "";
std::string sfiles = files; if(optional)
std::string destination = dest; {
os << "IF(EXISTS \"" << file << "\")\n";
indent = " ";
}
// Write a message indicating the file is being installed.
std::string fname = cmSystemTools::GetFilenameName(file);
os << indent << "MESSAGE(STATUS \"Installing " << dest
<< "/" << fname.c_str() << "\")\n";
// Use the FILE command to install the file.
std::string stype; std::string stype;
switch(type) switch(type)
{ {
@ -69,14 +79,17 @@ void cmInstallGenerator::AddInstallRule(std::ostream& os,
case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_FILES:
default: stype = "FILE"; break; default: stype = "FILE"; break;
} }
std::string fname = cmSystemTools::GetFilenameName(sfiles.c_str()); os << indent << "FILE(INSTALL DESTINATION \"" << dest
os << "MESSAGE(STATUS \"Installing " << destination.c_str() << "\" TYPE " << stype.c_str() ;
<< "/" << fname.c_str() << "\")\n"
<< "FILE(INSTALL DESTINATION \"" << destination.c_str()
<< "\" TYPE " << stype.c_str() << (optional?" OPTIONAL":"") ;
if(properties && *properties) if(properties && *properties)
{ {
os << " PROPERTIES" << properties; os << " PROPERTIES" << properties;
} }
os << " FILES \"" << sfiles.c_str() << "\")\n"; os << " FILES \"" << file << "\")\n";
// If the file is optional close the IF block.
if(optional)
{
os << "ENDIF(EXISTS \"" << file << "\")\n";
}
} }

View File

@ -35,7 +35,7 @@ public:
std::vector<std::string> const& configurationTypes); std::vector<std::string> const& configurationTypes);
static void AddInstallRule(std::ostream& os, const char* dest, int type, static void AddInstallRule(std::ostream& os, const char* dest, int type,
const char* files, bool optional = false, const char* file, bool optional = false,
const char* properties = 0); const char* properties = 0);
protected: protected: