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

Brad King brad.king at kitware.com
Mon May 16 09:27:57 EDT 2016


On 05/16/2016 03:06 AM, Petr Kmoch wrote:
> I'd like to express my concerns about the proposed change.
> CMake strongly discourages using `file(GLOB)` to find source files
[snip]
> On 14 May 2016 at 12:30, Reiner Herrmann wrote:
>     @@ -1026,6 +1026,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
> 
>          std::vector<std::string>::size_type cc;
>          std::vector<std::string>& files = g.GetFiles();
>     +    std::sort(files.begin(), files.end());

This has been proposed several times and never accepted because file(GLOB)
is a primitive.  As Petr said our documentation explicitly discourages
the use case in question.  Those projects that wish to ignore our advice
can use list(SORT) themselves to get reproducible source file ordering
after file(GLOB).

-Brad



More information about the cmake-developers mailing list