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 80b3b82332 [RELEASE] u22-v04
This version is submitted for U22 final presentation. (squashed 158 commits)
2021-02-07 00:00:00 +00:00

23 lines
778 B
CMake

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