[cmake-developers] [PATCH] cmFileCommand: sort list of files from glob command

Brad King brad.king at kitware.com
Tue May 17 10:23:46 EDT 2016


On 05/16/2016 05:23 PM, Reiner Herrmann wrote:
> Unfortunately many projects still use this for finding source files [1],
> without considering sorting.
> Without sorting it in file(GLOB), most of those packages have to be
> patched individually.  Would sorting by default really have such a
> noticable performance impact?  I can't imagine there are many projects
> where sorting time isn't negligible.

I also doubt the in-memory sorting time is noticeable.  If it turns
out to be a problem we can look at more efficient implementations.

There is an open issue about this too:

  https://cmake.org/Bug/view.php?id=14491

Even when file(GLOB) is used as a primitive for a purpose other than
collecting a list of source files, deterministic results are useful.

I've decided to apply the patch and merge to 'next' for testing:

 file: Sort GLOB results to make it deterministic (#14491)
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=edcccde7

I also updated the test suite to cover it.  I revised the wording
of the documentation to not promise sorting, only determinism.
When multiple globbing patterns are used we still sort only the
results of each individual pattern, so overall the results are not
necessarily sorted.

Thanks,
-Brad


More information about the cmake-developers mailing list