diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/cmCPackComponentGroup.h | 16 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 37 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 241 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.h | 18 | ||||
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.cxx | 12 | ||||
-rw-r--r-- | Source/cmGetCMakePropertyCommand.cxx | 16 | ||||
-rw-r--r-- | Source/cmGetCMakePropertyCommand.h | 3 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 77 | ||||
-rw-r--r-- | Source/cmInstallFilesCommand.cxx | 5 | ||||
-rw-r--r-- | Source/cmInstallProgramsCommand.cxx | 5 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmInstallTargetsCommand.cxx | 3 |
13 files changed, 392 insertions, 46 deletions
diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index 2e1703c..d080a87 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -70,12 +70,20 @@ public: /// Whether this component defaults to "disabled". bool IsDisabledByDefault : 1; + /// Whether this component should be downloaded on-the-fly. If false, + /// the component will be a part of the installation package. + bool IsDownloaded : 1; + /// A description of this component. std::string Description; /// The installation types that this component is a part of. std::vector<cmCPackInstallationType *> InstallationTypes; + /// If IsDownloaded is true, the name of the archive file that + /// contains the files that are part of this component. + std::string ArchiveFile; + /// The components that this component depends on. std::vector<cmCPackComponent *> Dependencies; @@ -95,6 +103,8 @@ public: class cmCPackComponentGroup { public: + cmCPackComponentGroup() : ParentGroup(0) { } + /// The name of the group (used to reference the group). std::string Name; @@ -112,6 +122,12 @@ public: /// The components within this group. std::vector<cmCPackComponent*> Components; + + /// The parent group of this component group (if any). + cmCPackComponentGroup *ParentGroup; + + /// The subgroups of this group. + std::vector<cmCPackComponentGroup*> Subgroups; }; #endif diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index f786f80..5090606 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -653,6 +653,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str()); + if ( !cmsys::SystemTools::MakeDirectory(dir.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating temporary directory: " + << dir << std::endl); + return 0; + } + cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)" << std::endl); @@ -664,6 +672,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( { mf->AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str()); + if ( !cmsys::SystemTools::MakeDirectory(tempInstallDirectory.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating temporary directory: " + << tempInstallDirectory << std::endl); + return 0; + } + cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Using non-DESTDIR install... (mf->AddDefinition)" << std::endl); cmCPackLogger(cmCPackLog::LOG_DEBUG, @@ -1255,6 +1271,16 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) = this->IsSet((macroPrefix + "_REQUIRED").c_str()); component->IsDisabledByDefault = this->IsSet((macroPrefix + "_DISABLED").c_str()); + component->IsDownloaded + = this->IsSet((macroPrefix + "_DOWNLOADED").c_str()) + || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); + + const char* archiveFile = this->GetOption((macroPrefix + "_ARCHIVE_FILE").c_str()); + if (archiveFile && *archiveFile) + { + component->ArchiveFile = archiveFile; + } + const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str()); if (groupName && *groupName) { @@ -1344,6 +1370,17 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) = this->IsSet((macroPrefix + "_BOLD_TITLE").c_str()); group->IsExpandedByDefault = this->IsSet((macroPrefix + "_EXPANDED").c_str()); + const char* parentGroupName + = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str()); + if (parentGroupName && *parentGroupName) + { + group->ParentGroup = GetComponentGroup(projectName, parentGroupName); + group->ParentGroup->Subgroups.push_back(group); + } + else + { + group->ParentGroup = 0; + } } return group; } diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index cd4ffb8..7be5cb2 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -173,6 +173,9 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, std::string componentDescriptions; std::string groupDescriptions; std::string installTypesCode; + std::string defines; + cmOStringStream macrosOut; + bool anyDownloadedComponents = false; // Create installation types. The order is significant, so we first fill // in a vector based on the indices, and print them in that order. @@ -201,7 +204,11 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, groupIt != this->ComponentGroups.end(); ++groupIt) { - componentCode += this->CreateComponentGroupDescription(&groupIt->second); + if (groupIt->second.ParentGroup == 0) + { + componentCode += + this->CreateComponentGroupDescription(&groupIt->second, macrosOut); + } // Add the group description, if any. if (!groupIt->second.Description.empty()) @@ -218,9 +225,19 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, compIt != this->Components.end(); ++compIt) { + if (compIt->second.Files.empty()) + { + // NSIS cannot cope with components that have no files. + continue; + } + + anyDownloadedComponents = + anyDownloadedComponents || compIt->second.IsDownloaded; + if (!compIt->second.Group) { - componentCode += this->CreateComponentDescription(&compIt->second); + componentCode + += this->CreateComponentDescription(&compIt->second, macrosOut); } // Add this component to the various section lists. @@ -228,6 +245,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, sectionList += compIt->first; sectionList += "\"\n"; selectedVarsList += "Var " + compIt->first + "_selected\n"; + selectedVarsList += "Var " + compIt->first + "_was_installed\n"; // Add the component description, if any. if (!compIt->second.Description.empty()) @@ -238,6 +256,8 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, } } + componentCode += macrosOut.str(); + if (componentDescriptions.empty() && groupDescriptions.empty()) { // Turn off the "Description" box @@ -254,12 +274,23 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", componentDescriptions.c_str()); } + + if (anyDownloadedComponents) + { + defines += "!define CPACK_USES_DOWNLOAD\n"; + if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE"))) + { + defines += "!define CPACK_NSIS_ADD_REMOVE\n"; + } + } + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", installTypesCode.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", "!insertmacro MUI_PAGE_COMPONENTS"); this->SetOptionIfNotSet("CPACK_NSIS_FULL_INSTALL", ""); this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", componentCode.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", sectionList.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", selectedVarsList.c_str()); + this->SetOption("CPACK_NSIS_DEFINES", defines.c_str()); } this->ConfigureFile(nsisInInstallOptions.c_str(), @@ -559,7 +590,7 @@ bool cmCPackNSISGenerator::SupportsComponentInstallation() const //---------------------------------------------------------------------- std::string cmCPackNSISGenerator:: -CreateComponentDescription(cmCPackComponent *component) const +CreateComponentDescription(cmCPackComponent *component, cmOStringStream& macrosOut) { // Basic description of the component std::string componentCode = "Section "; @@ -590,46 +621,204 @@ CreateComponentDescription(cmCPackComponent *component) const componentCode += " SectionIn" + out.str() + "\n"; } componentCode += " SetOutPath \"$INSTDIR\"\n"; - componentCode += " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n"; + + componentCode += " IntCmp $" + component->Name + + "_was_installed ${SF_SELECTED} noinstall_" + component->Name + "\n"; + + // Create the actual installation commands + if (component->IsDownloaded) + { + if (component->ArchiveFile.empty()) + { + // Compute the name of the archive. + std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + packagesDir += ".dummy"; + cmOStringStream out; + out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) + << "-" << component->Name << ".zip"; + component->ArchiveFile = out.str(); + } + + // Create the directory for the upload area + const char* userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY"); + std::string uploadDirectory; + if (userUploadDirectory && *userUploadDirectory) + { + uploadDirectory = userUploadDirectory; + } + else + { + uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY"); + uploadDirectory += "/CPackUploads"; + } + if(!cmSystemTools::FileExists(uploadDirectory.c_str())) + { + if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to create NSIS upload directory " << uploadDirectory + << std::endl); + return ""; + } + } + + // Remove the old archive, if one exists + std::string archiveFile = uploadDirectory + '/' + component->ArchiveFile; + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Building downloaded component archive: " + << archiveFile << std::endl); + if (cmSystemTools::FileExists(archiveFile.c_str(), true)) + { + if (!cmSystemTools::RemoveFile(archiveFile.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to remove archive file " << archiveFile + << std::endl); + return ""; + } + } + + // Find a ZIP program + if (!this->IsSet("ZIP_EXECUTABLE")) + { + this->ReadListFile("CPackZIP.cmake"); + + if (!this->IsSet("ZIP_EXECUTABLE")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to find ZIP program" + << std::endl); + return ""; + } + } + + // The directory where this component's files reside + std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + dirName += '/'; + dirName += component->Name; + dirName += '/'; + + // Build the list of files to go into this archive, and determine the + // size of the installed component. + std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + zipListFileName += "/winZip.filelist"; + bool needQuotesInFile + = cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES")); + unsigned long totalSize = 0; + { // the scope is needed for cmGeneratedFileStream + cmGeneratedFileStream out(zipListFileName.c_str()); + std::vector<std::string>::iterator fileIt; + for (fileIt = component->Files.begin(); + fileIt != component->Files.end(); + ++fileIt) + { + if ( needQuotesInFile ) + { + out << "\""; + } + out << *fileIt; + if ( needQuotesInFile ) + { + out << "\""; + } + out << std::endl; + + totalSize += cmSystemTools::FileLength((dirName + *fileIt).c_str()); + } + } + + // Build the archive in the upload area + std::string cmd = this->GetOption("CPACK_ZIP_COMMAND"); + cmsys::SystemTools::ReplaceString(cmd, "<ARCHIVE>", archiveFile.c_str()); + cmsys::SystemTools::ReplaceString(cmd, "<FILELIST>", + zipListFileName.c_str()); + std::string output; + int retVal = -1; + int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &retVal, + dirName.c_str(), false, 0); + if ( !res || retVal ) + { + std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + tmpFile += "/CompressZip.log"; + cmGeneratedFileStream ofs(tmpFile.c_str()); + ofs << "# Run command: " << cmd.c_str() << std::endl + << "# Output:" << std::endl + << output.c_str() << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: " + << cmd.c_str() << std::endl + << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + return ""; + } + + // Create the NSIS code to download this file on-the-fly. + unsigned totalSizeInKbytes = (totalSize + 512) / 1024; + if (totalSizeInKbytes == 0) + { + totalSizeInKbytes = 1; + } + cmOStringStream out; + out << " AddSize " << totalSizeInKbytes << "\n" + << " Push \"" << component->ArchiveFile << "\"\n" + << " Call DownloadFile\n" + << " ZipDLL::extractall \"$INSTDIR\\" + << component->ArchiveFile << "\" \"$INSTDIR\"\n" + << " Pop $2 ; error message\n" + " StrCmp $2 \"success\" +2 0\n" + " MessageBox MB_OK \"Failed to unzip $2\"\n" + " Delete $INSTDIR\\$0\n"; + componentCode += out.str(); + } + else + { + componentCode += " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n"; + } + componentCode += " noinstall_" + component->Name + ":\n"; componentCode += "SectionEnd\n"; // Macro used to remove the component - componentCode += "!macro Remove_${" + component->Name + "}\n"; + macrosOut << "!macro Remove_${" << component->Name << "}\n"; + macrosOut << " IntCmp $" << component->Name << "_was_installed 0 noremove_" + << component->Name << "\n"; std::vector<std::string>::iterator pathIt; for (pathIt = component->Files.begin(); pathIt != component->Files.end(); ++pathIt) { - componentCode += " Delete \"$INSTDIR\\" + *pathIt + "\"\n"; + macrosOut << " Delete \"$INSTDIR\\" + << cmSystemTools::ConvertToWindowsOutputPath(pathIt->c_str()) + << "\"\n"; } for (pathIt = component->Directories.begin(); pathIt != component->Directories.end(); ++pathIt) { - componentCode += " RMDir \"$INSTDIR\\" + *pathIt + "\"\n"; + macrosOut << " RMDir \"$INSTDIR\\" + << cmSystemTools::ConvertToWindowsOutputPath(pathIt->c_str()) + << "\"\n"; } - componentCode += "!macroend\n"; + macrosOut << " noremove_" << component->Name << ":\n"; + macrosOut << "!macroend\n"; // Macro used to select each of the components that this component // depends on. std::set<cmCPackComponent *> visited; - componentCode += "!macro Select_" + component->Name + "_depends\n"; - componentCode += CreateSelectionDependenciesDescription(component, visited); - componentCode += "!macroend\n"; + macrosOut << "!macro Select_" << component->Name << "_depends\n"; + macrosOut << CreateSelectionDependenciesDescription(component, visited); + macrosOut << "!macroend\n"; // Macro used to deselect each of the components that depend on this // component. visited.clear(); - componentCode += "!macro Deselect_required_by_" + component->Name + "\n"; - componentCode += CreateDeselectionDependenciesDescription(component, visited); - componentCode += "!macroend\n"; + macrosOut << "!macro Deselect_required_by_" << component->Name << "\n"; + macrosOut << CreateDeselectionDependenciesDescription(component, visited); + macrosOut << "!macroend\n"; return componentCode; } //---------------------------------------------------------------------- std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription (cmCPackComponent *component, - std::set<cmCPackComponent *>& visited) const + std::set<cmCPackComponent *>& visited) { // Don't visit a component twice if (visited.count(component)) @@ -660,7 +849,7 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription //---------------------------------------------------------------------- std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription (cmCPackComponent *component, - std::set<cmCPackComponent *>& visited) const + std::set<cmCPackComponent *>& visited) { // Don't visit a component twice if (visited.count(component)) @@ -692,9 +881,10 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription //---------------------------------------------------------------------- std::string cmCPackNSISGenerator:: -CreateComponentGroupDescription(cmCPackComponentGroup *group) const +CreateComponentGroupDescription(cmCPackComponentGroup *group, + cmOStringStream& macrosOut) { - if (group->Components.empty()) + if (group->Components.empty() && group->Subgroups.empty()) { // Silently skip empty groups. NSIS doesn't support them. return std::string(); @@ -713,12 +903,25 @@ CreateComponentGroupDescription(cmCPackComponentGroup *group) const { code += "\"" + group->DisplayName + "\" " + group->Name + "\n"; } + + std::vector<cmCPackComponentGroup*>::iterator groupIt; + for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end(); + ++groupIt) + { + code += this->CreateComponentGroupDescription(*groupIt, macrosOut); + } + std::vector<cmCPackComponent*>::iterator comp; for (comp = group->Components.begin(); comp != group->Components.end(); ++comp) { - code += this->CreateComponentDescription(*comp); + if ((*comp)->Files.empty()) + { + continue; + } + + code += this->CreateComponentDescription(*comp, macrosOut); } code += "SectionGroupEnd\n"; return code; diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index 70068e41..5299a91 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -53,24 +53,30 @@ protected: virtual bool SupportsComponentInstallation() const; /// Produce a string that contains the NSIS code to describe a - /// particular component. - std::string CreateComponentDescription(cmCPackComponent *component) const; + /// particular component. Any added macros will be emitted via + /// macrosOut. + std::string + CreateComponentDescription(cmCPackComponent *component, + cmOStringStream& macrosOut); /// Produce NSIS code that selects all of the components that this component /// depends on, recursively. std::string CreateSelectionDependenciesDescription (cmCPackComponent *component, - std::set<cmCPackComponent *>& visited) const; + std::set<cmCPackComponent *>& visited); /// Produce NSIS code that de-selects all of the components that are dependent /// on this component, recursively. std::string CreateDeselectionDependenciesDescription (cmCPackComponent *component, - std::set<cmCPackComponent *>& visited) const; + std::set<cmCPackComponent *>& visited); /// Produce a string that contains the NSIS code to describe a - /// particular component group, including its components. - std::string CreateComponentGroupDescription(cmCPackComponentGroup *group) const; + /// particular component group, including its components. Any + /// added macros will be emitted via macrosOut. + std::string + CreateComponentGroupDescription(cmCPackComponentGroup *group, + cmOStringStream& macrosOut); /// Translations any newlines found in the string into \r\n, so that the /// resulting string can be used within NSIS. diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 04b7899..a156971 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -580,7 +580,10 @@ WriteDistributionFile(const char* metapackageFile) groupIt != this->ComponentGroups.end(); ++groupIt) { - CreateChoiceOutline(groupIt->second, choiceOut); + if (groupIt->second.ParentGroup == 0) + { + CreateChoiceOutline(groupIt->second, choiceOut); + } } // Emit the outline for the non-grouped components @@ -622,6 +625,13 @@ cmCPackPackageMakerGenerator:: CreateChoiceOutline(const cmCPackComponentGroup& group, cmOStringStream& out) { out << "<line choice=\"" << group.Name << "Choice\">" << std::endl; + std::vector<cmCPackComponentGroup*>::const_iterator groupIt; + for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end(); + ++groupIt) + { + CreateChoiceOutline(**groupIt, out); + } + std::vector<cmCPackComponent*>::const_iterator compIt; for (compIt = group.Components.begin(); compIt != group.Components.end(); ++compIt) diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 09e7068..02e21bd 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -49,6 +49,22 @@ bool cmGetCMakePropertyCommand { this->Makefile->GetListOfMacros(output); } + else if ( args[1] == "COMPONENTS" ) + { + const std::set<cmStdString>* components + = this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->GetInstallComponents(); + std::set<cmStdString>::const_iterator compIt; + output = ""; + for (compIt = components->begin(); compIt != components->end(); ++compIt) + { + if (compIt != components->begin()) + { + output += ";"; + } + output += *compIt; + } + } else { const char *prop = diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index c1f66d9..b3cb442 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -62,7 +62,8 @@ public: "Get a property from the CMake instance. The value of the " "property is stored in the variable VAR. If the property is " "not found, CMake will report an error. Some supported properties " - "include: VARIABLES, CACHE_VARIABLES, COMMANDS, and MACROS."; + "include: VARIABLES, CACHE_VARIABLES, COMMANDS, MACROS, and " + "COMPONENTS."; } cmTypeMacro(cmGetCMakePropertyCommand, cmCommand); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 2865a38..a76890b 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -139,6 +139,9 @@ public: void AddInstallComponent(const char* component); + const std::set<cmStdString>* GetInstallComponents() const + { return &InstallComponents; } + ///! Add one installed target to the sets of the exports void AddTargetToExports(const char* exportSet, cmTarget* target, cmInstallTargetGenerator* archive, diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 6ce7ae5..eb162f5 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -384,6 +384,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } + // Keep track of whether we will be performing an installation of + // any files of the given type. + bool installsArchive = false; + bool installsLibrary = false; + bool installsRuntime = false; + bool installsFramework = false; + bool installsBundle = false; + bool installsPrivateHeader = false; + bool installsPublicHeader = false; + bool installsResource = false; + // Generate install script code to install the given targets. for(std::vector<cmTarget*>::iterator ti = targets.begin(); ti != targets.end(); ++ti) @@ -691,6 +702,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } + // Keep track of whether we're installing anything in each category + installsArchive = installsArchive || archiveGenerator != 0; + installsLibrary = installsLibrary || libraryGenerator != 0; + installsRuntime = installsRuntime || runtimeGenerator != 0; + installsFramework = installsFramework || frameworkGenerator != 0; + installsBundle = installsBundle || bundleGenerator != 0; + installsPrivateHeader = installsPrivateHeader || privateHeaderGenerator != 0; + installsPublicHeader = installsPublicHeader || publicHeaderGenerator != 0; + installsResource = installsResource || resourceGenerator; + this->Makefile->AddInstallGenerator(archiveGenerator); this->Makefile->AddInstallGenerator(libraryGenerator); this->Makefile->AddInstallGenerator(runtimeGenerator); @@ -713,22 +734,46 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } // Tell the global generator about any installation component names specified - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(archiveArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(libraryArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(runtimeArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(frameworkArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(bundleArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(resourceArgs.GetComponent().c_str()); + if (installsArchive) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(archiveArgs.GetComponent().c_str()); + } + if (installsLibrary) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(libraryArgs.GetComponent().c_str()); + } + if (installsRuntime) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(runtimeArgs.GetComponent().c_str()); + } + if (installsFramework) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(frameworkArgs.GetComponent().c_str()); + } + if (installsBundle) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(bundleArgs.GetComponent().c_str()); + } + if (installsPrivateHeader) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str()); + } + if (installsPublicHeader) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str()); + } + if (installsResource) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(resourceArgs.GetComponent().c_str()); + } return true; } diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 36e7e25..a352244 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -59,6 +59,9 @@ bool cmInstallFilesCommand } } + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent("Unspecified"); + return true; } @@ -126,7 +129,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = ""; + const char* no_component = "Unspecified"; std::vector<std::string> no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 6a55f17..d7557d0 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -38,6 +38,9 @@ bool cmInstallProgramsCommand this->FinalArgs.push_back(*s); } + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent("Unspecified"); + return true; } @@ -87,7 +90,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = ""; + const char* no_component = "Unspecified"; std::vector<std::string> no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 61357b3..cd4d6e5 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -31,7 +31,7 @@ public: const char* file_permissions = "", std::vector<std::string> const& configurations = std::vector<std::string>(), - const char* component = "", + const char* component = "Unspecified", bool optional = false ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index d3ecddf..cfcdc0c 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -62,6 +62,9 @@ bool cmInstallTargetsCommand } } + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent("Unspecified"); + return true; } |