From ef22ad6bec33cf2d9701732b6985744bf485cc06 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 22 Aug 2007 11:32:48 -0400 Subject: ENH: Handle FRAMEWORK and BUNDLE arguments in the INSTALL TARGETS command. Work in progress... More to come. --- Source/cmGlobalGenerator.cxx | 7 +- Source/cmGlobalGenerator.h | 4 +- Source/cmInstallCommand.cxx | 242 ++++++++++++++++++++++++++++++------ Source/cmInstallExportGenerator.cxx | 4 +- Source/cmInstallExportGenerator.h | 9 +- 5 files changed, 223 insertions(+), 43 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index aeffcdf..ac69843 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1079,11 +1079,14 @@ void cmGlobalGenerator::AddTargetToExports(const char* exportSetName, cmTarget* target, cmInstallTargetGenerator* archive, cmInstallTargetGenerator* runTime, - cmInstallTargetGenerator* library) + cmInstallTargetGenerator* library, + cmInstallTargetGenerator* framework, + cmInstallTargetGenerator* bundle) { if ((exportSetName) && (*exportSetName) && (target)) { - cmTargetExport* te = new cmTargetExport(target, archive, runTime, library); + cmTargetExport* te = new cmTargetExport(target, archive, runTime, library, + framework, bundle); this->ExportSets[exportSetName].push_back(te); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index fbddb47..6b8e53e 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -142,7 +142,9 @@ public: void AddTargetToExports(const char* exportSet, cmTarget* target, cmInstallTargetGenerator* archive, cmInstallTargetGenerator* runTime, - cmInstallTargetGenerator* library); + cmInstallTargetGenerator* library, + cmInstallTargetGenerator* framework, + cmInstallTargetGenerator* bundle); ///! Get the export target set with the given name const std::vector* GetExportSet(const char* name) const; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 5de168b..4ff5c63 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -144,23 +144,35 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) bool archive_settings = true; bool library_settings = true; bool runtime_settings = true; + bool framework_settings = true; + bool bundle_settings = true; std::vector targets; const char* archive_destination = 0; const char* library_destination = 0; const char* runtime_destination = 0; + const char* framework_destination = 0; + const char* bundle_destination = 0; std::string archive_permissions; std::string library_permissions; std::string runtime_permissions; + std::string framework_permissions; + std::string bundle_permissions; std::string archive_component = "Unspecified"; std::string library_component = "Unspecified"; std::string runtime_component = "Unspecified"; + std::string framework_component = "Unspecified"; + std::string bundle_component = "Unspecified"; std::string exportName; std::vector archive_configurations; std::vector library_configurations; std::vector runtime_configurations; + std::vector framework_configurations; + std::vector bundle_configurations; bool archive_optional = false; bool library_optional = false; bool runtime_optional = false; + bool framework_optional = false; + bool bundle_optional = false; for(unsigned int i=1; i < args.size(); ++i) { if(args[i] == "DESTINATION") @@ -215,6 +227,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) archive_settings = true; library_settings = false; runtime_settings = false; + framework_settings = false; + bundle_settings = false; } else if(args[i] == "LIBRARY") { @@ -228,6 +242,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) archive_settings = false; library_settings = true; runtime_settings = false; + framework_settings = false; + bundle_settings = false; } else if(args[i] == "RUNTIME") { @@ -241,10 +257,42 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) archive_settings = false; library_settings = false; runtime_settings = true; + framework_settings = false; + bundle_settings = false; + } + else if(args[i] == "FRAMEWORK") + { + // Switch to setting only framework properties. + doing_targets = false; + doing_destination = false; + doing_permissions = false; + doing_component = false; + doing_configurations = false; + doing_export = false; + archive_settings = false; + library_settings = false; + runtime_settings = false; + framework_settings = true; + bundle_settings = false; + } + else if(args[i] == "BUNDLE") + { + // Switch to setting only bundle properties. + doing_targets = false; + doing_destination = false; + doing_permissions = false; + doing_component = false; + doing_configurations = false; + doing_export = false; + archive_settings = false; + library_settings = false; + runtime_settings = false; + framework_settings = false; + bundle_settings = true; } else if(args[i] == "EXPORT") { - // Switch to setting only runtime properties. + // Switch to setting the export property. doing_targets = false; doing_destination = false; doing_permissions = false; @@ -272,6 +320,14 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) { runtime_optional = true; } + if(framework_settings) + { + framework_optional = true; + } + if(bundle_settings) + { + bundle_optional = true; + } } else if(doing_targets) { @@ -319,6 +375,14 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) { runtime_destination = args[i].c_str(); } + if(framework_settings) + { + framework_destination = args[i].c_str(); + } + if(bundle_settings) + { + bundle_destination = args[i].c_str(); + } doing_destination = false; } else if(doing_component) @@ -336,6 +400,14 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) { runtime_component = args[i]; } + if(framework_settings) + { + framework_component = args[i]; + } + if(bundle_settings) + { + bundle_component = args[i]; + } doing_component = false; } else if(doing_permissions) @@ -377,6 +449,30 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) return false; } } + if(framework_settings) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], framework_permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + if(bundle_settings) + { + // Check the requested permission. + if(!this->CheckPermissions(args[i], bundle_permissions)) + { + cmOStringStream e; + e << args[0] << " given invalid permission \"" + << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } } else if(doing_configurations) { @@ -393,6 +489,14 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) { runtime_configurations.push_back(args[i]); } + if(framework_settings) + { + framework_configurations.push_back(args[i]); + } + if(bundle_settings) + { + bundle_configurations.push_back(args[i]); + } } else if(doing_export) { @@ -414,7 +518,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) { return true; } - if(!archive_destination && !library_destination && !runtime_destination) + if(!archive_destination && !library_destination && !runtime_destination && + !framework_destination && !bundle_destination) { this->SetError("TARGETS given no DESTINATION!"); return false; @@ -429,9 +534,13 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) std::string archive_dest; std::string library_dest; std::string runtime_dest; + std::string framework_dest; + std::string bundle_dest; this->ComputeDestination(archive_destination, archive_dest); this->ComputeDestination(library_destination, library_dest); this->ComputeDestination(runtime_destination, runtime_dest); + if(framework_destination) framework_dest = framework_destination; + if(bundle_destination) bundle_dest = bundle_destination; // Generate install script code to install the given targets. for(std::vector::iterator ti = targets.begin(); @@ -440,8 +549,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Handle each target type. cmTarget& target = *(*ti); cmInstallTargetGenerator* archiveGenerator = 0; - cmInstallTargetGenerator* runtimeGenerator = 0; cmInstallTargetGenerator* libraryGenerator = 0; + cmInstallTargetGenerator* runtimeGenerator = 0; + cmInstallTargetGenerator* frameworkGenerator = 0; + cmInstallTargetGenerator* bundleGenerator = 0; switch(target.GetType()) { @@ -480,24 +591,51 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) else { // This is a non-DLL platform. - if(library_destination) + // If it is marked with FRAMEWORK property use the FRAMEWORK set of + // INSTALL properties. Otherwise, use the LIBRARY properties. + if(target.GetPropertyAsBool("FRAMEWORK")) { - // The shared library uses the LIBRARY properties. - libraryGenerator = new cmInstallTargetGenerator(target, - library_dest.c_str(), - false, - library_permissions.c_str(), - library_configurations, - library_component.c_str(), - library_optional); + if(framework_destination) + { + // Use the FRAMEWORK properties. + frameworkGenerator = new cmInstallTargetGenerator(target, + framework_dest.c_str(), + false, + framework_permissions.c_str(), + framework_configurations, + framework_component.c_str(), + framework_optional); + } + else + { + cmOStringStream e; + e << "TARGETS given no FRAMEWORK DESTINATION for shared library " + "FRAMEWORK target \"" << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } } else { - cmOStringStream e; - e << "TARGETS given no LIBRARY DESTINATION for shared library " - "target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); - return false; + if(library_destination) + { + // The shared library uses the LIBRARY properties. + libraryGenerator = new cmInstallTargetGenerator(target, + library_dest.c_str(), + false, + library_permissions.c_str(), + library_configurations, + library_component.c_str(), + library_optional); + } + else + { + cmOStringStream e; + e << "TARGETS given no LIBRARY DESTINATION for shared library " + "target \"" << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } } } } @@ -507,8 +645,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Static libraries use ARCHIVE properties. if(archive_destination) { - archiveGenerator = new cmInstallTargetGenerator(target, - archive_dest.c_str(), + archiveGenerator = new cmInstallTargetGenerator(target, + archive_dest.c_str(), false, archive_permissions.c_str(), archive_configurations, @@ -551,23 +689,47 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) case cmTarget::EXECUTABLE: { // Executables use the RUNTIME properties. - if(runtime_destination) + if(target.GetPropertyAsBool("MACOSX_BUNDLE")) { - runtimeGenerator = new cmInstallTargetGenerator(target, - runtime_dest.c_str(), - false, - runtime_permissions.c_str(), - runtime_configurations, - runtime_component.c_str(), - runtime_optional); + if(bundle_destination) + { + bundleGenerator = new cmInstallTargetGenerator(target, + bundle_dest.c_str(), + false, + bundle_permissions.c_str(), + bundle_configurations, + bundle_component.c_str(), + bundle_optional); + } + else + { + cmOStringStream e; + e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable target \"" + << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } } else { - cmOStringStream e; - e << "TARGETS given no RUNTIME DESTINATION for executable target \"" - << target.GetName() << "\"."; - this->SetError(e.str().c_str()); - return false; + if(runtime_destination) + { + runtimeGenerator = new cmInstallTargetGenerator(target, + runtime_dest.c_str(), + false, + runtime_permissions.c_str(), + runtime_configurations, + runtime_component.c_str(), + runtime_optional); + } + else + { + cmOStringStream e; + e << "TARGETS given no RUNTIME DESTINATION for executable target \"" + << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } } // On DLL platforms an executable may also have an import @@ -577,8 +739,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) target.GetPropertyAsBool("ENABLE_EXPORTS")) { // The import library uses the ARCHIVE properties. - archiveGenerator = new cmInstallTargetGenerator(target, - archive_dest.c_str(), + archiveGenerator = new cmInstallTargetGenerator(target, + archive_dest.c_str(), true, archive_permissions.c_str(), archive_configurations, @@ -593,8 +755,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) break; } this->Makefile->AddInstallGenerator(archiveGenerator); - this->Makefile->AddInstallGenerator(runtimeGenerator); this->Makefile->AddInstallGenerator(libraryGenerator); + this->Makefile->AddInstallGenerator(runtimeGenerator); + this->Makefile->AddInstallGenerator(frameworkGenerator); + this->Makefile->AddInstallGenerator(bundleGenerator); if (!exportName.empty()) { @@ -603,7 +767,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) &target, archiveGenerator, runtimeGenerator, - libraryGenerator); + libraryGenerator, + frameworkGenerator, + bundleGenerator); } } @@ -615,6 +781,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) ->AddInstallComponent(library_component.c_str()); this->Makefile->GetLocalGenerator()->GetGlobalGenerator() ->AddInstallComponent(runtime_component.c_str()); + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(framework_component.c_str()); + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(bundle_component.c_str()); return true; } diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 495da6c..a61a8c0 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -185,8 +185,8 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) switch ((*targetIt)->Target->GetType()) { case cmTarget::EXECUTABLE: - exportFileStream << "ADD_EXECUTABLE(" << this->Prefix.c_str() - << (*targetIt)->Target->GetName() + exportFileStream << "ADD_EXECUTABLE(" << this->Prefix.c_str() + << (*targetIt)->Target->GetName() << " IMPORT )\n"; break; case cmTarget::STATIC_LIBRARY: diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 22e4a08..0559872 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -34,14 +34,19 @@ public: cmTargetExport(cmTarget* tgt, cmInstallTargetGenerator* archive, cmInstallTargetGenerator* runtime, - cmInstallTargetGenerator* library + cmInstallTargetGenerator* library, + cmInstallTargetGenerator* framework, + cmInstallTargetGenerator* bundle ) : Target(tgt), ArchiveGenerator(archive), - RuntimeGenerator(runtime), LibraryGenerator(library) {} + RuntimeGenerator(runtime), LibraryGenerator(library), + FrameworkGenerator(framework), BundleGenerator(bundle) {} cmTarget* Target; cmInstallTargetGenerator* ArchiveGenerator; cmInstallTargetGenerator* RuntimeGenerator; cmInstallTargetGenerator* LibraryGenerator; + cmInstallTargetGenerator* FrameworkGenerator; + cmInstallTargetGenerator* BundleGenerator; private: cmTargetExport(); }; -- cgit v0.12