Browse Source

install: Fix COMPONENT option

Since commit 7ced0732 (make default install component name configurable,
2012-05-13) the COMPONENT option has not worked in all cases.  The
change restored use of the broken SetDefaultString previously removed by
commit 43cad3e4 (fix the default "Unspecified" component, 2008-03-26).

Remove SetDefaultString and use the default component name only when an
invocation does not specify a non-empty COMPONENT option value.

Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680825
Brad King 13 years ago
parent
commit
8720aa0496

+ 1 - 1
Source/cmCommandArgumentsHelper.cxx

@@ -178,7 +178,7 @@ bool cmCAString::DoConsume(const std::string& arg, unsigned int index)
 
 void cmCAString::DoReset()
 {
-  this->String = this->DefaultString;
+  this->String = "";
 }
 
 cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args, 

+ 0 - 3
Source/cmCommandArgumentsHelper.h

@@ -125,11 +125,8 @@ class cmCAString : public cmCommandArgument
     /// Return the string
     const std::string& GetString() const                 {return this->String;}
     const char* GetCString() const               {return this->String.c_str();}
-    void SetDefaultString(const char* text)
-                                    {this->DefaultString = (text ? text : "");}
   private:
     std::string String;
-    std::string DefaultString;
     unsigned int DataStart;
     virtual bool DoConsume(const std::string& arg, unsigned int index);
     virtual void DoReset();

+ 5 - 2
Source/cmInstallCommandArguments.cxx

@@ -36,8 +36,8 @@ cmInstallCommandArguments::cmInstallCommandArguments(
 ,NamelinkOnly  (&Parser, "NAMELINK_ONLY" , &ArgumentGroup)
 ,NamelinkSkip  (&Parser, "NAMELINK_SKIP" , &ArgumentGroup)
 ,GenericArguments(0)
+,DefaultComponentName(defaultComponent)
 {
-  this->Component.SetDefaultString(defaultComponent.c_str());
 }
 
 const std::string& cmInstallCommandArguments::GetDestination() const
@@ -63,7 +63,10 @@ const std::string& cmInstallCommandArguments::GetComponent() const
     {
     return this->GenericArguments->GetComponent();
     }
-
+  if (!this->DefaultComponentName.empty())
+    {
+    return this->DefaultComponentName;
+    }
   static std::string unspecifiedComponent = "Unspecified";
   return unspecifiedComponent;
 }

+ 1 - 0
Source/cmInstallCommandArguments.h

@@ -61,6 +61,7 @@ class cmInstallCommandArguments
     cmInstallCommandArguments* GenericArguments;
     static const char* PermissionsTable[];
     static const std::string EmptyString;
+    std::string DefaultComponentName;
     bool CheckPermissions();
 };