[CMake] Diff output from CMake?
Alexander Neundorf
a.neundorf-work at gmx.net
Tue Sep 13 13:39:16 EDT 2011
On Tuesday, September 13, 2011 05:07:00 AM Clifford Yapp wrote:
> I am trying to compare two large lists of file paths (about 14,000 lines
> each) to identify which entries in each list are missing from the other,
> and while I can get CMake to do it I must be doing it the wrong way
> because the results are hideously slow.
>
> I currently generate two files with the paths and then read them in as
> lists, using LIST() commands to peform STREQUAL tests. I was hoping to
How do you do that ?
Do you iterate over one list using foreach() and then list(FIND) to check
whether it exists in the other list ?
Internally, every cmake variable is stored as a plain std::string.
When using a list() command, this string is converted to a
std::vector<std::string>, and then cmake operates on this vector.
So if you do this 14000 times, each time a 14000 std::strings are created,
which makes this O(n^2) I think.
Maybe something like this works ?
set(uniqueItems ${list1} ${list2})
list(REMOVE_DUPLICATES uniqueItems )
Or maybe you can do something with sorting both lists first.
Alex
More information about the CMake
mailing list