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 84c3a02b9a [RELEASE] u22-v03
This version is submitted to U22 breau.
2020-09-14 00:00:00 +00:00

21 lines
723 B
CMake

function(target_any_sources target)
set(bin2c ${LEFTONE_TOOL_DIR}/bin2c.sh)
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
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} | ${bin2c} ${name} ${out}
DEPENDS ${path} ${bin2c}
COMMENT "converting ${path} to C header")
target_sources(${target} PRIVATE ${out}.c ${out}.h)
endforeach()
endfunction()