一、函数原型
file(READ <filename> <variable>[OFFSET <offset>] [LIMIT <max-in>] [HEX])
Read content from a file called <filename>
and store it in a <variable>
. Optionally start from the given <offset>
and read at most <max-in>
bytes. The HEX
option causes data to be converted to a hexadecimal representation (useful for binary data).
二、测试案例
CMakeLists.txt 中添加如下代码:
# 读取include/hello.h文件内容
file(READ include/hello.h HelloContent)
message("${HelloContent}")