From 26cfd039a9479959da1d893bcee5b2aa879da6c0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 11 Apr 2017 14:33:19 -0400 Subject: cmInstallTargetGenerator: Re-order GenerateScriptForConfig logic Do not populate some local variables before switching on the target type. --- Source/cmInstallTargetGenerator.cxx | 41 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 88fcc56..5b43a1d 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -60,25 +60,6 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) void cmInstallTargetGenerator::GenerateScriptForConfig( std::ostream& os, const std::string& config, Indent const& indent) { - // Compute the build tree directory from which to copy the target. - std::string fromDirConfig; - if (this->Target->NeedRelinkBeforeInstall(config)) { - fromDirConfig = - this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fromDirConfig += cmake::GetCMakeFilesDirectory(); - fromDirConfig += "/CMakeRelink.dir/"; - } else { - fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); - fromDirConfig += "/"; - } - std::string toDir = - this->ConvertToAbsoluteDestination(this->GetDestination(config)); - toDir += "/"; - - // Compute the list of files to install for this target. - std::vector filesFrom; - std::vector filesTo; - std::string literal_args; cmStateEnums::TargetType targetType = this->Target->GetType(); cmInstallType type = cmInstallType(); switch (targetType) { @@ -109,6 +90,28 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( "cmInstallTargetGenerator created with non-installable target."); return; } + + // Compute the build tree directory from which to copy the target. + std::string fromDirConfig; + if (this->Target->NeedRelinkBeforeInstall(config)) { + fromDirConfig = + this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); + fromDirConfig += cmake::GetCMakeFilesDirectory(); + fromDirConfig += "/CMakeRelink.dir/"; + } else { + fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); + fromDirConfig += "/"; + } + + std::string toDir = + this->ConvertToAbsoluteDestination(this->GetDestination(config)); + toDir += "/"; + + // Compute the list of files to install for this target. + std::vector filesFrom; + std::vector filesTo; + std::string literal_args; + if (targetType == cmStateEnums::EXECUTABLE) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); -- cgit v0.12