[cmake-commits] king committed cmFileCommand.cxx 1.89 1.90 cmInstallCommand.cxx 1.37 1.38 cmInstallCommand.h 1.22 1.23

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Jan 2 15:17:58 EST 2008


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv23335/Source

Modified Files:
	cmFileCommand.cxx cmInstallCommand.cxx cmInstallCommand.h 
Log Message:
ENH: Added FILES_MATCHING option to INSTALL(DIRECTORY).  This will help install a tree of header files while ignoring non-headers.


Index: cmInstallCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.cxx,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- cmInstallCommand.cxx	17 Dec 2007 20:20:06 -0000	1.37
+++ cmInstallCommand.cxx	2 Jan 2008 20:17:56 -0000	1.38
@@ -871,6 +871,29 @@
       doing_component = false;
       literal_args += " USE_SOURCE_PERMISSIONS";
       }
+    else if(args[i] == "FILES_MATCHING")
+      {
+      if(in_match_mode)
+        {
+        cmOStringStream e;
+        e << args[0] << " does not allow \""
+          << args[i] << "\" after PATTERN or REGEX.";
+        this->SetError(e.str().c_str());
+        return false;
+        }
+
+      // Add this option literally.
+      doing_dirs = false;
+      doing_destination = false;
+      doing_pattern = false;
+      doing_regex = false;
+      doing_permissions_file = false;
+      doing_permissions_dir = false;
+      doing_permissions_match = false;
+      doing_configurations = false;
+      doing_component = false;
+      literal_args += " FILES_MATCHING";
+      }
     else if(args[i] == "CONFIGURATIONS")
       {
       if(in_match_mode)

Index: cmInstallCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmInstallCommand.h	10 Oct 2007 15:47:43 -0000	1.22
+++ cmInstallCommand.h	2 Jan 2008 20:17:56 -0000	1.23
@@ -178,7 +178,7 @@
       "          [DIRECTORY_PERMISSIONS permissions...]\n"
       "          [USE_SOURCE_PERMISSIONS]\n"
       "          [CONFIGURATIONS [Debug|Release|...]]\n"
-      "          [COMPONENT <component>]\n"
+      "          [COMPONENT <component>] [FILES_MATCHING]\n"
       "          [[PATTERN <pattern> | REGEX <regex>]\n"
       "           [EXCLUDE] [PERMISSIONS permissions...]] [...])\n"
       "The DIRECTORY form installs contents of one or more directories "
@@ -198,18 +198,31 @@
       "If no permissions are specified files will be given the default "
       "permissions specified in the FILES form of the command, and the "
       "directories will be given the default permissions specified in the "
-      "PROGRAMS form of the command.  "
-      "The PATTERN and REGEX options specify a globbing pattern or regular "
-      "expression to match directories or files encountered during traversal "
-      "of an input directory.  The full path to an input file or directory "
+      "PROGRAMS form of the command.\n"
+
+      "Installation of directories may be controlled with fine granularity "
+      "using the PATTERN or REGEX options.  These \"match\" options specify a "
+      "globbing pattern or regular expression to match directories or files "
+      "encountered within input directories.  They may be used to apply "
+      "certain options (see below) to a subset of the files and directories "
+      "encountered.  "
+      "The full path to each input file or directory "
       "(with forward slashes) is matched against the expression.  "
       "A PATTERN will match only complete file names: the portion of the "
       "full path matching the pattern must occur at the end of the file name "
       "and be preceded by a slash.  "
       "A REGEX will match any portion of the full path but it may use "
       "'/' and '$' to simulate the PATTERN behavior.  "
-      "Options following one of these matching expressions "
-      "are applied only to files or directories matching them.  "
+      "By default all files and directories are installed whether "
+      "or not they are matched.  "
+      "The FILES_MATCHING option may be given before the first match option "
+      "to disable installation of files (but not directories) not matched by "
+      "any expression.  For example, the code\n"
+      "  install(DIRECTORY src/ DESTINATION include/myproj\n"
+      "          FILES_MATCHING PATTERN \"*.h\")\n"
+      "will extract and install header files from a source tree.\n"
+      "Some options may follow a PATTERN or REGEX expression and are "
+      "applied only to files or directories matching them.  "
       "The EXCLUDE option will skip the matched file or directory.  "
       "The PERMISSIONS option overrides the permissions setting for the "
       "matched file or directory.  "

Index: cmFileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFileCommand.cxx,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- cmFileCommand.cxx	5 Oct 2007 13:46:28 -0000	1.89
+++ cmFileCommand.cxx	2 Jan 2008 20:17:56 -0000	1.90
@@ -702,7 +702,7 @@
 
   // 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 @@
   // 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 @@
   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 @@
 #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 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 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 @@
         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;



More information about the Cmake-commits mailing list