Commit caa4b7b8 authored by Clinton Stimpson's avatar Clinton Stimpson Committed by Brad King
Browse files

genex: Preserve order while evaluating TARGET_OBJECTS

The logic introduced in commit v3.1.0-rc1~688^2~9 (Genex: Evaluate
TARGET_OBJECTS as a normal expression, 2014-02-26) ordered a map
by pointer value and then constructed a list of object files by
iterating over the map.  This is not deterministic.

Since commit v3.1.0-rc1~688^2~5 (cmTarget: Allow any generator
expression in SOURCES property, 2014-03-18) the order produced by the
above-mentioned logic started being used for the actual list of object
files on the link line.  Since it is not deterministic, spurious
re-links occur after re-running CMake simply because the order of
objects changed on the link line.

Fix this by iterating over the original vector of source files instead
of the map.  This has a deterministic order.
parent 4cc2d9b3
......@@ -1286,12 +1286,16 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
std::string obj_dir = gt->ObjectDirectory;
std::string result;
const char* sep = "";
for(std::map<cmSourceFile const*, std::string>::const_iterator it
= mapping.begin(); it != mapping.end(); ++it)
for(std::vector<cmSourceFile const*>::const_iterator it
= objectSources.begin(); it != objectSources.end(); ++it)
// Find the object file name corresponding to this source file.
std::map<cmSourceFile const*, std::string>::const_iterator
map_it = mapping.find(*it);
// It must exist because we populated the mapping just above.
result += sep;
std::string objFile = obj_dir + it->second;
std::string objFile = obj_dir + map_it->second;
cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true);
sf->SetProperty("EXTERNAL_OBJECT", "1");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment