Browse Source

Update gen_c_array

This renames it to "file_to_data" and adds an extra parameter that will
control whether an ending zero byte is added or not.
master
Gavin Howard 4 years ago
parent
commit
013a6802b0
Signed by: gavin GPG Key ID: C08038BDF280D33E
  1. 4
      functions.cmake
  2. 8
      gen_array.cmake.in

4
functions.cmake

@ -60,7 +60,7 @@ cmake_policy(SET CMP0026 NEW)
# the name of the array; target is the CMake target that other targets can then
# depend on; and start_line is the line in infile that will be the first line
# in the array, which is useful for excluding header comments.
function(gen_c_array infile outfile array_name target start_line)
function(file_to_data infile outfile array_name target start_line ctsr)
set(script "${CMAKE_CURRENT_BINARY_DIR}/${target}_script.cmake")
@ -72,7 +72,7 @@ function(gen_c_array infile outfile array_name target start_line)
add_library("${target}" "${outfile}")
add_dependencies("${target}" "${target}_script")
endfunction(gen_c_array)
endfunction(file_to_data)
function(static_lib_path var lib_output_name)

8
gen_array.cmake.in

@ -67,5 +67,11 @@ foreach(iter RANGE 1 ${start})
endforeach()
string(REGEX REPLACE ";" ",\n0x" output "${output}")
file(APPEND "@outfile@" "const char @array_name@[] = {0x${output},\n0x0};")
file(APPEND "@outfile@" "const char @array_name@[] = {0x${output}")
if (@cstr@)
file(APPEND "@outfile@" ",\n0x0")
endif()
file(APPEND "@outfile@" "};")

Loading…
Cancel
Save