BUG: Fix computed directory property DEFINITIONS.
- The property tracks the value formed by add_definitions and remove_definitions command invocations. - The string should be maintained for use in returning for the DEFINITIONS property value. - It is no longer used for any other purpose. - The DEFINITIONS property was recently documented as deprecated. - See bug #7239.
This commit is contained in:
parent
c59603f48e
commit
b9b11903ab
|
@ -1018,12 +1018,21 @@ void cmMakefile::AddDefineFlag(const char* flag)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the string used for the old DEFINITIONS property.
|
||||||
|
this->AddDefineFlag(flag, this->DefineFlagsOrig);
|
||||||
|
|
||||||
// If this is really a definition, update COMPILE_DEFINITIONS.
|
// If this is really a definition, update COMPILE_DEFINITIONS.
|
||||||
if(this->ParseDefineFlag(flag, false))
|
if(this->ParseDefineFlag(flag, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add this flag that does not look like a definition.
|
||||||
|
this->AddDefineFlag(flag, this->DefineFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags)
|
||||||
|
{
|
||||||
// remove any \n\r
|
// remove any \n\r
|
||||||
std::string ret = flag;
|
std::string ret = flag;
|
||||||
std::string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
|
@ -1039,8 +1048,8 @@ void cmMakefile::AddDefineFlag(const char* flag)
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->DefineFlags += " ";
|
dflags += " ";
|
||||||
this->DefineFlags += ret;
|
dflags += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1053,22 +1062,33 @@ void cmMakefile::RemoveDefineFlag(const char* flag)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the string used for the old DEFINITIONS property.
|
||||||
|
this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig);
|
||||||
|
|
||||||
// If this is really a definition, update COMPILE_DEFINITIONS.
|
// If this is really a definition, update COMPILE_DEFINITIONS.
|
||||||
if(this->ParseDefineFlag(flag, true))
|
if(this->ParseDefineFlag(flag, true))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove this flag that does not look like a definition.
|
||||||
|
this->RemoveDefineFlag(flag, len, this->DefineFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmMakefile::RemoveDefineFlag(const char* flag,
|
||||||
|
std::string::size_type len,
|
||||||
|
std::string& dflags)
|
||||||
|
{
|
||||||
// Remove all instances of the flag that are surrounded by
|
// Remove all instances of the flag that are surrounded by
|
||||||
// whitespace or the beginning/end of the string.
|
// whitespace or the beginning/end of the string.
|
||||||
for(std::string::size_type lpos = this->DefineFlags.find(flag, 0);
|
for(std::string::size_type lpos = dflags.find(flag, 0);
|
||||||
lpos != std::string::npos; lpos = this->DefineFlags.find(flag, lpos))
|
lpos != std::string::npos; lpos = dflags.find(flag, lpos))
|
||||||
{
|
{
|
||||||
std::string::size_type rpos = lpos + len;
|
std::string::size_type rpos = lpos + len;
|
||||||
if((lpos <= 0 || isspace(this->DefineFlags[lpos-1])) &&
|
if((lpos <= 0 || isspace(dflags[lpos-1])) &&
|
||||||
(rpos >= this->DefineFlags.size() || isspace(this->DefineFlags[rpos])))
|
(rpos >= dflags.size() || isspace(dflags[rpos])))
|
||||||
{
|
{
|
||||||
this->DefineFlags.erase(lpos, len);
|
dflags.erase(lpos, len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2957,20 +2977,7 @@ const char *cmMakefile::GetProperty(const char* prop,
|
||||||
}
|
}
|
||||||
else if (!strcmp("DEFINITIONS",prop))
|
else if (!strcmp("DEFINITIONS",prop))
|
||||||
{
|
{
|
||||||
if(const char* cdefs = this->GetProperty("COMPILE_DEFINITIONS"))
|
output += this->DefineFlagsOrig;
|
||||||
{
|
|
||||||
// Expand the list.
|
|
||||||
std::vector<std::string> defs;
|
|
||||||
cmSystemTools::ExpandListArgument(cdefs, defs);
|
|
||||||
for(std::vector<std::string>::iterator i = defs.begin();
|
|
||||||
i != defs.end(); ++i)
|
|
||||||
{
|
|
||||||
output += "-D";
|
|
||||||
output += *i;
|
|
||||||
output += " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output += this->GetDefineFlags();
|
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
else if (!strcmp("INCLUDE_DIRECTORIES",prop) )
|
else if (!strcmp("INCLUDE_DIRECTORIES",prop) )
|
||||||
|
|
|
@ -829,6 +829,11 @@ protected:
|
||||||
std::vector<std::string> HeaderFileExtensions;
|
std::vector<std::string> HeaderFileExtensions;
|
||||||
std::string DefineFlags;
|
std::string DefineFlags;
|
||||||
|
|
||||||
|
// Track the value of the computed DEFINITIONS property.
|
||||||
|
void AddDefineFlag(const char*, std::string&);
|
||||||
|
void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
|
||||||
|
std::string DefineFlagsOrig;
|
||||||
|
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
std::vector<cmSourceGroup> SourceGroups;
|
std::vector<cmSourceGroup> SourceGroups;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue