From 9d6f1f8399ada5559509cc7fa4daeb76dd481cfb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 4 Jul 2019 10:47:42 +0900 Subject: [PATCH] Introduce ListFile CMake module (#4081) This commit introduces ListFile CMake module which provides ListFile_Read helper. This helper makes it easy to create a list from text files. Signed-off-by: Jonghyun Park --- cmake/modules/ListFile.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cmake/modules/ListFile.cmake diff --git a/cmake/modules/ListFile.cmake b/cmake/modules/ListFile.cmake new file mode 100644 index 0000000..aee0d16 --- /dev/null +++ b/cmake/modules/ListFile.cmake @@ -0,0 +1,12 @@ +# Read a file and create a list variable +# +# HOW TO USE +# +# ListFile_Read("A.txt" A_LIST) +# +function(ListFile_Read FILENAME VARNAME) + file(READ ${FILENAME} content) + # Reference: http://public.kitware.com/pipermail/cmake/2007-May/014236.html + STRING(REGEX REPLACE "\n" ";" content "${content}") + set(${VARNAME} ${content} PARENT_SCOPE) +endfunction(ListFile_Read) -- 2.7.4