Browse Source

cmake: preload resources into web examples

No examples built for the Web platform functioned properly due to lack
of resources in the virtual file system provided by emscripten.

This patch addresses this problem by adding
'--preload-file local_path/resources@resources' emcc option to link
flags whenever necessary.
pull/730/head
Piotr Balcer 6 years ago
parent
commit
3065cbbce9
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      examples/CMakeLists.txt

+ 9
- 0
examples/CMakeLists.txt View File

@ -80,6 +80,15 @@ foreach(example_source ${example_sources})
add_executable(${example_name} ${example_source}) add_executable(${example_name} ${example_source})
target_link_libraries(${example_name} raylib) target_link_libraries(${example_name} raylib)
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
string(APPEND resources_dir "resources")
if(${PLATFORM} MATCHES "Web" AND EXISTS ${resources_dir})
# The local resources path needs to be mapped to /resources virtual path
string(APPEND resources_dir "@resources")
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
endif()
endforeach() endforeach()
if (${PLATFORM} MATCHES "Desktop") if (${PLATFORM} MATCHES "Desktop")

Loading…
Cancel
Save