diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2017-03-23 13:32:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-04-18 15:36:10 (GMT) |
commit | eec93bceec5411e4409b5e3ee5dc301fca6fcbfd (patch) | |
tree | 58758ce2d61173c52559f55c0979236cafa7f969 /Source/cmInstallCommand.cxx | |
parent | 93c89bc75ceee599ba7c08b8fe1ac5104942054f (diff) | |
download | CMake-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/cmInstallCommand.cxx')
-rw-r--r-- | Source/cmInstallCommand.cxx | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c8923b0..ba554aa 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -206,6 +206,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmCAStringVector archiveArgVector(&argHelper, "ARCHIVE", &group); cmCAStringVector libraryArgVector(&argHelper, "LIBRARY", &group); cmCAStringVector runtimeArgVector(&argHelper, "RUNTIME", &group); + cmCAStringVector objectArgVector(&argHelper, "OBJECTS", &group); cmCAStringVector frameworkArgVector(&argHelper, "FRAMEWORK", &group); cmCAStringVector bundleArgVector(&argHelper, "BUNDLE", &group); cmCAStringVector includesArgVector(&argHelper, "INCLUDES", &group); @@ -234,6 +235,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmInstallCommandArguments archiveArgs(this->DefaultComponentName); cmInstallCommandArguments libraryArgs(this->DefaultComponentName); cmInstallCommandArguments runtimeArgs(this->DefaultComponentName); + cmInstallCommandArguments objectArgs(this->DefaultComponentName); cmInstallCommandArguments frameworkArgs(this->DefaultComponentName); cmInstallCommandArguments bundleArgs(this->DefaultComponentName); cmInstallCommandArguments privateHeaderArgs(this->DefaultComponentName); @@ -246,6 +248,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) archiveArgs.Parse(&archiveArgVector.GetVector(), &unknownArgs); libraryArgs.Parse(&libraryArgVector.GetVector(), &unknownArgs); runtimeArgs.Parse(&runtimeArgVector.GetVector(), &unknownArgs); + objectArgs.Parse(&objectArgVector.GetVector(), &unknownArgs); frameworkArgs.Parse(&frameworkArgVector.GetVector(), &unknownArgs); bundleArgs.Parse(&bundleArgVector.GetVector(), &unknownArgs); privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs); @@ -265,6 +268,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) archiveArgs.SetGenericArguments(&genericArgs); libraryArgs.SetGenericArguments(&genericArgs); runtimeArgs.SetGenericArguments(&genericArgs); + objectArgs.SetGenericArguments(&genericArgs); frameworkArgs.SetGenericArguments(&genericArgs); bundleArgs.SetGenericArguments(&genericArgs); privateHeaderArgs.SetGenericArguments(&genericArgs); @@ -274,6 +278,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) success = success && archiveArgs.Finalize(); success = success && libraryArgs.Finalize(); success = success && runtimeArgs.Finalize(); + success = success && objectArgs.Finalize(); success = success && frameworkArgs.Finalize(); success = success && bundleArgs.Finalize(); success = success && privateHeaderArgs.Finalize(); @@ -287,8 +292,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Enforce argument rules too complex to specify for the // general-purpose parser. if (archiveArgs.GetNamelinkOnly() || runtimeArgs.GetNamelinkOnly() || - frameworkArgs.GetNamelinkOnly() || bundleArgs.GetNamelinkOnly() || - privateHeaderArgs.GetNamelinkOnly() || + objectArgs.GetNamelinkOnly() || frameworkArgs.GetNamelinkOnly() || + bundleArgs.GetNamelinkOnly() || privateHeaderArgs.GetNamelinkOnly() || publicHeaderArgs.GetNamelinkOnly() || resourceArgs.GetNamelinkOnly()) { this->SetError( "TARGETS given NAMELINK_ONLY option not in LIBRARY group. " @@ -296,8 +301,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } if (archiveArgs.GetNamelinkSkip() || runtimeArgs.GetNamelinkSkip() || - frameworkArgs.GetNamelinkSkip() || bundleArgs.GetNamelinkSkip() || - privateHeaderArgs.GetNamelinkSkip() || + objectArgs.GetNamelinkSkip() || frameworkArgs.GetNamelinkSkip() || + bundleArgs.GetNamelinkSkip() || privateHeaderArgs.GetNamelinkSkip() || publicHeaderArgs.GetNamelinkSkip() || resourceArgs.GetNamelinkSkip()) { this->SetError( "TARGETS given NAMELINK_SKIP option not in LIBRARY group. " @@ -356,11 +361,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { - std::ostringstream e; - e << "TARGETS given OBJECT library \"" << (*targetIt) - << "\" which may not be installed."; - this->SetError(e.str()); - return false; + std::string reason; + if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation( + &reason)) { + std::ostringstream e; + e << "TARGETS given OBJECT library \"" << (*targetIt) + << "\" 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); @@ -379,6 +388,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) bool installsArchive = false; bool installsLibrary = false; bool installsRuntime = false; + bool installsObject = false; bool installsFramework = false; bool installsBundle = false; bool installsPrivateHeader = false; @@ -393,6 +403,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmInstallTargetGenerator* archiveGenerator = CM_NULLPTR; cmInstallTargetGenerator* libraryGenerator = CM_NULLPTR; cmInstallTargetGenerator* runtimeGenerator = CM_NULLPTR; + cmInstallTargetGenerator* objectGenerator = CM_NULLPTR; cmInstallTargetGenerator* frameworkGenerator = CM_NULLPTR; cmInstallTargetGenerator* bundleGenerator = CM_NULLPTR; cmInstallFilesGenerator* privateHeaderGenerator = CM_NULLPTR; @@ -522,6 +533,20 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } } break; + case cmStateEnums::OBJECT_LIBRARY: { + // Objects use OBJECT properties. + if (!objectArgs.GetDestination().empty()) { + 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; + } + } break; case cmStateEnums::EXECUTABLE: { if (target.IsAppBundleOnApple()) { // Application bundles use the BUNDLE properties. @@ -664,6 +689,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) installsArchive = installsArchive || archiveGenerator != CM_NULLPTR; installsLibrary = installsLibrary || libraryGenerator != CM_NULLPTR; installsRuntime = installsRuntime || runtimeGenerator != CM_NULLPTR; + installsObject = installsObject || objectGenerator != CM_NULLPTR; installsFramework = installsFramework || frameworkGenerator != CM_NULLPTR; installsBundle = installsBundle || bundleGenerator != CM_NULLPTR; installsPrivateHeader = @@ -675,6 +701,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) this->Makefile->AddInstallGenerator(archiveGenerator); this->Makefile->AddInstallGenerator(libraryGenerator); this->Makefile->AddInstallGenerator(runtimeGenerator); + this->Makefile->AddInstallGenerator(objectGenerator); this->Makefile->AddInstallGenerator(frameworkGenerator); this->Makefile->AddInstallGenerator(bundleGenerator); this->Makefile->AddInstallGenerator(privateHeaderGenerator); @@ -692,6 +719,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) te->HeaderGenerator = publicHeaderGenerator; te->LibraryGenerator = libraryGenerator; te->RuntimeGenerator = runtimeGenerator; + te->ObjectsGenerator = objectGenerator; this->Makefile->GetGlobalGenerator() ->GetExportSets()[exports.GetString()] ->AddTargetExport(te); @@ -715,6 +743,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) this->Makefile->GetGlobalGenerator()->AddInstallComponent( runtimeArgs.GetComponent().c_str()); } + if (installsObject) { + this->Makefile->GetGlobalGenerator()->AddInstallComponent( + objectArgs.GetComponent().c_str()); + } if (installsFramework) { this->Makefile->GetGlobalGenerator()->AddInstallComponent( frameworkArgs.GetComponent().c_str()); |