summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-11-20 15:58:01 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-11-22 14:06:25 (GMT)
commitabb13ea5659cdaa4254724fca582f56570f88164 (patch)
tree162fe496f8dbe7477d59e947174bded4b5b3d265 /Source
parent7246e635fe8312206b62a279b3c237d1cf584c83 (diff)
downloadCMake-abb13ea5659cdaa4254724fca582f56570f88164.zip
CMake-abb13ea5659cdaa4254724fca582f56570f88164.tar.gz
CMake-abb13ea5659cdaa4254724fca582f56570f88164.tar.bz2
Order cmGeneratorTargetsType elements deterministically.
Define a custom ordering functor to deterministically and strictly order the cmTarget* key. Otherwise the order would be dependent on runtime pointer values, which breaks assumptions of some generators. The functor orders first by target name, and then by directory. Multiple global targets may have the same name, such as edit_cache, but their directory differentiates them.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx11
-rw-r--r--Source/cmGeneratorTarget.h8
2 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 011fc6c..90cca1b 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -692,3 +692,14 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const
gg->AddToManifest(config? config:"", f);
}
}
+
+bool cmStrictTargetComparison::operator()(cmTarget *t1, cmTarget *t2) const
+{
+ int nameResult = strcmp(t1->GetName(), t2->GetName());
+ if (nameResult == 0)
+ {
+ return strcmp(t1->GetMakefile()->GetStartDirectory(),
+ t2->GetMakefile()->GetStartDirectory()) < 0;
+ }
+ return nameResult < 0;
+}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 69d1bb2..d2b65b2 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -100,6 +100,12 @@ private:
void operator=(cmGeneratorTarget const&);
};
-typedef std::map<cmTarget*, cmGeneratorTarget*> cmGeneratorTargetsType;
+struct cmStrictTargetComparison {
+ bool operator()(cmTarget *t1, cmTarget *t2) const;
+};
+
+typedef std::map<cmTarget*,
+ cmGeneratorTarget*,
+ cmStrictTargetComparison> cmGeneratorTargetsType;
#endif