diff options
author | Brad King <brad.king@kitware.com> | 2008-01-02 20:17:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-02 20:17:56 (GMT) |
commit | 60bf0531b01b641a00f6844dfd38ef803d2deda1 (patch) | |
tree | 1f39b207ca36da6e19b1ae0363836517b3e663bd /Source/cmFileCommand.cxx | |
parent | 509764067136026cfab21e7eb83c9f03ddc1c96a (diff) | |
download | CMake-60bf0531b01b641a00f6844dfd38ef803d2deda1.zip CMake-60bf0531b01b641a00f6844dfd38ef803d2deda1.tar.gz CMake-60bf0531b01b641a00f6844dfd38ef803d2deda1.tar.bz2 |
ENH: Added FILES_MATCHING option to INSTALL(DIRECTORY). This will help install a tree of header files while ignoring non-headers.
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r-- | Source/cmFileCommand.cxx | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 3a31a3f..092dfb1 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -702,7 +702,7 @@ struct cmFileInstaller // All instances need the file command and makefile using them. cmFileInstaller(cmFileCommand* fc, cmMakefile* mf): - FileCommand(fc), Makefile(mf), DestDirLength(0) + FileCommand(fc), Makefile(mf), DestDirLength(0), MatchlessFiles(true) { // Get the current manifest. this->Manifest = @@ -724,6 +724,9 @@ public: // The length of the destdir setting. int DestDirLength; + // Whether to install a file not matching any expression. + bool MatchlessFiles; + // The current file manifest (semicolon separated list). std::string Manifest; @@ -749,7 +752,8 @@ public: std::vector<MatchRule> MatchRules; // Get the properties from rules matching this input file. - MatchProperties CollectMatchProperties(const char* file) + MatchProperties CollectMatchProperties(const char* file, + bool isDirectory) { // Match rules are case-insensitive on some platforms. #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__) @@ -758,16 +762,22 @@ public: #endif // Collect properties from all matching rules. + bool matched = false; MatchProperties result; for(std::vector<MatchRule>::iterator mr = this->MatchRules.begin(); mr != this->MatchRules.end(); ++mr) { if(mr->Regex.find(file)) { + matched = true; result.Exclude |= mr->Properties.Exclude; result.Permissions |= mr->Properties.Permissions; } } + if(!matched && !this->MatchlessFiles && !isDirectory) + { + result.Exclude = true; + } return result; } @@ -868,7 +878,8 @@ bool cmFileInstaller::InstallFile(const char* fromFile, const char* toFile, bool always) { // Collect any properties matching this file name. - MatchProperties match_properties = this->CollectMatchProperties(fromFile); + MatchProperties match_properties = + this->CollectMatchProperties(fromFile, false); // Skip the file if it is excluded. if(match_properties.Exclude) @@ -946,7 +957,8 @@ bool cmFileInstaller::InstallDirectory(const char* source, bool always) { // Collect any properties matching this directory name. - MatchProperties match_properties = this->CollectMatchProperties(source); + MatchProperties match_properties = + this->CollectMatchProperties(source, true); // Skip the directory if it is excluded. if(match_properties.Exclude) @@ -1463,6 +1475,22 @@ bool cmFileCommand::ParseInstallArgs(std::vector<std::string> const& args, doing_permissions_dir = false; use_source_permissions = true; } + else if ( *cstr == "FILES_MATCHING" ) + { + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } + + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + installer.MatchlessFiles = false; + } else if ( *cstr == "COMPONENTS" ) { cmOStringStream e; |