1# - Macros for simplifying development with Emscripten 2# 3# Embed file into the virtual filesystem of given executable 4# emscripten_embed_file(MyExecutable 5# path/to/file 6# /path/in/virtual/filesystem) 7# File path is absolute or relative to current source directory, path in 8# virtual filesystem should start with `/`. Supports both files and 9# directories. Useful e.g. in case of unit tests where you are testing output 10# against some external file and manually embedding that file just to test on 11# Emscripten is just not worth it. 12# 13 14function(emscripten_embed_file target file destination) 15 get_filename_component(absolute_file ${file} ABSOLUTE) 16 get_target_property(${target}_LINK_FLAGS ${target} LINK_FLAGS) 17 if(NOT ${target}_LINK_FLAGS) 18 set(${target}_LINK_FLAGS ) 19 endif() 20 set_target_properties(${target} PROPERTIES LINK_FLAGS "${${target}_LINK_FLAGS} --embed-file ${absolute_file}@${destination}") 21endfunction() 22