diff options
author | Domen Vrankar <domen.vrankar@gmail.com> | 2015-03-17 22:34:03 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-03-20 13:45:25 (GMT) |
commit | a2c068a7ce47ab5934735b9f9168dda9760646ec (patch) | |
tree | b6619fd89eebce8675685db87ab7deadc28b39de /Tests/RunCMake/file/GLOB.cmake | |
parent | a5cab2e7391df8d2072f1083c075a69bc746c7aa (diff) | |
download | CMake-a2c068a7ce47ab5934735b9f9168dda9760646ec.zip CMake-a2c068a7ce47ab5934735b9f9168dda9760646ec.tar.gz CMake-a2c068a7ce47ab5934735b9f9168dda9760646ec.tar.bz2 |
file: Teach GLOB to list directories optionally
GLOB lists directories by default and GLOB_RECURSE does not.
LIST_DIRECTORIES enables user to control the behavior explicitly for
consistently for both GLOB and GLOB_RECURSE.
Diffstat (limited to 'Tests/RunCMake/file/GLOB.cmake')
-rw-r--r-- | Tests/RunCMake/file/GLOB.cmake | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Tests/RunCMake/file/GLOB.cmake b/Tests/RunCMake/file/GLOB.cmake new file mode 100644 index 0000000..3d577e3 --- /dev/null +++ b/Tests/RunCMake/file/GLOB.cmake @@ -0,0 +1,28 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/empty_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/dir 1 file" "test file") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 1/non_empty_dir/dir 1 subdir file" "test file") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/dir 2 file" "test file") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir file" "test file") + +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}") |