Bin2H Module¶
See also
We use Bin2H functionality in the following CMake code:
Builtins for embedding bitcode containing our device side builtin functions.
Utilities to convert binary files to header files at build time using only CMake in script mode. To use these utilities:
include(Bin2H)
add_bin2h_command(my_bin
${path_to_input}/file.bin
${path_to_output}/file.h)
add_bin2h_target(my_bin
${path_to_input}/file.bin
${path_to_output}/file.h)
- add_bin2h_command¶
The
add_bin2h_command
macro creates a custom command which generates a header file from a binary file that can be included into source code. Additionally the macro specifies that the header file is generated at build time, this allows it to be used as a source file for libraries and exectuables.- Arguments:
variable
: The name of the variable to access the data in the header fileinput
: The binary input filepath to be made into a header fileoutput
: The header filepath to generate
- add_bin2h_target¶
The
add_bin2h_target
macro creates a custom target which generates a header file from a binary file that can be included into source code and use the target in CMake dependency tracking.- Arguments:
target
: The name of the target and the name of the variable to access the data in the header fileinput
: The binary input filepath to be made into a header fileoutput
: The header filepath to generate
Bin2HScript Module¶
Bin2HScript.cmake
is used as part of the implementation of
add_bin2h_command from the Bin2H Module.
A CMake script taking a file and embedding it in a C header with a given
variable name, to be invoked using -P
as part of an internal
CMAKE_COMMAND.
- BIN2H_INPUT_FILE¶
The binary input filepath to be made into a header file
- BIN2H_OUTUPUT_FILE¶
The header filepath to generate
- BIN2H_VARIABLE_NAME¶
The name of the variable to access the data in the header file