Files
FastDeploy/external/utils.cmake
jiangjiajun 9d87046d78 first commit
2022-07-05 09:30:15 +00:00

16 lines
666 B
CMake

# This function comes from https://blog.csdn.net/yindongjie1221/article/details/90614261
function(redefine_file_macro targetname)
get_target_property(source_files "${targetname}" SOURCES)
foreach(sourcefile ${source_files})
get_property(defs SOURCE "${sourcefile}"
PROPERTY COMPILE_DEFINITIONS)
get_filename_component(filepath "${sourcefile}" ABSOLUTE)
string(REPLACE ${PROJECT_SOURCE_DIR}/ "" relpath ${filepath})
list(APPEND defs "__REL_FILE__=\"${relpath}\"")
set_property(
SOURCE "${sourcefile}"
PROPERTY COMPILE_DEFINITIONS ${defs}
)
endforeach()
endfunction()