diff options
author | Reiner Herrmann <reiner@reiner-h.de> | 2016-05-14 10:30:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-17 14:12:11 (GMT) |
commit | edcccde7d65944b3744c4567bd1d452211829702 (patch) | |
tree | ee784327c065d207b0fa24e7cf32078a6c82e68c /Help/command | |
parent | d9fd2f5402eeaa345691313658e02b51038f570b (diff) | |
download | CMake-edcccde7d65944b3744c4567bd1d452211829702.zip CMake-edcccde7d65944b3744c4567bd1d452211829702.tar.gz CMake-edcccde7d65944b3744c4567bd1d452211829702.tar.bz2 |
file: Sort GLOB results to make it deterministic (#14491)
Even though the `file(GLOB)` documentation specifically warns against
using it to collect a list of source files, projects often do it anyway.
Since it uses `readdir()`, the list of files will be unsorted.
This list is often passed directly to add_executable / add_library.
Linking binaries with an unsorted list will make it unreproducible,
which means that the produced binary will differ depending on the
unpredictable `readdir()` order.
To solve those reproducibility issues in a lot of programs (which don't
explicitly `list(SORT)` the list manually), sort the resulting list of
the `file(GLOB)` command.
A more detailed rationale about reproducible builds is available
[here](https://reproducible-builds.org/).
Diffstat (limited to 'Help/command')
-rw-r--r-- | Help/command/file.rst | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst index 96ac6c7..256d16d 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -103,8 +103,9 @@ Generate a list of files that match the ``<globbing-expressions>`` and store it into the ``<variable>``. Globbing expressions are similar to regular expressions, but much simpler. If ``RELATIVE`` flag is specified, the results will be returned as relative paths to the given -path. No specific order of results is defined. If order is important then -sort the list explicitly (e.g. using the :command:`list(SORT)` command). +path. No specific order of results is defined other than that it is +deterministic. If order is important then sort the list explicitly +(e.g. using the :command:`list(SORT)` command). By default ``GLOB`` lists directories - directories are omited in result if ``LIST_DIRECTORIES`` is set to false. |