Add simple web backend
This commit is contained in:
parent
7c31143d26
commit
fe45e382bc
5 changed files with 55 additions and 3 deletions
|
@ -55,8 +55,8 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|||
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
set(ENABLE_WINDOWS ON)
|
||||
set(ENABLE_VULKAN ON)
|
||||
set(ENABLE_WINDOWS TRUE)
|
||||
set(ENABLE_VULKAN TRUE)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore")
|
||||
|
@ -65,6 +65,13 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore")
|
|||
set(ENABLE_UWP TRUE)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
|
||||
message("Web build detected!")
|
||||
|
||||
set(ENABLE_WEB TRUE)
|
||||
set(ENABLE_WEBGPU TRUE)
|
||||
endif()
|
||||
|
||||
set(CROSS_LIBS
|
||||
spirv-cross-core
|
||||
spirv-cross-glsl
|
||||
|
|
|
@ -35,7 +35,7 @@ endfunction()
|
|||
|
||||
# add shaders to target
|
||||
function(add_shaders)
|
||||
if(NOT ENABLE_IOS AND NOT ENABLE_TVOS)
|
||||
if(NOT ENABLE_IOS AND NOT ENABLE_TVOS AND NOT ENABLE_WEB)
|
||||
cmake_parse_arguments(ARGS "" "TARGET" "SHADERS" ${ARGN})
|
||||
|
||||
foreach(SHADER_FILENAME ${ARGS_SHADERS})
|
||||
|
|
|
@ -17,3 +17,7 @@ endif()
|
|||
if(ENABLE_TVOS)
|
||||
add_subdirectory(tvos)
|
||||
endif()
|
||||
|
||||
if(ENABLE_WEB)
|
||||
add_subdirectory(web)
|
||||
endif()
|
34
platforms/web/CMakeLists.txt
Normal file
34
platforms/web/CMakeLists.txt
Normal file
|
@ -0,0 +1,34 @@
|
|||
include(../../cmake/AddPlatformExecutable.cmake)
|
||||
|
||||
add_platform(
|
||||
MAIN_FILE
|
||||
main.cpp.in
|
||||
LINK_LIBRARIES
|
||||
Core
|
||||
)
|
||||
|
||||
function(add_platform_commands target)
|
||||
set_target_properties(
|
||||
${target}
|
||||
PROPERTIES
|
||||
SUFFIX ".html"
|
||||
)
|
||||
|
||||
set(DUMMY_NAME ${target}-CopyShaders)
|
||||
|
||||
add_custom_target(${DUMMY_NAME} ALL DEPENDS ${CMAKE_BINARY_DIR}/${target}-dummy)
|
||||
|
||||
if(ENABLE_MACOS)
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${target}-dummy
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/../Resources/shaders
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/../Resources/shaders
|
||||
)
|
||||
else()
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${target}-dummy
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/shaders
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/shaders
|
||||
)
|
||||
endif()
|
||||
|
||||
add_dependencies(${target} ${DUMMY_NAME})
|
||||
endfunction()
|
7
platforms/web/main.cpp.in
Normal file
7
platforms/web/main.cpp.in
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
printf("Hello, world!\n");
|
||||
|
||||
return 0;
|
||||
}
|
Reference in a new issue