summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-02-28 15:58:07 (GMT)
committerBrad King <brad.king@kitware.com>2018-02-28 15:58:10 (GMT)
commitea0ce73a195e1cc0f672f1e7519c42a240592f15 (patch)
tree568319f21bf3e9ed2583832c0b2e69eb2d29d5b3 /Source/cmInstallCommand.cxx
parentd870148537319da2e86237cbd8baf6815975e594 (diff)
downloadCMake-ea0ce73a195e1cc0f672f1e7519c42a240592f15.zip
CMake-ea0ce73a195e1cc0f672f1e7519c42a240592f15.tar.gz
CMake-ea0ce73a195e1cc0f672f1e7519c42a240592f15.tar.bz2
install,export: Maybe transform OBJECT libraries to INTERFACE libraries
Teach the `install` and `export` commands to support installing and exporting `OBJECT` libraries without their object files. Transform them to `INTERFACE` libraries in such cases. For `install(TARGETS)`, activate this when no destination for the object files is specified. For `export`, activate this only under Xcode with multiple architectures when we have no well-defined object file locations to give to clients.
Diffstat (limited to 'Source/cmInstallCommand.cxx')
-rw-r--r--Source/cmInstallCommand.cxx31
1 files changed, 14 insertions, 17 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 394f976..008a5e0 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -360,17 +360,6 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
this->SetError(e.str());
return false;
}
- if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- std::string reason;
- if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation(
- &reason)) {
- std::ostringstream e;
- e << "TARGETS given OBJECT library \"" << tgt
- << "\" which may not be installed" << reason << ".";
- this->SetError(e.str());
- return false;
- }
- }
// Store the target in the list to be installed.
targets.push_back(target);
} else {
@@ -534,15 +523,23 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
case cmStateEnums::OBJECT_LIBRARY: {
// Objects use OBJECT properties.
if (!objectArgs.GetDestination().empty()) {
+ // Verify that we know where the objects are to install them.
+ std::string reason;
+ if (!this->Makefile->GetGlobalGenerator()
+ ->HasKnownObjectFileLocation(&reason)) {
+ std::ostringstream e;
+ e << "TARGETS given OBJECT library \"" << target.GetName()
+ << "\" whose objects may not be installed" << reason << ".";
+ this->SetError(e.str());
+ return false;
+ }
+
objectGenerator =
CreateInstallTargetGenerator(target, objectArgs, false);
} else {
- std::ostringstream e;
- e << "TARGETS given no OBJECTS DESTINATION for object library "
- "target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
- return false;
+ // Installing an OBJECT library without a destination transforms
+ // it to an INTERFACE library. It installs no files but can be
+ // exported.
}
} break;
case cmStateEnums::EXECUTABLE: {