diff options
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 168 | ||||
-rw-r--r-- | Source/cmInstallCommand.h | 5 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmInstallExportGenerator.h | 11 |
6 files changed, 177 insertions, 51 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ac69843..a62a5c3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1081,12 +1081,13 @@ void cmGlobalGenerator::AddTargetToExports(const char* exportSetName, cmInstallTargetGenerator* runTime, cmInstallTargetGenerator* library, cmInstallTargetGenerator* framework, - cmInstallTargetGenerator* bundle) + cmInstallTargetGenerator* bundle, + cmInstallFilesGenerator* headers) { if ((exportSetName) && (*exportSetName) && (target)) { cmTargetExport* te = new cmTargetExport(target, archive, runTime, library, - framework, bundle); + framework, bundle, headers); this->ExportSets[exportSetName].push_back(te); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 6b8e53e..c0996b6 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -29,6 +29,7 @@ class cmExternalMakefileProjectGenerator; class cmTarget; class cmTargetExport; class cmInstallTargetGenerator; +class cmInstallFilesGenerator; /** \class cmGlobalGenerator * \brief Responable for overseeing the generation process for the entire tree @@ -144,7 +145,8 @@ public: cmInstallTargetGenerator* runTime, cmInstallTargetGenerator* library, cmInstallTargetGenerator* framework, - cmInstallTargetGenerator* bundle); + cmInstallTargetGenerator* bundle, + cmInstallFilesGenerator* publicHeaders); ///! Get the export target set with the given name const std::vector<cmTargetExport*>* GetExportSet(const char* name) const; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c2ed512..bee6f50 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -167,7 +167,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmCAStringVector frameworkArgVector (&argHelper, "FRAMEWORK", &group); cmCAStringVector bundleArgVector (&argHelper, "BUNDLE", &group); cmCAStringVector resourcesArgVector (&argHelper, "RESOURCE", &group); - cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER ", &group); + cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group); cmCAStringVector privateHeaderArgVector(&argHelper,"PRIVATE_HEADER", &group); genericArgVector.Follows(0); group.Follows(&genericArgVector); @@ -200,7 +200,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) resourcesArgs.Parse (&resourcesArgVector.GetVector(), &unknownArgs); publicHeaderArgs.Parse (&publicHeaderArgVector.GetVector(), &unknownArgs); privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs); - + if(!unknownArgs.empty()) { // Unknown argument. @@ -290,9 +290,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmInstallTargetGenerator* runtimeGenerator = 0; cmInstallTargetGenerator* frameworkGenerator = 0; cmInstallTargetGenerator* bundleGenerator = 0; - cmInstallTargetGenerator* resourcesGenerator = 0; - cmInstallTargetGenerator* publicHeaderGenerator = 0; - cmInstallTargetGenerator* privateHeaderGenerator = 0; + cmInstallFilesGenerator* resourcesGenerator = 0; + cmInstallFilesGenerator* publicHeaderGenerator = 0; + cmInstallFilesGenerator* privateHeaderGenerator = 0; switch(target.GetType()) { @@ -362,13 +362,6 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } } - -/* if(target.GetPropertyAsBool("FRAMEWORK")) - { - // Create the files install generator. - this->Makefile->AddInstallGenerator(CreateInstallFilesGenerator( - absFiles, publicHeaderArgs, false); - }*/ } break; case cmTarget::STATIC_LIBRARY: @@ -460,25 +453,106 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Ignore the case. break; } + +// if(target.GetProperty("ASSOCIATED_FILES"); + + const char* files = target.GetProperty("PUBLIC_HEADER"); + if ((files) && (*files)) + { + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + std::vector<std::string> absFiles; + if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) + { + return false; + } + + // Create the files install generator. + if (!publicHeaderArgs.GetDestination().empty()) + { + publicHeaderGenerator = CreateInstallFilesGenerator(absFiles, + publicHeaderArgs, false); + } + else + { + cmOStringStream e; + e << "TARGETS given no PUBLIC_HEADER DESTINATION for header files\"" + << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + + files = target.GetProperty("PRIVATE_HEADER"); + if ((files) && (*files)) + { + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + std::vector<std::string> absFiles; + if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) + { + return false; + } + + // Create the files install generator. + if (!privateHeaderArgs.GetDestination().empty()) + { + privateHeaderGenerator = CreateInstallFilesGenerator(absFiles, + privateHeaderArgs, false); + } + else + { + cmOStringStream e; + e << "TARGETS given no PRIVATE_HEADER DESTINATION for header files\"" + << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + + files = target.GetProperty("RESOURCE_FILES"); + if ((files) && (*files)) + { + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + std::vector<std::string> absFiles; + if (!this->MakeFilesFullPath("RESOURCE_FILES", relFiles, absFiles)) + { + return false; + } + + // Create the files install generator. + if (!privateHeaderArgs.GetDestination().empty()) + { + resourcesGenerator = CreateInstallFilesGenerator(absFiles, + resourcesArgs, false); + } + else + { + cmOStringStream e; + e << "TARGETS given no RESOURCES DESTINATION for resource files\"" + << target.GetName() << "\"."; + this->SetError(e.str().c_str()); + return false; + } + } + this->Makefile->AddInstallGenerator(archiveGenerator); this->Makefile->AddInstallGenerator(libraryGenerator); this->Makefile->AddInstallGenerator(runtimeGenerator); this->Makefile->AddInstallGenerator(frameworkGenerator); this->Makefile->AddInstallGenerator(bundleGenerator); - this->Makefile->AddInstallGenerator(resourcesGenerator); this->Makefile->AddInstallGenerator(publicHeaderGenerator); this->Makefile->AddInstallGenerator(privateHeaderGenerator); + this->Makefile->AddInstallGenerator(resourcesGenerator); if (!exports.GetString().empty()) { this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddTargetToExports(exports.GetCString(), - &target, - archiveGenerator, - runtimeGenerator, - libraryGenerator, - frameworkGenerator, - bundleGenerator); + ->AddTargetToExports(exports.GetCString(), &target, + archiveGenerator, runtimeGenerator, + libraryGenerator, frameworkGenerator, + bundleGenerator, publicHeaderGenerator); } } @@ -540,29 +614,9 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) } std::vector<std::string> absFiles; - for(std::vector<std::string>::const_iterator - fileIt = files.GetVector().begin(); fileIt != files.GetVector().end(); - ++fileIt) + if (!this->MakeFilesFullPath(args[0].c_str(), files.GetVector(), absFiles)) { - // Convert this file to a full path. - std::string file = *fileIt; - if(!cmSystemTools::FileIsFullPath(file.c_str())) - { - file = this->Makefile->GetCurrentDirectory(); - file += "/"; - file += *fileIt; - } - - // Make sure the file is not a directory. - if(cmSystemTools::FileIsDirectory(file.c_str())) - { - cmOStringStream e; - e << args[0] << " given directory \"" << (*fileIt) << "\" to install."; - this->SetError(e.str().c_str()); - return false; - } - // Store the file for installation. - absFiles.push_back(file); + return false; } if (!ica.Finalize()) @@ -1011,3 +1065,33 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) return true; } + +bool cmInstallCommand::MakeFilesFullPath(const char* modeName, + const std::vector<std::string>& relFiles, + std::vector<std::string>& absFiles) +{ + for(std::vector<std::string>::const_iterator fileIt = relFiles.begin(); + fileIt != relFiles.end(); + ++fileIt) + { + std::string file = (*fileIt); + if(!cmSystemTools::FileIsFullPath(file.c_str())) + { + file = this->Makefile->GetCurrentDirectory(); + file += "/"; + file += *fileIt; + } + + // Make sure the file is not a directory. + if(cmSystemTools::FileIsDirectory(file.c_str())) + { + cmOStringStream e; + e << modeName << " given directory \"" << (*fileIt) << "\" to install."; + this->SetError(e.str().c_str()); + return false; + } + // Store the file for installation. + absFiles.push_back(file); + } + return true; +} diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index b0e9ff7..7afa866 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -252,8 +252,9 @@ private: bool HandleFilesMode(std::vector<std::string> const& args); bool HandleDirectoryMode(std::vector<std::string> const& args); bool HandleExportMode(std::vector<std::string> const& args); - void ComputeDestination(const char* destination, std::string& dest) const; - bool CheckPermissions(std::string const& arg, std::string& permissions)const; + bool MakeFilesFullPath(const char* modeName, + const std::vector<std::string>& relFiles, + std::vector<std::string>& absFiles); }; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index a61a8c0..e0ff82c 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -22,6 +22,7 @@ #include "cmTarget.h" #include "cmInstallExportGenerator.h" +#include "cmInstallFilesGenerator.h" cmInstallExportGenerator::cmInstallExportGenerator( const char* destination, @@ -60,7 +61,7 @@ bool cmInstallExportGenerator::AddInstallLocations(cmTargetWithProperties* twp, std::string propertyName = prefix; propertyName += "LOCATION"; // check that this property doesn't exist yet and add it then - if (twp->Properties.find(propertyName.c_str())== twp->Properties.end()) + if (twp->Properties.find(propertyName.c_str()) == twp->Properties.end()) { std::string destinationFilename = generator->GetDestination(); destinationFilename += "/"; @@ -83,7 +84,7 @@ bool cmInstallExportGenerator::AddInstallLocations(cmTargetWithProperties* twp, propertyName += prefix; propertyName += "LOCATION"; // check that this property doesn't exist yet and add it then - if (twp->Properties.find(propertyName.c_str())== twp->Properties.end()) + if (twp->Properties.find(propertyName.c_str()) == twp->Properties.end()) { std::string destinationFilename = generator->GetDestination(); destinationFilename += "/"; @@ -100,6 +101,31 @@ bool cmInstallExportGenerator::AddInstallLocations(cmTargetWithProperties* twp, } +bool cmInstallExportGenerator::AddInstallLocations(cmTargetWithProperties* twp, + cmInstallFilesGenerator* generator, + const char* propertyName) +{ + if (generator == 0) // nothing to do + { + return true; + } + + if ((propertyName == 0) || (*propertyName == '\0')) + { + return false; + } + + // check that this property doesn't exist yet and add it then + if (twp->Properties.find(propertyName) == twp->Properties.end()) + { + twp->Properties[propertyName] = generator->GetDestination(); + return true; + } + + return false; +} + + bool cmInstallExportGenerator::SetExportSet(const char* name, const std::vector<cmTargetExport*>* set) { @@ -152,6 +178,11 @@ bool cmInstallExportGenerator::SetExportSet(const char* name, { return false; } + if (this->AddInstallLocations(targetWithProps, (*it)->HeaderGenerator, + "PUBLIC_HEADER_LOCATION") == false) + { + return false; + } } return true; diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 0559872..ee0ae3e 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -23,6 +23,7 @@ class cmTarget; class cmInstallTargetGenerator; +class cmInstallFilesGenerator; /* cmInstallExportTarget is used in cmGlobalGenerator to collect the install generators for the exported targets. These are then used by the @@ -36,10 +37,12 @@ public: cmInstallTargetGenerator* runtime, cmInstallTargetGenerator* library, cmInstallTargetGenerator* framework, - cmInstallTargetGenerator* bundle + cmInstallTargetGenerator* bundle, + cmInstallFilesGenerator* headers ) : Target(tgt), ArchiveGenerator(archive), RuntimeGenerator(runtime), LibraryGenerator(library), - FrameworkGenerator(framework), BundleGenerator(bundle) {} + FrameworkGenerator(framework), BundleGenerator(bundle), + HeaderGenerator(headers) {} cmTarget* Target; cmInstallTargetGenerator* ArchiveGenerator; @@ -47,6 +50,7 @@ public: cmInstallTargetGenerator* LibraryGenerator; cmInstallTargetGenerator* FrameworkGenerator; cmInstallTargetGenerator* BundleGenerator; + cmInstallFilesGenerator* HeaderGenerator; private: cmTargetExport(); }; @@ -85,6 +89,9 @@ protected: static bool AddInstallLocations(cmTargetWithProperties *twp, cmInstallTargetGenerator* generator, const char* prefix); + static bool AddInstallLocations(cmTargetWithProperties* twp, + cmInstallFilesGenerator* generator, + const char* propertyName); std::string Name; std::string FilePermissions; |