BUG: Fixed optional file install support for multi-configuration generators.
This commit is contained in:
parent
c21287552b
commit
3ca9ef09b7
@ -290,13 +290,6 @@ bool cmFileCommand::HandleInstallCommand(
|
|||||||
|
|
||||||
const char* destdir = cmSystemTools::GetEnv("DESTDIR");
|
const char* destdir = cmSystemTools::GetEnv("DESTDIR");
|
||||||
|
|
||||||
std::string extra_dir = "";
|
|
||||||
if ( build_type )
|
|
||||||
{
|
|
||||||
extra_dir = build_type;
|
|
||||||
std::string btype = cmSystemTools::LowerCase(build_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
int itype = cmTarget::INSTALL_FILES;
|
int itype = cmTarget::INSTALL_FILES;
|
||||||
|
|
||||||
@ -553,14 +546,9 @@ bool cmFileCommand::HandleInstallCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reconstruct the source file path taking into account the
|
// Reconstruct the source file path taking into account the
|
||||||
// extra directory and possible new file name.
|
// possibly new file name.
|
||||||
cmOStringStream str;
|
cmOStringStream str;
|
||||||
str << cmSystemTools::GetFilenamePath(ctarget) << "/";
|
str << cmSystemTools::GetFilenamePath(ctarget) << "/" << fname;
|
||||||
if ( extra_dir.size() > 0 )
|
|
||||||
{
|
|
||||||
str << extra_dir << "/";
|
|
||||||
}
|
|
||||||
str << fname;
|
|
||||||
ctarget = str.str();
|
ctarget = str.str();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -597,23 +585,22 @@ bool cmFileCommand::HandleInstallCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reconstruct the source file path taking into account the
|
// Reconstruct the source file path taking into account the
|
||||||
// extra directory and possible new file name.
|
// possibly new file name.
|
||||||
cmOStringStream str;
|
cmOStringStream str;
|
||||||
str << cmSystemTools::GetFilenamePath(ctarget) << "/";
|
str << cmSystemTools::GetFilenamePath(ctarget) << "/" << fname;
|
||||||
if ( extra_dir.size() > 0 )
|
|
||||||
{
|
|
||||||
str << extra_dir << "/";
|
|
||||||
}
|
|
||||||
str << fname;
|
|
||||||
ctarget = str.str();
|
ctarget = str.str();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string message;
|
||||||
if ( !cmSystemTools::SameFile(ctarget.c_str(), destfile.c_str()) )
|
if ( !cmSystemTools::SameFile(ctarget.c_str(), destfile.c_str()) )
|
||||||
{
|
{
|
||||||
if ( cmSystemTools::FileExists(ctarget.c_str()) )
|
if ( cmSystemTools::FileExists(ctarget.c_str()) )
|
||||||
{
|
{
|
||||||
|
message = "Installing ";
|
||||||
|
message += destfile.c_str();
|
||||||
|
m_Makefile->DisplayStatus(message.c_str(), -1);
|
||||||
cmSystemTools::RemoveFile(destfile.c_str());
|
cmSystemTools::RemoveFile(destfile.c_str());
|
||||||
if ( !cmSystemTools::CopyFileAlways(ctarget.c_str(),
|
if ( !cmSystemTools::CopyFileAlways(ctarget.c_str(),
|
||||||
destination.c_str()) )
|
destination.c_str()) )
|
||||||
|
@ -54,19 +54,6 @@ void cmInstallGenerator::AddInstallRule(std::ostream& os,
|
|||||||
bool optional /* = false */,
|
bool optional /* = false */,
|
||||||
const char* properties /* = 0 */)
|
const char* properties /* = 0 */)
|
||||||
{
|
{
|
||||||
// If the file is optional test its existence before installing.
|
|
||||||
const char* indent = "";
|
|
||||||
if(optional)
|
|
||||||
{
|
|
||||||
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.
|
// Use the FILE command to install the file.
|
||||||
std::string stype;
|
std::string stype;
|
||||||
switch(type)
|
switch(type)
|
||||||
@ -79,17 +66,14 @@ void cmInstallGenerator::AddInstallRule(std::ostream& os,
|
|||||||
case cmTarget::INSTALL_FILES:
|
case cmTarget::INSTALL_FILES:
|
||||||
default: stype = "FILE"; break;
|
default: stype = "FILE"; break;
|
||||||
}
|
}
|
||||||
os << indent << "FILE(INSTALL DESTINATION \"" << dest
|
os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
|
||||||
<< "\" TYPE " << stype.c_str() ;
|
if(optional)
|
||||||
|
{
|
||||||
|
os << " OPTIONAL";
|
||||||
|
}
|
||||||
if(properties && *properties)
|
if(properties && *properties)
|
||||||
{
|
{
|
||||||
os << " PROPERTIES" << properties;
|
os << " PROPERTIES" << properties;
|
||||||
}
|
}
|
||||||
os << " FILES \"" << file << "\")\n";
|
os << " FILES \"" << file << "\")\n";
|
||||||
|
|
||||||
// If the file is optional close the IF block.
|
|
||||||
if(optional)
|
|
||||||
{
|
|
||||||
os << "ENDIF(EXISTS \"" << file << "\")\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
#include "cmInstallTargetGenerator.h"
|
#include "cmInstallTargetGenerator.h"
|
||||||
|
|
||||||
|
#include "cmGlobalGenerator.h"
|
||||||
|
#include "cmLocalGenerator.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmTarget.h"
|
#include "cmTarget.h"
|
||||||
|
|
||||||
@ -162,8 +164,13 @@ cmInstallTargetGenerator
|
|||||||
this->ConfigurationTypes->begin();
|
this->ConfigurationTypes->begin();
|
||||||
i != this->ConfigurationTypes->end(); ++i)
|
i != this->ConfigurationTypes->end(); ++i)
|
||||||
{
|
{
|
||||||
|
// Start with the configuration's subdirectory.
|
||||||
|
fname = "";
|
||||||
|
this->Target->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()->
|
||||||
|
AppendDirectoryForConfig(i->c_str(), fname);
|
||||||
|
|
||||||
// Set a variable with the target name for this configuration.
|
// Set a variable with the target name for this configuration.
|
||||||
fname = this->Target->GetFullName(i->c_str(), this->ImportLibrary);
|
fname += this->Target->GetFullName(i->c_str(), this->ImportLibrary);
|
||||||
os << "SET(" << this->Target->GetName()
|
os << "SET(" << this->Target->GetName()
|
||||||
<< (this->ImportLibrary? "_IMPNAME_" : "_NAME_") << *i
|
<< (this->ImportLibrary? "_IMPNAME_" : "_NAME_") << *i
|
||||||
<< " \"" << fname << "\")\n";
|
<< " \"" << fname << "\")\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user