cmCPackGenerator::SetOption accepts cmProp or std::string

This commit is contained in:
Marc Chevrier
2021-09-14 18:41:44 +02:00
parent 1375862764
commit 7aeb262278
2 changed files with 41 additions and 4 deletions
+25 -4
View File
@@ -994,17 +994,29 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName)
return retval; return retval;
} }
void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, template <typename ValueType>
const char* value) void cmCPackGenerator::StoreOptionIfNotSet(const std::string& op,
ValueType value)
{ {
cmProp def = this->MakefileMap->GetDefinition(op); cmProp def = this->MakefileMap->GetDefinition(op);
if (cmNonempty(def)) { if (cmNonempty(def)) {
return; return;
} }
this->SetOption(op, value); this->StoreOption(op, value);
} }
void cmCPackGenerator::SetOption(const std::string& op, const char* value) void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
const char* value)
{
this->StoreOptionIfNotSet(op, value);
}
void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, cmProp value)
{
this->StoreOptionIfNotSet(op, value);
}
template <typename ValueType>
void cmCPackGenerator::StoreOption(const std::string& op, ValueType value)
{ {
if (!value) { if (!value) {
this->MakefileMap->RemoveDefinition(op); this->MakefileMap->RemoveDefinition(op);
@@ -1016,6 +1028,15 @@ void cmCPackGenerator::SetOption(const std::string& op, const char* value)
this->MakefileMap->AddDefinition(op, value); this->MakefileMap->AddDefinition(op, value);
} }
void cmCPackGenerator::SetOption(const std::string& op, const char* value)
{
this->StoreOption(op, value);
}
void cmCPackGenerator::SetOption(const std::string& op, cmProp value)
{
this->StoreOption(op, value);
}
int cmCPackGenerator::DoPackage() int cmCPackGenerator::DoPackage()
{ {
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+16
View File
@@ -85,7 +85,17 @@ public:
//! Set and get the options //! Set and get the options
void SetOption(const std::string& op, const char* value); void SetOption(const std::string& op, const char* value);
void SetOption(const std::string& op, const std::string& value)
{
this->SetOption(op, cmProp(value));
}
void SetOption(const std::string& op, cmProp value);
void SetOptionIfNotSet(const std::string& op, const char* value); void SetOptionIfNotSet(const std::string& op, const char* value);
void SetOptionIfNotSet(const std::string& op, const std::string& value)
{
this->SetOptionIfNotSet(op, cmProp(value));
}
void SetOptionIfNotSet(const std::string& op, cmProp value);
cmProp GetOption(const std::string& op) const; cmProp GetOption(const std::string& op) const;
std::vector<std::string> GetOptions() const; std::vector<std::string> GetOptions() const;
bool IsSet(const std::string& name) const; bool IsSet(const std::string& name) const;
@@ -324,6 +334,12 @@ protected:
bool TraceExpand; bool TraceExpand;
cmMakefile* MakefileMap; cmMakefile* MakefileMap;
private:
template <typename ValueType>
void StoreOption(const std::string& op, ValueType value);
template <typename ValueType>
void StoreOptionIfNotSet(const std::string& op, ValueType value);
}; };
#define cmCPackTypeMacro(klass, superclass) \ #define cmCPackTypeMacro(klass, superclass) \