| 1 |
# |
| 2 |
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <[email protected]> |
| 3 |
# |
| 4 |
# Redistribution and use is allowed according to the terms of the New |
| 5 |
# BSD license. |
| 6 |
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
| 7 |
# |
| 8 |
|
| 9 |
#.rst: |
| 10 |
# GetFilesList |
| 11 |
# ------------ |
| 12 |
# |
| 13 |
# This is a helper script for FindABImap.cmake. |
| 14 |
# |
| 15 |
# Search in the provided directories for files matching the provided pattern. |
| 16 |
# The list of files is then written to the output file. |
| 17 |
# |
| 18 |
# Expected defined variables |
| 19 |
# -------------------------- |
| 20 |
# |
| 21 |
# ``DIRECTORIES``: |
| 22 |
# Required, expects a list of directories paths. |
| 23 |
# |
| 24 |
# ``FILES_PATTERNS``: |
| 25 |
# Required, expects a list of patterns to be used to search files |
| 26 |
# |
| 27 |
# ``OUTPUT_PATH``: |
| 28 |
# Required, expects the output file path. |
| 29 |
|
| 30 |
if (NOT DEFINED DIRECTORIES) |
| 31 |
message(SEND_ERROR "DIRECTORIES not defined") |
| 32 |
endif() |
| 33 |
|
| 34 |
if (NOT DEFINED FILES_PATTERNS) |
| 35 |
message(SEND_ERROR "FILES_PATTERNS not defined") |
| 36 |
endif() |
| 37 |
|
| 38 |
if (NOT DEFINED OUTPUT_PATH) |
| 39 |
message(SEND_ERROR "OUTPUT_PATH not defined") |
| 40 |
endif() |
| 41 |
|
| 42 |
string(REPLACE " " ";" DIRECTORIES_LIST "${DIRECTORIES}") |
| 43 |
string(REPLACE " " ";" FILES_PATTERNS_LIST "${FILES_PATTERNS}") |
| 44 |
|
| 45 |
# Create the list of expressions for the files |
| 46 |
set(glob_expressions) |
| 47 |
foreach(dir ${DIRECTORIES_LIST}) |
| 48 |
foreach(exp ${FILES_PATTERNS_LIST}) |
| 49 |
list(APPEND glob_expressions |
| 50 |
"${dir}/${exp}" |
| 51 |
) |
| 52 |
endforeach() |
| 53 |
endforeach() |
| 54 |
|
| 55 |
# Create the list of files |
| 56 |
file(GLOB files ${glob_expressions}) |
| 57 |
|
| 58 |
# Write to the output |
| 59 |
file(WRITE ${OUTPUT_PATH} "${files}") |