@@ -97,17 +97,9 @@ if (${PLATFORM} MATCHES "Android")
97
97
list (REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR} /shaders/shaders_basic_lighting.c)
98
98
99
99
elseif (${PLATFORM} MATCHES "Web" )
100
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os" )
101
- # Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
102
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s WASM=1 -s ASYNCIFY -s ALLOW_MEMORY_GROWTH=1 --shell-file ${CMAKE_SOURCE_DIR} /src/shell.html" )
103
- set (CMAKE_EXECUTABLE_SUFFIX ".html" )
104
-
105
- list (REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR} /others/raylib_opengl_interop.c)
106
-
107
- # Remove the -rdynamic flag because otherwise emscripten
108
- # does not generate HTML+JS+WASM files, only a non-working
109
- # and fat HTML
110
- string (REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} " )
100
+ set (example_sources) # clear example_sources
101
+ list (APPEND example_sources others/web_basic_window.c)
102
+ list (APPEND example_sources core/core_input_gestures_testbed.c)
111
103
112
104
elseif ("${PLATFORM} " STREQUAL "DRM" )
113
105
list (REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR} /others/rlgl_standalone.c)
@@ -165,10 +157,34 @@ foreach (example_source ${example_sources})
165
157
string (REGEX MATCH ".*/.*/" resources_dir ${example_source} )
166
158
string (APPEND resources_dir "resources" )
167
159
168
- if (${PLATFORM} MATCHES "Web" AND EXISTS ${resources_dir} )
169
- # The local resources path needs to be mapped to /resources virtual path
170
- string (APPEND resources_dir "@resources" )
171
- set_target_properties (${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir} " )
160
+ if (${PLATFORM} MATCHES "Web" )
161
+ target_compile_options (${example_name} PRIVATE -Os)
162
+ target_link_options (${example_name} PRIVATE
163
+ -sALLOW_MEMORY_GROWTH=1
164
+ -sEXPORTED_RUNTIME_METHODS=[requestFullscreen]
165
+ -sUSE_GLFW=3
166
+ --shell-file "${CMAKE_SOURCE_DIR} /src/shell.html"
167
+ )
168
+ set_target_properties (${example_name} PROPERTIES SUFFIX ".html" )
169
+
170
+ if (EXISTS ${resources_dir} )
171
+ # The local resources path needs to be mapped to /resources virtual path
172
+ string (APPEND resources_dir "@resources" )
173
+ set_target_properties (${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir} " )
174
+ endif ()
175
+
176
+ if (${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3" )
177
+ target_link_options (${example_name} PUBLIC "-sMIN_WEBGL_VERSION=2" )
178
+ target_link_options (${example_name} PUBLIC "-sMAX_WEBGL_VERSION=2" )
179
+ endif ()
180
+
181
+ # Checks if OSX and links appropriate frameworks (Only required on MacOS)
182
+ if (APPLE )
183
+ target_link_libraries (${example_name} "-framework IOKit" )
184
+ target_link_libraries (${example_name} "-framework Cocoa" )
185
+ target_link_libraries (${example_name} "-framework OpenGL" )
186
+ endif ()
187
+
172
188
endif ()
173
189
endforeach ()
174
190
0 commit comments