VTK  9.1.0
Functions
vtkEncodeString.cmake File Reference

This module contains the vtk_encode_string function which may be used to turn a file into a C string. More...

Go to the source code of this file.

Functions

function vtk_encode_string ()
 Encode a file as a C string at build time.
 

Detailed Description

This module contains the vtk_encode_string function which may be used to turn a file into a C string.

This is primarily used within a program so that the content does not need to be retrieved from the filesystem at runtime, but can still be developed as a standalone file.

Definition in file vtkEncodeString.cmake.

Function Documentation

◆ vtk_encode_string()

function vtk_encode_string ( )

Encode a file as a C string at build time.

Adds a rule to turn a file into a C string. Note that any Unicode characters will not be replaced with escaping, so it is recommended to avoid their usage in the input.

INPUT <input>
[NAME <name>]
[EXPORT_SYMBOL <symbol>]
[EXPORT_HEADER <header>]
[HEADER_OUTPUT <variable>]
[SOURCE_OUTPUT <variable>]
[BINARY] [NUL_TERMINATE])
function vtk_encode_string()
Encode a file as a C string at build time.

The only required variable is INPUT, however, it is likely that at least one of HEADER_OUTPUT or SOURCE_OUTPUT will be required to add them to a library.

  • INPUT: (Required) The path to the file to be embedded. If a relative path is given, it will be interpreted as being relative to CMAKE_CURRENT_SOURCE_DIR.
  • NAME: This is the base name of the files that will be generated as well as the variable name for the C string. It defaults to the basename of the input without extensions.
  • EXPORT_SYMBOL: The symbol to use for exporting the variable. By default, it will not be exported. If set, EXPORT_HEADER must also be set.
  • EXPORT_HEADER: The header to include for providing the given export symbol. If set, EXPORT_SYMBOL should also be set.
  • HEADER_OUTPUT: The variable to store the generated header path.
  • SOURCE_OUTPUT: The variable to store the generated source path.
  • BINARY: If given, the data will be written as an array of unsigned char bytes.
  • NUL_TERMINATE: If given, the binary data will be NUL-terminated. Only makes sense with the BINARY flag. This is intended to be used if embedding a file as a C string exceeds compiler limits on string literals in various compilers.

Definition at line 53 of file vtkEncodeString.cmake.