aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPiotr Balcer <piotr@balcer.eu>2019-01-20 14:58:10 +0100
committerPiotr Balcer <piotr@balcer.eu>2019-01-20 15:24:30 +0100
commit3065cbbce9ac3bab73552d4ae39df43ad3aeb414 (patch)
tree23858fdafcf424302c7b7454f05bee230a4d3f1e /examples
parent1bfa1b8696d45eba7cd4d3ab35d0486943c2b1bc (diff)
downloadraylib-3065cbbce9ac3bab73552d4ae39df43ad3aeb414.tar.gz
raylib-3065cbbce9ac3bab73552d4ae39df43ad3aeb414.zip
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.
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index b9cd3ff5..4b04d45a 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -80,6 +80,15 @@ foreach(example_source ${example_sources})
add_executable(${example_name} ${example_source})
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()
if (${PLATFORM} MATCHES "Desktop")