Merge topic 'refactor-cmMakefile-properties'
bbb507ae
cmMakefile: Move the InitializeFromParent method6ed9c7e0
cmState: Host buildsystem properties for directories.8f0a5d84
cmState: Fix compilation on IBM XL compiler9644a2d1
cmAlgorithms: Add cmMakeReverseIterator.1e77de74
cmMakefile: Don't clear buildsystem properties.c1bf1a59
CompileDefinitions: Add unit test for setting empty content.
This commit is contained in:
commit
d74abbea89
|
@ -363,4 +363,10 @@ cmReverseRange(Range const& range)
|
|||
range.rbegin(), range.rend());
|
||||
}
|
||||
|
||||
template <class Iter>
|
||||
std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
|
||||
{
|
||||
return std::reverse_iterator<Iter>(it);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -275,32 +275,34 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
|
|||
|
||||
cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
|
||||
{
|
||||
return cmMakeRange(this->IncludeDirectoriesEntries);
|
||||
return this->StateSnapshot.GetDirectory().GetIncludeDirectoriesEntries();
|
||||
}
|
||||
|
||||
cmBacktraceRange cmMakefile::GetIncludeDirectoriesBacktraces() const
|
||||
{
|
||||
return cmMakeRange(this->IncludeDirectoriesEntryBacktraces);
|
||||
return this->StateSnapshot.GetDirectory()
|
||||
.GetIncludeDirectoriesEntryBacktraces();
|
||||
}
|
||||
|
||||
cmStringRange cmMakefile::GetCompileOptionsEntries() const
|
||||
{
|
||||
return cmMakeRange(this->CompileOptionsEntries);
|
||||
return this->StateSnapshot.GetDirectory().GetCompileOptionsEntries();
|
||||
}
|
||||
|
||||
cmBacktraceRange cmMakefile::GetCompileOptionsBacktraces() const
|
||||
{
|
||||
return cmMakeRange(this->CompileOptionsEntryBacktraces);
|
||||
return this->StateSnapshot.GetDirectory().GetCompileOptionsEntryBacktraces();
|
||||
}
|
||||
|
||||
cmStringRange cmMakefile::GetCompileDefinitionsEntries() const
|
||||
{
|
||||
return cmMakeRange(this->CompileDefinitionsEntries);
|
||||
return this->StateSnapshot.GetDirectory().GetCompileDefinitionsEntries();
|
||||
}
|
||||
|
||||
cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const
|
||||
{
|
||||
return cmMakeRange(this->CompileDefinitionsEntryBacktraces);
|
||||
return this->StateSnapshot.GetDirectory()
|
||||
.GetCompileDefinitionsEntryBacktraces();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -1552,38 +1554,13 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
|||
// Initialize definitions with the closure of the parent scope.
|
||||
this->Internal->InitializeDefinitions(parent);
|
||||
|
||||
this->StateSnapshot.InitializeFromParent();
|
||||
|
||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
||||
this->GetCurrentSourceDirectory());
|
||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
|
||||
this->GetCurrentBinaryDirectory());
|
||||
|
||||
this->IncludeDirectoriesEntries.insert(
|
||||
this->IncludeDirectoriesEntries.end(),
|
||||
parent->IncludeDirectoriesEntries.begin(),
|
||||
parent->IncludeDirectoriesEntries.end());
|
||||
this->IncludeDirectoriesEntryBacktraces.insert(
|
||||
this->IncludeDirectoriesEntryBacktraces.end(),
|
||||
parent->IncludeDirectoriesEntryBacktraces.begin(),
|
||||
parent->IncludeDirectoriesEntryBacktraces.end());
|
||||
|
||||
this->CompileOptionsEntries.insert(
|
||||
this->CompileOptionsEntries.end(),
|
||||
parent->CompileOptionsEntries.begin(),
|
||||
parent->CompileOptionsEntries.end());
|
||||
this->CompileOptionsEntryBacktraces.insert(
|
||||
this->CompileOptionsEntryBacktraces.end(),
|
||||
parent->CompileOptionsEntryBacktraces.begin(),
|
||||
parent->CompileOptionsEntryBacktraces.end());
|
||||
|
||||
this->CompileDefinitionsEntries.insert(
|
||||
this->CompileDefinitionsEntries.end(),
|
||||
parent->CompileDefinitionsEntries.begin(),
|
||||
parent->CompileDefinitionsEntries.end());
|
||||
this->CompileDefinitionsEntryBacktraces.insert(
|
||||
this->CompileDefinitionsEntryBacktraces.end(),
|
||||
parent->CompileDefinitionsEntryBacktraces.begin(),
|
||||
parent->CompileDefinitionsEntryBacktraces.end());
|
||||
|
||||
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
||||
|
||||
// define flags
|
||||
|
@ -1926,17 +1903,18 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
|
|||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string>::iterator position =
|
||||
before ? this->IncludeDirectoriesEntries.begin()
|
||||
: this->IncludeDirectoriesEntries.end();
|
||||
std::vector<cmListFileBacktrace>::iterator btPos =
|
||||
this->IncludeDirectoriesEntryBacktraces.begin()
|
||||
+ std::distance(this->IncludeDirectoriesEntries.begin(), position);
|
||||
|
||||
cmListFileBacktrace lfbt = this->GetBacktrace();
|
||||
std::string entryString = cmJoin(incs, ";");
|
||||
this->IncludeDirectoriesEntries.insert(position, entryString);
|
||||
this->IncludeDirectoriesEntryBacktraces.insert(btPos, lfbt);
|
||||
if (before)
|
||||
{
|
||||
this->StateSnapshot.GetDirectory()
|
||||
.PrependIncludeDirectoriesEntry(entryString, lfbt);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->StateSnapshot.GetDirectory()
|
||||
.AppendIncludeDirectoriesEntry(entryString, lfbt);
|
||||
}
|
||||
|
||||
// Property on each target:
|
||||
for (cmTargets::iterator l = this->Targets.begin();
|
||||
|
@ -4162,41 +4140,35 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
|
|||
{
|
||||
if (prop == "INCLUDE_DIRECTORIES")
|
||||
{
|
||||
this->IncludeDirectoriesEntries.clear();
|
||||
this->IncludeDirectoriesEntryBacktraces.clear();
|
||||
if (!value)
|
||||
{
|
||||
this->StateSnapshot.GetDirectory().ClearIncludeDirectories();
|
||||
return;
|
||||
}
|
||||
cmListFileBacktrace lfbt = this->GetBacktrace();
|
||||
this->IncludeDirectoriesEntries.push_back(value);
|
||||
this->IncludeDirectoriesEntryBacktraces.push_back(lfbt);
|
||||
this->StateSnapshot.GetDirectory().SetIncludeDirectories(value, lfbt);
|
||||
return;
|
||||
}
|
||||
if (prop == "COMPILE_OPTIONS")
|
||||
{
|
||||
this->CompileOptionsEntries.clear();
|
||||
this->CompileDefinitionsEntryBacktraces.clear();
|
||||
if (!value)
|
||||
{
|
||||
this->StateSnapshot.GetDirectory().ClearCompileOptions();
|
||||
return;
|
||||
}
|
||||
cmListFileBacktrace lfbt = this->GetBacktrace();
|
||||
this->CompileOptionsEntries.push_back(value);
|
||||
this->CompileOptionsEntryBacktraces.push_back(lfbt);
|
||||
this->StateSnapshot.GetDirectory().SetCompileOptions(value, lfbt);
|
||||
return;
|
||||
}
|
||||
if (prop == "COMPILE_DEFINITIONS")
|
||||
{
|
||||
this->CompileDefinitionsEntries.clear();
|
||||
this->CompileDefinitionsEntryBacktraces.clear();
|
||||
if (!value)
|
||||
{
|
||||
this->StateSnapshot.GetDirectory().ClearCompileDefinitions();
|
||||
return;
|
||||
}
|
||||
cmListFileBacktrace lfbt = this->GetBacktrace();
|
||||
this->CompileDefinitionsEntries.push_back(value);
|
||||
this->CompileDefinitionsEntryBacktraces.push_back(lfbt);
|
||||
this->StateSnapshot.GetDirectory().SetCompileDefinitions(value, lfbt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4210,22 +4182,21 @@ void cmMakefile::AppendProperty(const std::string& prop,
|
|||
if (prop == "INCLUDE_DIRECTORIES")
|
||||
{
|
||||
cmListFileBacktrace lfbt = this->GetBacktrace();
|
||||
this->IncludeDirectoriesEntries.push_back(value);
|
||||
this->IncludeDirectoriesEntryBacktraces.push_back(lfbt);
|
||||
this->StateSnapshot.GetDirectory().AppendIncludeDirectoriesEntry(value,
|
||||
lfbt);
|
||||
return;
|
||||
}
|
||||
if (prop == "COMPILE_OPTIONS")
|
||||
{
|
||||
cmListFileBacktrace lfbt = this->GetBacktrace();
|
||||
this->CompileOptionsEntries.push_back(value);
|
||||
this->CompileOptionsEntryBacktraces.push_back(lfbt);
|
||||
this->StateSnapshot.GetDirectory().AppendCompileOptionsEntry(value, lfbt);
|
||||
return;
|
||||
}
|
||||
if (prop == "COMPILE_DEFINITIONS")
|
||||
{
|
||||
cmListFileBacktrace lfbt = this->GetBacktrace();
|
||||
this->CompileDefinitionsEntries.push_back(value);
|
||||
this->CompileDefinitionsEntryBacktraces.push_back(lfbt);
|
||||
this->StateSnapshot.GetDirectory().AppendCompileDefinitionsEntry(value,
|
||||
lfbt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4280,17 +4251,20 @@ const char *cmMakefile::GetProperty(const std::string& prop,
|
|||
}
|
||||
else if (prop == "INCLUDE_DIRECTORIES")
|
||||
{
|
||||
output = cmJoin(this->IncludeDirectoriesEntries, ";");
|
||||
output = cmJoin(this->StateSnapshot.GetDirectory()
|
||||
.GetIncludeDirectoriesEntries(), ";");
|
||||
return output.c_str();
|
||||
}
|
||||
else if (prop == "COMPILE_OPTIONS")
|
||||
{
|
||||
output = cmJoin(this->CompileOptionsEntries, ";");
|
||||
output = cmJoin(this->StateSnapshot.GetDirectory()
|
||||
.GetCompileOptionsEntries(), ";");
|
||||
return output.c_str();
|
||||
}
|
||||
else if (prop == "COMPILE_DEFINITIONS")
|
||||
{
|
||||
output = cmJoin(this->CompileDefinitionsEntries, ";");
|
||||
output = cmJoin(this->StateSnapshot.GetDirectory()
|
||||
.GetCompileDefinitionsEntries(), ";");
|
||||
return output.c_str();
|
||||
}
|
||||
|
||||
|
|
|
@ -846,13 +846,6 @@ protected:
|
|||
std::vector<std::string> HeaderFileExtensions;
|
||||
std::string DefineFlags;
|
||||
|
||||
std::vector<std::string> IncludeDirectoriesEntries;
|
||||
std::vector<cmListFileBacktrace> IncludeDirectoriesEntryBacktraces;
|
||||
std::vector<std::string> CompileOptionsEntries;
|
||||
std::vector<cmListFileBacktrace> CompileOptionsEntryBacktraces;
|
||||
std::vector<std::string> CompileDefinitionsEntries;
|
||||
std::vector<cmListFileBacktrace> CompileDefinitionsEntryBacktraces;
|
||||
|
||||
// Track the value of the computed DEFINITIONS property.
|
||||
void AddDefineFlag(const char*, std::string&);
|
||||
void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
|
||||
|
|
|
@ -28,6 +28,9 @@ struct cmState::SnapshotDataType
|
|||
BuildSystemDirectory;
|
||||
std::string EntryPointCommand;
|
||||
long EntryPointLine;
|
||||
std::vector<std::string>::size_type IncludeDirectoryPosition;
|
||||
std::vector<std::string>::size_type CompileDefinitionsPosition;
|
||||
std::vector<std::string>::size_type CompileOptionsPosition;
|
||||
};
|
||||
|
||||
struct cmState::BuildsystemDirectoryStateType
|
||||
|
@ -44,6 +47,15 @@ struct cmState::BuildsystemDirectoryStateType
|
|||
// safely by the build tools.
|
||||
std::string RelativePathTopSource;
|
||||
std::string RelativePathTopBinary;
|
||||
|
||||
std::vector<std::string> IncludeDirectories;
|
||||
std::vector<cmListFileBacktrace> IncludeDirectoryBacktraces;
|
||||
|
||||
std::vector<std::string> CompileDefinitions;
|
||||
std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces;
|
||||
|
||||
std::vector<std::string> CompileOptions;
|
||||
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
|
||||
};
|
||||
|
||||
cmState::cmState(cmake* cm)
|
||||
|
@ -228,7 +240,16 @@ cmState::Snapshot cmState::Reset()
|
|||
this->GlobalProperties.clear();
|
||||
this->PropertyDefinitions.clear();
|
||||
|
||||
this->BuildsystemDirectory.Truncate();
|
||||
{
|
||||
cmLinkedTree<BuildsystemDirectoryStateType>::iterator it =
|
||||
this->BuildsystemDirectory.Truncate();
|
||||
it->IncludeDirectories.clear();
|
||||
it->IncludeDirectoryBacktraces.clear();
|
||||
it->CompileDefinitions.clear();
|
||||
it->CompileDefinitionsBacktraces.clear();
|
||||
it->CompileOptions.clear();
|
||||
it->CompileOptionsBacktraces.clear();
|
||||
}
|
||||
PositionType pos = this->SnapshotData.Truncate();
|
||||
this->ExecutionListFiles.Truncate();
|
||||
|
||||
|
@ -698,6 +719,9 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
|
|||
this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root());
|
||||
pos->ExecutionListFile =
|
||||
this->ExecutionListFiles.Extend(this->ExecutionListFiles.Root());
|
||||
pos->IncludeDirectoryPosition = 0;
|
||||
pos->CompileDefinitionsPosition = 0;
|
||||
pos->CompileOptionsPosition = 0;
|
||||
return cmState::Snapshot(this, pos);
|
||||
}
|
||||
|
||||
|
@ -796,6 +820,13 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
|
|||
PositionType pos = originSnapshot.Position;
|
||||
PositionType prevPos = pos;
|
||||
++prevPos;
|
||||
prevPos->IncludeDirectoryPosition =
|
||||
prevPos->BuildSystemDirectory->IncludeDirectories.size();
|
||||
prevPos->CompileDefinitionsPosition =
|
||||
prevPos->BuildSystemDirectory->CompileDefinitions.size();
|
||||
prevPos->CompileOptionsPosition =
|
||||
prevPos->BuildSystemDirectory->CompileOptions.size();
|
||||
|
||||
if (prevPos == this->SnapshotData.Root())
|
||||
{
|
||||
return Snapshot(this, prevPos);
|
||||
|
@ -803,6 +834,12 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
|
|||
return Snapshot(this, originSnapshot.Position->CallStackParent);
|
||||
}
|
||||
|
||||
cmState::Snapshot::Snapshot(cmState* state)
|
||||
: State(state)
|
||||
, Position()
|
||||
{
|
||||
}
|
||||
|
||||
cmState::Snapshot::Snapshot(cmState* state, PositionType position)
|
||||
: State(state),
|
||||
Position(position)
|
||||
|
@ -943,6 +980,62 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
|
|||
return snapshot;
|
||||
}
|
||||
|
||||
static const std::string cmPropertySentinal = std::string();
|
||||
|
||||
template<typename T, typename U, typename V>
|
||||
void InitializeContentFromParent(T& parentContent,
|
||||
T& thisContent,
|
||||
U& parentBacktraces,
|
||||
U& thisBacktraces,
|
||||
V& contentEndPosition)
|
||||
{
|
||||
std::vector<std::string>::const_iterator parentBegin =
|
||||
parentContent.begin();
|
||||
std::vector<std::string>::const_iterator parentEnd =
|
||||
parentContent.end();
|
||||
|
||||
std::vector<std::string>::const_reverse_iterator parentRbegin =
|
||||
cmMakeReverseIterator(parentEnd);
|
||||
std::vector<std::string>::const_reverse_iterator parentRend =
|
||||
parentContent.rend();
|
||||
parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal);
|
||||
std::vector<std::string>::const_iterator parentIt = parentRbegin.base();
|
||||
|
||||
thisContent = std::vector<std::string>(parentIt, parentEnd);
|
||||
|
||||
std::vector<cmListFileBacktrace>::const_iterator btIt =
|
||||
parentBacktraces.begin() + std::distance(parentBegin, parentIt);
|
||||
std::vector<cmListFileBacktrace>::const_iterator btEnd =
|
||||
parentBacktraces.end();
|
||||
|
||||
thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd);
|
||||
|
||||
contentEndPosition = thisContent.size();
|
||||
}
|
||||
|
||||
void cmState::Snapshot::InitializeFromParent()
|
||||
{
|
||||
PositionType parent = this->Position->DirectoryParent;
|
||||
|
||||
InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories,
|
||||
this->Position->BuildSystemDirectory->IncludeDirectories,
|
||||
parent->BuildSystemDirectory->IncludeDirectoryBacktraces,
|
||||
this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces,
|
||||
this->Position->IncludeDirectoryPosition);
|
||||
|
||||
InitializeContentFromParent(parent->BuildSystemDirectory->CompileDefinitions,
|
||||
this->Position->BuildSystemDirectory->CompileDefinitions,
|
||||
parent->BuildSystemDirectory->CompileDefinitionsBacktraces,
|
||||
this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces,
|
||||
this->Position->CompileDefinitionsPosition);
|
||||
|
||||
InitializeContentFromParent(parent->BuildSystemDirectory->CompileOptions,
|
||||
this->Position->BuildSystemDirectory->CompileOptions,
|
||||
parent->BuildSystemDirectory->CompileOptionsBacktraces,
|
||||
this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
|
||||
this->Position->CompileOptionsPosition);
|
||||
}
|
||||
|
||||
cmState* cmState::Snapshot::GetState() const
|
||||
{
|
||||
return this->State;
|
||||
|
@ -960,3 +1053,220 @@ cmState::Directory::Directory(
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
cmStringRange GetPropertyContent(T const& content, U contentEndPosition)
|
||||
{
|
||||
std::vector<std::string>::const_iterator end =
|
||||
content.begin() + contentEndPosition;
|
||||
|
||||
std::vector<std::string>::const_reverse_iterator rbegin =
|
||||
cmMakeReverseIterator(end);
|
||||
rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
|
||||
|
||||
return cmMakeRange(rbegin.base(), end);
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
cmBacktraceRange GetPropertyBacktraces(T const& content,
|
||||
U const& backtraces,
|
||||
V contentEndPosition)
|
||||
{
|
||||
std::vector<std::string>::const_iterator entryEnd =
|
||||
content.begin() + contentEndPosition;
|
||||
|
||||
std::vector<std::string>::const_reverse_iterator rbegin =
|
||||
cmMakeReverseIterator(entryEnd);
|
||||
rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
|
||||
|
||||
std::vector<cmListFileBacktrace>::const_iterator it =
|
||||
backtraces.begin() + std::distance(content.begin(), rbegin.base());
|
||||
|
||||
std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end();
|
||||
return cmMakeRange(it, end);
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
void AppendEntry(T& content, U& backtraces, V& endContentPosition,
|
||||
const std::string& vec, const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
assert(endContentPosition == content.size());
|
||||
|
||||
content.push_back(vec);
|
||||
backtraces.push_back(lfbt);
|
||||
|
||||
endContentPosition = content.size();
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
void SetContent(T& content, U& backtraces, V& endContentPosition,
|
||||
const std::string& vec, const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
assert(endContentPosition == content.size());
|
||||
|
||||
content.resize(content.size() + 2);
|
||||
backtraces.resize(backtraces.size() + 2);
|
||||
|
||||
content.back() = vec;
|
||||
backtraces.back() = lfbt;
|
||||
|
||||
endContentPosition = content.size();
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
void ClearContent(T& content, U& backtraces, V& endContentPosition)
|
||||
{
|
||||
assert(endContentPosition == content.size());
|
||||
|
||||
content.resize(content.size() + 1);
|
||||
backtraces.resize(backtraces.size() + 1);
|
||||
|
||||
endContentPosition = content.size();
|
||||
}
|
||||
|
||||
cmStringRange
|
||||
cmState::Directory::GetIncludeDirectoriesEntries() const
|
||||
{
|
||||
return GetPropertyContent(this->DirectoryState->IncludeDirectories,
|
||||
this->Snapshot_.Position->IncludeDirectoryPosition);
|
||||
}
|
||||
|
||||
cmBacktraceRange
|
||||
cmState::Directory::GetIncludeDirectoriesEntryBacktraces() const
|
||||
{
|
||||
return GetPropertyBacktraces(this->DirectoryState->IncludeDirectories,
|
||||
this->DirectoryState->IncludeDirectoryBacktraces,
|
||||
this->Snapshot_.Position->IncludeDirectoryPosition);
|
||||
}
|
||||
|
||||
void cmState::Directory::AppendIncludeDirectoriesEntry(
|
||||
const std::string& vec, const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
AppendEntry(this->DirectoryState->IncludeDirectories,
|
||||
this->DirectoryState->IncludeDirectoryBacktraces,
|
||||
this->Snapshot_.Position->IncludeDirectoryPosition,
|
||||
vec, lfbt);
|
||||
}
|
||||
|
||||
void cmState::Directory::PrependIncludeDirectoriesEntry(
|
||||
const std::string& vec, const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
std::vector<std::string>::iterator entryEnd =
|
||||
this->DirectoryState->IncludeDirectories.begin()
|
||||
+ this->Snapshot_.Position->IncludeDirectoryPosition;
|
||||
|
||||
std::vector<std::string>::const_reverse_iterator rend =
|
||||
this->DirectoryState->IncludeDirectories.rend();
|
||||
std::vector<std::string>::reverse_iterator rbegin =
|
||||
cmMakeReverseIterator(entryEnd);
|
||||
std::vector<std::string>::const_reverse_iterator crbegin = rbegin;
|
||||
crbegin = std::find(crbegin, rend, cmPropertySentinal);
|
||||
|
||||
std::vector<std::string>::const_iterator entryIt = crbegin.base();
|
||||
std::vector<std::string>::const_iterator entryBegin =
|
||||
this->DirectoryState->IncludeDirectories.begin();
|
||||
|
||||
std::vector<cmListFileBacktrace>::iterator btIt =
|
||||
this->DirectoryState->IncludeDirectoryBacktraces.begin()
|
||||
+ std::distance(entryBegin, entryIt);
|
||||
|
||||
this->DirectoryState->IncludeDirectories.insert(rbegin.base(), vec);
|
||||
this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt);
|
||||
|
||||
this->Snapshot_.Position->IncludeDirectoryPosition =
|
||||
this->DirectoryState->IncludeDirectories.size();
|
||||
}
|
||||
|
||||
void cmState::Directory::SetIncludeDirectories(
|
||||
const std::string& vec, const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
SetContent(this->DirectoryState->IncludeDirectories,
|
||||
this->DirectoryState->IncludeDirectoryBacktraces,
|
||||
this->Snapshot_.Position->IncludeDirectoryPosition,
|
||||
vec, lfbt);
|
||||
}
|
||||
|
||||
void cmState::Directory::ClearIncludeDirectories()
|
||||
{
|
||||
ClearContent(this->DirectoryState->IncludeDirectories,
|
||||
this->DirectoryState->IncludeDirectoryBacktraces,
|
||||
this->Snapshot_.Position->IncludeDirectoryPosition);
|
||||
}
|
||||
|
||||
cmStringRange cmState::Directory::GetCompileDefinitionsEntries() const
|
||||
{
|
||||
return GetPropertyContent(this->DirectoryState->CompileDefinitions,
|
||||
this->Snapshot_.Position->CompileDefinitionsPosition);
|
||||
}
|
||||
|
||||
cmBacktraceRange
|
||||
cmState::Directory::GetCompileDefinitionsEntryBacktraces() const
|
||||
{
|
||||
return GetPropertyBacktraces(this->DirectoryState->CompileDefinitions,
|
||||
this->DirectoryState->CompileDefinitionsBacktraces,
|
||||
this->Snapshot_.Position->CompileDefinitionsPosition);
|
||||
}
|
||||
|
||||
void cmState::Directory::AppendCompileDefinitionsEntry(const std::string& vec,
|
||||
const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
AppendEntry(this->DirectoryState->CompileDefinitions,
|
||||
this->DirectoryState->CompileDefinitionsBacktraces,
|
||||
this->Snapshot_.Position->CompileDefinitionsPosition,
|
||||
vec, lfbt);
|
||||
}
|
||||
|
||||
void cmState::Directory::SetCompileDefinitions(const std::string& vec,
|
||||
const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
SetContent(this->DirectoryState->CompileDefinitions,
|
||||
this->DirectoryState->CompileDefinitionsBacktraces,
|
||||
this->Snapshot_.Position->CompileDefinitionsPosition,
|
||||
vec, lfbt);
|
||||
}
|
||||
|
||||
void cmState::Directory::ClearCompileDefinitions()
|
||||
{
|
||||
ClearContent(this->DirectoryState->CompileDefinitions,
|
||||
this->DirectoryState->CompileDefinitionsBacktraces,
|
||||
this->Snapshot_.Position->CompileDefinitionsPosition);
|
||||
}
|
||||
|
||||
cmStringRange cmState::Directory::GetCompileOptionsEntries() const
|
||||
{
|
||||
return GetPropertyContent(this->DirectoryState->CompileOptions,
|
||||
this->Snapshot_.Position->CompileOptionsPosition);
|
||||
}
|
||||
|
||||
cmBacktraceRange cmState::Directory::GetCompileOptionsEntryBacktraces() const
|
||||
{
|
||||
return GetPropertyBacktraces(this->DirectoryState->CompileOptions,
|
||||
this->DirectoryState->CompileOptionsBacktraces,
|
||||
this->Snapshot_.Position->CompileOptionsPosition);
|
||||
}
|
||||
|
||||
void
|
||||
cmState::Directory::AppendCompileOptionsEntry(const std::string& vec,
|
||||
const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
AppendEntry(this->DirectoryState->CompileOptions,
|
||||
this->DirectoryState->CompileOptionsBacktraces,
|
||||
this->Snapshot_.Position->CompileOptionsPosition,
|
||||
vec, lfbt);
|
||||
}
|
||||
|
||||
void cmState::Directory::SetCompileOptions(const std::string& vec,
|
||||
const cmListFileBacktrace& lfbt)
|
||||
{
|
||||
SetContent(this->DirectoryState->CompileOptions,
|
||||
this->DirectoryState->CompileOptionsBacktraces,
|
||||
this->Snapshot_.Position->CompileOptionsPosition,
|
||||
vec, lfbt);
|
||||
}
|
||||
|
||||
void cmState::Directory::ClearCompileOptions()
|
||||
{
|
||||
ClearContent(this->DirectoryState->CompileOptions,
|
||||
this->DirectoryState->CompileOptionsBacktraces,
|
||||
this->Snapshot_.Position->CompileOptionsPosition);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "cmPropertyDefinitionMap.h"
|
||||
#include "cmPropertyMap.h"
|
||||
#include "cmLinkedTree.h"
|
||||
#include "cmAlgorithms.h"
|
||||
|
||||
class cmake;
|
||||
class cmCommand;
|
||||
|
@ -43,7 +44,8 @@ public:
|
|||
|
||||
class Snapshot {
|
||||
public:
|
||||
Snapshot(cmState* state = 0, PositionType position = PositionType());
|
||||
Snapshot(cmState* state = 0);
|
||||
Snapshot(cmState* state, PositionType position);
|
||||
|
||||
void SetListFile(std::string const& listfile);
|
||||
|
||||
|
@ -55,6 +57,8 @@ public:
|
|||
Snapshot GetBuildsystemDirectoryParent() const;
|
||||
Snapshot GetCallStackParent() const;
|
||||
|
||||
void InitializeFromParent();
|
||||
|
||||
cmState* GetState() const;
|
||||
|
||||
Directory GetDirectory() const;
|
||||
|
@ -86,6 +90,32 @@ public:
|
|||
void SetRelativePathTopSource(const char* dir);
|
||||
void SetRelativePathTopBinary(const char* dir);
|
||||
|
||||
cmStringRange GetIncludeDirectoriesEntries() const;
|
||||
cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const;
|
||||
void AppendIncludeDirectoriesEntry(std::string const& vec,
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void PrependIncludeDirectoriesEntry(std::string const& vec,
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void SetIncludeDirectories(std::string const& vec,
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void ClearIncludeDirectories();
|
||||
|
||||
cmStringRange GetCompileDefinitionsEntries() const;
|
||||
cmBacktraceRange GetCompileDefinitionsEntryBacktraces() const;
|
||||
void AppendCompileDefinitionsEntry(std::string const& vec,
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void SetCompileDefinitions(std::string const& vec,
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void ClearCompileDefinitions();
|
||||
|
||||
cmStringRange GetCompileOptionsEntries() const;
|
||||
cmBacktraceRange GetCompileOptionsEntryBacktraces() const;
|
||||
void AppendCompileOptionsEntry(std::string const& vec,
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void SetCompileOptions(std::string const& vec,
|
||||
cmListFileBacktrace const& lfbt);
|
||||
void ClearCompileOptions();
|
||||
|
||||
private:
|
||||
void ComputeRelativePathTopSource();
|
||||
void ComputeRelativePathTopBinary();
|
||||
|
|
|
@ -143,6 +143,7 @@ add_RunCMake_test(Swift)
|
|||
add_RunCMake_test(TargetObjects)
|
||||
add_RunCMake_test(TargetSources)
|
||||
add_RunCMake_test(find_dependency)
|
||||
add_RunCMake_test(CompileDefinitions)
|
||||
add_RunCMake_test(CompileFeatures)
|
||||
add_RunCMake_test(WriteCompilerDetectionHeader)
|
||||
if(NOT WIN32)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
cmake_minimum_required(VERSION 3.3)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
|
@ -0,0 +1,3 @@
|
|||
include(RunCMake)
|
||||
|
||||
run_cmake(SetEmpty)
|
|
@ -0,0 +1 @@
|
|||
0
|
|
@ -0,0 +1,3 @@
|
|||
RESULT1=A;;B
|
||||
RESULT2=
|
||||
RESULT3=-DBAR
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS A "" B)
|
||||
get_property(result DIRECTORY PROPERTY COMPILE_DEFINITIONS)
|
||||
message("RESULT1=${result}")
|
||||
|
||||
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS)
|
||||
get_property(result DIRECTORY PROPERTY COMPILE_DEFINITIONS)
|
||||
message("RESULT2=${result}")
|
||||
|
||||
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS -DBAR)
|
||||
get_property(result DIRECTORY PROPERTY COMPILE_DEFINITIONS)
|
||||
message("RESULT3=${result}")
|
Loading…
Reference in New Issue