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 /Help | |
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 'Help')
-rw-r--r-- | Help/command/file.rst | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst index 73d4cfa..2fe7414 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -92,9 +92,12 @@ store it in a ``<variable>``. :: - file(GLOB <variable> [RELATIVE <path>] [<globbing-expressions>...]) - file(GLOB_RECURSE <variable> [RELATIVE <path>] - [FOLLOW_SYMLINKS] [<globbing-expressions>...]) + file(GLOB <variable> + [LIST_DIRECTORIES true|false] [RELATIVE <path>] + [<globbing-expressions>...]) + file(GLOB_RECURSE <variable> [FOLLOW_SYMLINKS] + [LIST_DIRECTORIES true|false] [RELATIVE <path>] + [<globbing-expressions>...]) Generate a list of files that match the ``<globbing-expressions>`` and store it into the ``<variable>``. Globbing expressions are similar to @@ -102,6 +105,9 @@ regular expressions, but much simpler. If ``RELATIVE`` flag is specified, the results will be returned as relative paths to the given path. +By default ``GLOB`` lists directories - directories are omited in result if +``LIST_DIRECTORIES`` is set to false. + .. note:: We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is @@ -119,6 +125,11 @@ matched directory and match the files. Subdirectories that are symlinks are only traversed if ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to ``NEW``. +By default ``GLOB_RECURSE`` omits directories from result list - setting +``LIST_DIRECTORIES`` to true adds directories to result list. +If ``FOLLOW_SYMLINKS`` is given or policy :policy:`CMP0009` is not set to +``OLD`` then ``LIST_DIRECTORIES`` treats symlinks as directories. + Examples of recursive globbing include:: /dir/*.py - match all python files in /dir and subdirectories |