Introduce ListFile CMake module (#4081)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 4 Jul 2019 01:47:42 +0000 (10:47 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 4 Jul 2019 01:47:42 +0000 (10:47 +0900)
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 <jh1302.park@samsung.com>
cmake/modules/ListFile.cmake [new file with mode: 0644]

diff --git a/cmake/modules/ListFile.cmake b/cmake/modules/ListFile.cmake
new file mode 100644 (file)
index 0000000..aee0d16
--- /dev/null
@@ -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)