This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
LEFTONE/cmake/anysrc.cmake
falsycat 80b3b82332 [RELEASE] u22-v04
This version is submitted for U22 final presentation. (squashed 158 commits)
2021-02-07 00:00:00 +00:00

20 lines
668 B
CMake

function(target_any_sources target)
set(bin2c ${LEFTONE_TOOL_DIR}/bin2c.sh)
foreach (path ${ARGN})
get_filename_component(dirname ${path} DIRECTORY)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/anysrc/${dirname})
set(name ${target}_${path}_)
set(in ${CMAKE_CURRENT_SOURCE_DIR}/${path})
set(out ${CMAKE_CURRENT_BINARY_DIR}/anysrc/${path})
add_custom_command(
OUTPUT ${out}.c ${out}.h
COMMAND cat ${in} | bash ${bin2c} ${name} ${out}
DEPENDS ${path} ${bin2c}
COMMENT "converting ${path} to C header"
VERBATIM)
target_sources(${target} PRIVATE ${out}.c ${out}.h)
endforeach()
endfunction()