utils.cmake 587 B

12345678910111213141516
  1. # utils.cmake
  2. function(redefine_file_macro targetname)
  3. get_target_property(source_files "${targetname}" SOURCES)
  4. foreach(sourcefile ${source_files})
  5. get_property(defs SOURCE "${sourcefile}"
  6. PROPERTY COMPILE_DEFINITIONS)
  7. get_filename_component(filepath "${sourcefile}" ABSOLUTE)
  8. string(REPLACE ${PROJECT_SOURCE_DIR}/ "" relpath ${filepath})
  9. list(APPEND defs "__FILE__=\"${relpath}\"")
  10. set_property(
  11. SOURCE "${sourcefile}"
  12. PROPERTY COMPILE_DEFINITIONS ${defs}
  13. )
  14. endforeach()
  15. endfunction()