summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/file
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2016-05-14 10:30:36 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-17 14:12:11 (GMT)
commitedcccde7d65944b3744c4567bd1d452211829702 (patch)
treeee784327c065d207b0fa24e7cf32078a6c82e68c /Tests/RunCMake/file
parentd9fd2f5402eeaa345691313658e02b51038f570b (diff)
downloadCMake-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 'Tests/RunCMake/file')
-rw-r--r--Tests/RunCMake/file/GLOB.cmake3
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake3
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE.cmake3
3 files changed, 0 insertions, 9 deletions
diff --git a/Tests/RunCMake/file/GLOB.cmake b/Tests/RunCMake/file/GLOB.cmake
index 3d577e3..c524e42 100644
--- a/Tests/RunCMake/file/GLOB.cmake
+++ b/Tests/RunCMake/file/GLOB.cmake
@@ -12,17 +12,14 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir fi
file(GLOB CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
file(GLOB CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
file(GLOB CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
index a8c6784..fb8be42 100644
--- a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
+++ b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
@@ -7,17 +7,14 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINA
file(GLOB_RECURSE CONTENT_LIST FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/GLOB_RECURSE.cmake b/Tests/RunCMake/file/GLOB_RECURSE.cmake
index 6db377b..530930f 100644
--- a/Tests/RunCMake/file/GLOB_RECURSE.cmake
+++ b/Tests/RunCMake/file/GLOB_RECURSE.cmake
@@ -12,17 +12,14 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir fi
file(GLOB_RECURSE CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")
file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
list(LENGTH CONTENT_LIST CONTENT_COUNT)
message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
message("${CONTENT_LIST}")