[cmake-developers] [CMake 0014491]: file(GLOB) and file(GLOB_RECURSE) indeterministic

Mantis Bug Tracker mantis at public.kitware.com
Thu Oct 17 11:02:03 EDT 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14491 
====================================================================== 
Reported By:                ingolf
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14491
Category:                   (No Category)
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-10-17 11:02 EDT
Last Modified:              2013-10-17 11:02 EDT
====================================================================== 
Summary:                    file(GLOB) and file(GLOB_RECURSE) indeterministic
Description: 
file(GLOB) and file(GLOB_RECURSE) have indeterministic behavior. Apparently, the
ordering of the files which match the specified pattern depends on the sequence
in which files are delivered by the file system.

While this might be on purpose, this should at least be clearly documented --
together with a proposal to use list(SORT) afterwards if a fixed ordering is
desired.

Nevertheless, I would expect the cmake output to be reproducible when all the
files involved in the project (including the cmake tool itself) as well as the
user environment variables have the same content.

Steps to Reproduce: 
Create an empty project directory with the following contents (all files can be
empty):
./f1.abx
./folder1/8764gh.abb
./folder1/q.ab0
./folder1/zzzzz.ab_
./folder2/.abz
./folder2/_bbbb_.abd
./folder2/bea7.96.abc
./folder2/xcx.abcd
./fsbi213.ab
./z.ab5

Then use the following CMakeLists.txt:
----8<----8<----8<----8<----8<----8<----8<----8<----
cmake_minimum_required(VERSION 2.8)

file(GLOB FILES_LOCAL RELATIVE ${CMAKE_SOURCE_DIR} *.ab?)
message(STATUS "Non-recursive: ${FILES_LOCAL}")

file(GLOB_RECURSE FILES_RECURSE RELATIVE ${CMAKE_SOURCE_DIR} *.ab?)
message(STATUS "Recursive: ${FILES_RECURSE}")
----8<----8<----8<----8<----8<----8<----8<----8<----

On the same machine (with the same user environment), CMake might output

> -- Non-recursive: z.ab5;f1.abx
> -- Recursive:
z.ab5;folder1/8764gh.abb;folder1/q.ab0;folder1/zzzzz.ab_;f1.abx;folder2/.abz;folder2/bea7.96.abc;folder2/_bbbb_.abd

when run in one folder and

> -- Non-recursive: f1.abx;z.ab5
> -- Recursive:
f1.abx;folder2/_bbbb_.abd;folder2/.abz;folder2/bea7.96.abc;folder1/zzzzz.ab_;folder1/q.ab0;folder1/8764gh.abb;z.ab5

when run in another folder.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-10-17 11:02 ingolf         New Issue                                    
======================================================================




More information about the cmake-developers mailing list