ENH: Do not generate install target unless some INSTALL or INSTALL_* commands have been used. This addresses bug#2827.
This commit is contained in:
parent
8ffb32369f
commit
239fce5caa
|
@ -42,6 +42,9 @@ cmGlobalGenerator::cmGlobalGenerator()
|
||||||
|
|
||||||
// Relative paths are not configured in the constructor.
|
// Relative paths are not configured in the constructor.
|
||||||
this->RelativePathsConfigured = false;
|
this->RelativePathsConfigured = false;
|
||||||
|
|
||||||
|
// Whether an install target is needed.
|
||||||
|
this->InstallTargetEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalGenerator::~cmGlobalGenerator()
|
cmGlobalGenerator::~cmGlobalGenerator()
|
||||||
|
@ -927,6 +930,11 @@ void cmGlobalGenerator::AddInstallComponent(const char* component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmGlobalGenerator::EnableInstallTarget()
|
||||||
|
{
|
||||||
|
this->InstallTargetEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
|
cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
|
||||||
{
|
{
|
||||||
cmLocalGenerator *lg = new cmLocalGenerator;
|
cmLocalGenerator *lg = new cmLocalGenerator;
|
||||||
|
@ -1448,66 +1456,69 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Install
|
//Install
|
||||||
std::string cmd;
|
if(this->InstallTargetEnabled)
|
||||||
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end());
|
|
||||||
singleLine.erase(singleLine.begin(), singleLine.end());
|
|
||||||
depends.erase(depends.begin(), depends.end());
|
|
||||||
if ( this->GetPreinstallTargetName() )
|
|
||||||
{
|
{
|
||||||
depends.push_back(this->GetPreinstallTargetName());
|
std::string cmd;
|
||||||
}
|
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end());
|
||||||
else
|
singleLine.erase(singleLine.begin(), singleLine.end());
|
||||||
{
|
depends.erase(depends.begin(), depends.end());
|
||||||
const char* noall =
|
if ( this->GetPreinstallTargetName() )
|
||||||
mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
|
|
||||||
if(!noall || cmSystemTools::IsOff(noall))
|
|
||||||
{
|
{
|
||||||
depends.push_back(this->GetAllTargetName());
|
depends.push_back(this->GetPreinstallTargetName());
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
if(mf->GetDefinition("CMake_BINARY_DIR"))
|
|
||||||
{
|
|
||||||
// We are building CMake itself. We cannot use the original
|
|
||||||
// executable to install over itself.
|
|
||||||
cmd = mf->GetDefinition("EXECUTABLE_OUTPUT_PATH");
|
|
||||||
if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.')
|
|
||||||
{
|
{
|
||||||
cmd += "/";
|
const char* noall =
|
||||||
cmd += cmakeCfgIntDir;
|
mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
|
||||||
|
if(!noall || cmSystemTools::IsOff(noall))
|
||||||
|
{
|
||||||
|
depends.push_back(this->GetAllTargetName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cmd += "/cmake";
|
if(mf->GetDefinition("CMake_BINARY_DIR"))
|
||||||
}
|
{
|
||||||
else
|
// We are building CMake itself. We cannot use the original
|
||||||
{
|
// executable to install over itself.
|
||||||
cmd = cmakeCommand;
|
cmd = mf->GetDefinition("EXECUTABLE_OUTPUT_PATH");
|
||||||
}
|
if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.')
|
||||||
singleLine.push_back(cmd.c_str());
|
{
|
||||||
if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
|
cmd += "/";
|
||||||
{
|
cmd += cmakeCfgIntDir;
|
||||||
std::string cfgArg = "-DBUILD_TYPE=";
|
}
|
||||||
cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR");
|
cmd += "/cmake";
|
||||||
singleLine.push_back(cfgArg);
|
}
|
||||||
}
|
else
|
||||||
singleLine.push_back("-P");
|
{
|
||||||
singleLine.push_back("cmake_install.cmake");
|
cmd = cmakeCommand;
|
||||||
cpackCommandLines.push_back(singleLine);
|
}
|
||||||
(*targets)[this->GetInstallTargetName()] =
|
singleLine.push_back(cmd.c_str());
|
||||||
this->CreateGlobalTarget(
|
if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
|
||||||
this->GetInstallTargetName(), "Install the project...",
|
{
|
||||||
&cpackCommandLines, depends);
|
std::string cfgArg = "-DBUILD_TYPE=";
|
||||||
|
cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR");
|
||||||
// install_local
|
singleLine.push_back(cfgArg);
|
||||||
if(const char* install_local = this->GetInstallLocalTargetName())
|
}
|
||||||
{
|
singleLine.push_back("-P");
|
||||||
singleLine.insert(singleLine.begin()+1, "-DCMAKE_INSTALL_LOCAL_ONLY=1");
|
singleLine.push_back("cmake_install.cmake");
|
||||||
cpackCommandLines.erase(cpackCommandLines.begin(),
|
|
||||||
cpackCommandLines.end());
|
|
||||||
cpackCommandLines.push_back(singleLine);
|
cpackCommandLines.push_back(singleLine);
|
||||||
|
(*targets)[this->GetInstallTargetName()] =
|
||||||
(*targets)[install_local] =
|
|
||||||
this->CreateGlobalTarget(
|
this->CreateGlobalTarget(
|
||||||
install_local, "Installing only the local directory...",
|
this->GetInstallTargetName(), "Install the project...",
|
||||||
&cpackCommandLines, depends);
|
&cpackCommandLines, depends);
|
||||||
|
|
||||||
|
// install_local
|
||||||
|
if(const char* install_local = this->GetInstallLocalTargetName())
|
||||||
|
{
|
||||||
|
singleLine.insert(singleLine.begin()+1, "-DCMAKE_INSTALL_LOCAL_ONLY=1");
|
||||||
|
cpackCommandLines.erase(cpackCommandLines.begin(),
|
||||||
|
cpackCommandLines.end());
|
||||||
|
cpackCommandLines.push_back(singleLine);
|
||||||
|
|
||||||
|
(*targets)[install_local] =
|
||||||
|
this->CreateGlobalTarget(
|
||||||
|
install_local, "Installing only the local directory...",
|
||||||
|
&cpackCommandLines, depends);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ public:
|
||||||
void AddLocalGenerator(cmLocalGenerator *lg);
|
void AddLocalGenerator(cmLocalGenerator *lg);
|
||||||
|
|
||||||
void AddInstallComponent(const char* component);
|
void AddInstallComponent(const char* component);
|
||||||
|
void EnableInstallTarget();
|
||||||
|
|
||||||
static int s_TryCompileTimeout;
|
static int s_TryCompileTimeout;
|
||||||
|
|
||||||
|
@ -221,6 +222,7 @@ protected:
|
||||||
|
|
||||||
// Set of named installation components requested by the project.
|
// Set of named installation components requested by the project.
|
||||||
std::set<cmStdString> InstallComponents;
|
std::set<cmStdString> InstallComponents;
|
||||||
|
bool InstallTargetEnabled;
|
||||||
|
|
||||||
// Manifest of all targets that will be built for each configuration.
|
// Manifest of all targets that will be built for each configuration.
|
||||||
// This is computed just before local generators generate.
|
// This is computed just before local generators generate.
|
||||||
|
|
|
@ -33,6 +33,10 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the install target.
|
||||||
|
this->Makefile->GetLocalGenerator()
|
||||||
|
->GetGlobalGenerator()->EnableInstallTarget();
|
||||||
|
|
||||||
// Switch among the command modes.
|
// Switch among the command modes.
|
||||||
if(args[0] == "SCRIPT")
|
if(args[0] == "SCRIPT")
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,11 @@ bool cmInstallFilesCommand
|
||||||
this->SetError("called with incorrect number of arguments");
|
this->SetError("called with incorrect number of arguments");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the install target.
|
||||||
|
this->Makefile->GetLocalGenerator()
|
||||||
|
->GetGlobalGenerator()->EnableInstallTarget();
|
||||||
|
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
|
this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ bool cmInstallProgramsCommand
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the install target.
|
||||||
|
this->Makefile->GetLocalGenerator()
|
||||||
|
->GetGlobalGenerator()->EnableInstallTarget();
|
||||||
|
|
||||||
// Create an INSTALL_PROGRAMS target specifically for this path.
|
// Create an INSTALL_PROGRAMS target specifically for this path.
|
||||||
this->TargetName = "INSTALL_PROGRAMS_"+args[0];
|
this->TargetName = "INSTALL_PROGRAMS_"+args[0];
|
||||||
cmTarget& target = this->Makefile->GetTargets()[this->TargetName];
|
cmTarget& target = this->Makefile->GetTargets()[this->TargetName];
|
||||||
|
|
|
@ -26,6 +26,10 @@ bool cmInstallTargetsCommand
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable the install target.
|
||||||
|
this->Makefile->GetLocalGenerator()
|
||||||
|
->GetGlobalGenerator()->EnableInstallTarget();
|
||||||
|
|
||||||
cmTargets &tgts = this->Makefile->GetTargets();
|
cmTargets &tgts = this->Makefile->GetTargets();
|
||||||
std::vector<std::string>::const_iterator s = args.begin();
|
std::vector<std::string>::const_iterator s = args.begin();
|
||||||
++s;
|
++s;
|
||||||
|
|
Loading…
Reference in New Issue