diff options
author | Brad King <brad.king@kitware.com> | 2017-04-19 14:47:28 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-04-19 14:47:31 (GMT) |
commit | 44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46 (patch) | |
tree | c95b4621b9a71adc962c9c2e3e3140a0fb73e627 /Source/cmInstallTargetGenerator.cxx | |
parent | 9db9bb27ea3f3dd3db3913c2bc2233f03018d5b0 (diff) | |
parent | eec93bceec5411e4409b5e3ee5dc301fca6fcbfd (diff) | |
download | CMake-44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46.zip CMake-44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46.tar.gz CMake-44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46.tar.bz2 |
Merge topic 'objlib-extend'
eec93bce Allow OBJECT libraries to be installed, exported, and imported
93c89bc7 Genex: Allow TARGET_OBJECTS to be used everywhere
ac0cf7ff Genex: Reject TARGET_OBJECTS on non-object libraries earlier
8577978c Tests: ExportImport C code should use explicit (void) in prototypes
26cfd039 cmInstallTargetGenerator: Re-order GenerateScriptForConfig logic
25f3f22a cmGlobalGenerator: Add method to check if object file location is known
d596c550 cmGeneratorTarget: Add method to get the object file directory
930042f2 cmGeneratorTarget: Factor out a GetTargetObjectNames method
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !712
Diffstat (limited to 'Source/cmInstallTargetGenerator.cxx')
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 88 |
1 files changed, 69 insertions, 19 deletions
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 88fcc56..6ecf42d 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<std::string> filesFrom; - std::vector<std::string> filesTo; - std::string literal_args; cmStateEnums::TargetType targetType = this->Target->GetType(); cmInstallType type = cmInstallType(); switch (targetType) { @@ -100,7 +81,11 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( assert(false && "INTERFACE_LIBRARY targets have no installable outputs."); break; + case cmStateEnums::OBJECT_LIBRARY: + this->GenerateScriptForConfigObjectLibrary(os, config, indent); + return; + case cmStateEnums::UTILITY: case cmStateEnums::GLOBAL_TARGET: case cmStateEnums::UNKNOWN_LIBRARY: @@ -109,6 +94,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<std::string> filesFrom; + std::vector<std::string> filesTo; + std::string literal_args; + if (targetType == cmStateEnums::EXECUTABLE) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -315,6 +322,49 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( &cmInstallTargetGenerator::PostReplacementTweaks); } +static std::string computeInstallObjectDir(cmGeneratorTarget* gt, + std::string const& config) +{ + std::string objectDir = "objects"; + if (!config.empty()) { + objectDir += "-"; + objectDir += config; + } + objectDir += "/"; + objectDir += gt->GetName(); + return objectDir; +} + +void cmInstallTargetGenerator::GenerateScriptForConfigObjectLibrary( + std::ostream& os, const std::string& config, Indent const& indent) +{ + // Compute all the object files inside this target + std::vector<std::string> objects; + this->Target->GetTargetObjectNames(config, objects); + + std::string const dest = this->GetDestination(config) + "/" + + computeInstallObjectDir(this->Target, config); + + std::string const obj_dir = this->Target->GetObjectDirectory(config); + std::string const literal_args = " FILES_FROM_DIR \"" + obj_dir + "\""; + + const char* no_dir_permissions = CM_NULLPTR; + const char* no_rename = CM_NULLPTR; + this->AddInstallRule(os, dest, cmInstallType_FILES, objects, this->Optional, + this->FilePermissions.c_str(), no_dir_permissions, + no_rename, literal_args.c_str(), indent); +} + +void cmInstallTargetGenerator::GetInstallObjectNames( + std::string const& config, std::vector<std::string>& objects) const +{ + this->Target->GetTargetObjectNames(config, objects); + for (std::vector<std::string>::iterator i = objects.begin(); + i != objects.end(); ++i) { + *i = computeInstallObjectDir(this->Target, config) + "/" + *i; + } +} + std::string cmInstallTargetGenerator::GetDestination( std::string const& config) const { |