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

21 lines
675 B
CMake

function(target_source_of_source target)
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sos)
foreach (file ${ARGN})
get_filename_component(name ${file} NAME_WE)
set(sos_target sos-${target}-${name})
set(in ${CMAKE_CURRENT_SOURCE_DIR}/${file})
set(out ${CMAKE_CURRENT_BINARY_DIR}/sos/${file})
add_executable(${sos_target} ${in})
add_custom_command(
OUTPUT ${out}
COMMAND ${sos_target} > ${out}
DEPENDS ${sos_target}
COMMENT "generating ${file}")
target_sources(${target} PRIVATE ${out})
endforeach()
endfunction()