cmake-bin2h icon indicating copy to clipboard operation
cmake-bin2h copied to clipboard

Pure CMake function to convert any file into C/C++ header, implemented with only CMake commands.

bin2h.cmake

Pure CMake function to convert any file into C/C++ header, implemented with only CMake commands.

Example Usage

include(bin2h.cmake)
...
message("Embedding following files into header file ${HEADER_FILE}")
foreach(file ${SOURCE_FILES})
    message("   ${file}")

    get_filename_component(variableName ${file} NAME)

    bin2h(SOURCE_FILE ${file} HEADER_FILE ${HEADER_FILE} VARIABLE_NAME ${variableName} APPEND NULL_TERMINATE)
    file(APPEND ${HEADER_FILE} "\n")
endforeach()