mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 21:30:01 -05:00
ENH: Allow specifying cmake variables on the command line without specifying the type Bug #118 - Specifying cache entries with -D should not need the type
This commit is contained in:
@@ -79,6 +79,42 @@ bool cmCacheManager::LoadCache(const char* path,
|
||||
return this->LoadCache(path, internal, emptySet, emptySet);
|
||||
}
|
||||
|
||||
bool cmCacheManager::ParseEntry(const char* entry,
|
||||
std::string& var,
|
||||
std::string& value)
|
||||
{
|
||||
// input line is: key:type=value
|
||||
cmsys::RegularExpression reg("^([^:]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
|
||||
// input line is: "key":type=value
|
||||
cmsys::RegularExpression regQuoted("^\"([^\"]*)\"=(.*[^\t ]|[\t ]*)[\t ]*$");
|
||||
bool flag = false;
|
||||
if(regQuoted.find(entry))
|
||||
{
|
||||
var = regQuoted.match(1);
|
||||
value = regQuoted.match(2);
|
||||
flag = true;
|
||||
}
|
||||
else if (reg.find(entry))
|
||||
{
|
||||
var = reg.match(1);
|
||||
value = reg.match(2);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
// if value is enclosed in single quotes ('foo') then remove them
|
||||
// it is used to enclose trailing space or tab
|
||||
if (flag &&
|
||||
value.size() >= 2 &&
|
||||
value[0] == '\'' &&
|
||||
value[value.size() - 1] == '\'')
|
||||
{
|
||||
value = value.substr(1,
|
||||
value.size() - 2);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
bool cmCacheManager::ParseEntry(const char* entry,
|
||||
std::string& var,
|
||||
std::string& value,
|
||||
|
||||
Reference in New Issue
Block a user