aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-01-21 09:52:08 +0100
committerGitHub <noreply@github.com>2019-01-21 09:52:08 +0100
commit734999301589cf007bbd974aba19e5774cc39c3c (patch)
tree23858fdafcf424302c7b7454f05bee230a4d3f1e /examples
parent0d2cfce18edf8016b7ff865aafab25ee7a352507 (diff)
parent3065cbbce9ac3bab73552d4ae39df43ad3aeb414 (diff)
downloadraylib-734999301589cf007bbd974aba19e5774cc39c3c.tar.gz
raylib-734999301589cf007bbd974aba19e5774cc39c3c.zip
Merge pull request #730 from pbalcer/examples-web-fix-preload
cmake: fix resource preloading for web examples
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 1d4fdd79..4b04d45a 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -56,7 +56,10 @@ if(${PLATFORM} MATCHES "Android")
elseif(${PLATFORM} MATCHES "Web")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1")
+ # Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html")
+
set(OUTPUT_EXT ".html")
endif()
@@ -77,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")