The file() Command
Let's learn about the file() command in CMake.
We'll cover the following...
This command provides all kinds of operations related to files:
Reading
Writing
Transferring
Locking
Archiving
It also provides modes to inspect the filesystem and operations on strings representing paths. Full details can be found in the online documentation.
Reading
The following modes are available:
file(READ <filename> <out> [OFFSET <o>] [LIMIT <max>] [HEX])
reads the file from<filename>
to the<out>
variable. The read optionally starts at offset<o>
and follows the optional limit of<max>
bytes. TheHEX flag
specifies that output should be converted to hexadecimal representation.file(STRINGS <filename> <out>)
reads strings from the file at<filename>
to the<out>
variable.file(<algorithm> <filename> <out>)
computes the<algorithm>
hash from the file at<filename>
and stores the result in the<out>
variable. ...