summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallTargetGenerator.cxx
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2017-03-23 13:32:08 (GMT)
committerBrad King <brad.king@kitware.com>2017-04-18 15:36:10 (GMT)
commiteec93bceec5411e4409b5e3ee5dc301fca6fcbfd (patch)
tree58758ce2d61173c52559f55c0979236cafa7f969 /Source/cmInstallTargetGenerator.cxx
parent93c89bc75ceee599ba7c08b8fe1ac5104942054f (diff)
downloadCMake-eec93bceec5411e4409b5e3ee5dc301fca6fcbfd.zip
CMake-eec93bceec5411e4409b5e3ee5dc301fca6fcbfd.tar.gz
CMake-eec93bceec5411e4409b5e3ee5dc301fca6fcbfd.tar.bz2
Allow OBJECT libraries to be installed, exported, and imported
Teach install() and export() to handle the actual object files. Disallow this on Xcode with multiple architectures because it still cannot be cleanly supported there. Co-Author: Brad King <brad.king@kitware.com>
Diffstat (limited to 'Source/cmInstallTargetGenerator.cxx')
-rw-r--r--Source/cmInstallTargetGenerator.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 5b43a1d..6ecf42d 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -81,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:
@@ -318,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
{