diff --git a/CMakeLists.txt b/CMakeLists.txt index 72f5f881..2cb8eb16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,8 +159,8 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" AND NOT MSVC) add_compile_options(-fno-exceptions) endif() - if(NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") - # Error if there's symbols that are not found at link time. + if(NOT (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")) + # Error if there's symbols that are not found at link time. Some linkers do not support this flag. if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") add_link_options("-Wl,-undefined,error") elseif(NOT APPLE) diff --git a/glslang/OSDependent/Web/CMakeLists.txt b/glslang/OSDependent/Web/CMakeLists.txt index 5bfbed41..6232b809 100644 --- a/glslang/OSDependent/Web/CMakeLists.txt +++ b/glslang/OSDependent/Web/CMakeLists.txt @@ -53,6 +53,9 @@ if(ENABLE_GLSLANG_JS) target_link_libraries(glslang.js "-s ALLOW_MEMORY_GROWTH=1") target_link_libraries(glslang.js "-s FILESYSTEM=0") + # We use ccall in glslang.pre.js, so make sure it's exposed + target_link_libraries(glslang.js "-s EXPORTED_RUNTIME_METHODS=ccall") + if(ENABLE_EMSCRIPTEN_SINGLE_FILE) target_link_libraries(glslang.js "-s SINGLE_FILE=1") endif() @@ -64,8 +67,18 @@ if(ENABLE_GLSLANG_JS) endif() if(NOT ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE) - add_custom_command(TARGET glslang.js POST_BUILD - COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js >> ${CMAKE_CURRENT_BINARY_DIR}/glslang.js) + if (CMAKE_HOST_SYSTEM MATCHES "Windows.*") + # There are several ways we could append one file to another on Windows, but unfortunately 'cat' is not one of them + # (there is no 'cat' command in cmd). Also, since this will ultimately run in cmd and not pwsh, we need to ensure + # Windows path separators are used. + file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/glslang.js" glslang_js_path) + file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js" glslang_after_js_path) + add_custom_command(TARGET glslang.js POST_BUILD + COMMAND type "${glslang_after_js_path}" >> "${glslang_js_path}") + else() + add_custom_command(TARGET glslang.js POST_BUILD + COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js >> ${CMAKE_CURRENT_BINARY_DIR}/glslang.js) + endif() endif() endif() endif() diff --git a/glslang/OSDependent/Web/glslang.pre.js b/glslang/OSDependent/Web/glslang.pre.js index 46a56950..390390e9 100644 --- a/glslang/OSDependent/Web/glslang.pre.js +++ b/glslang/OSDependent/Web/glslang.pre.js @@ -25,7 +25,7 @@ Module['compileGLSLZeroCopy'] = function(glsl, shader_stage, gen_debug, spirv_ve var p_output = Module['_malloc'](4); var p_output_len = Module['_malloc'](4); - var id = ccall('convert_glsl_to_spirv', + var id = Module['ccall']('convert_glsl_to_spirv', 'number', ['string', 'number', 'boolean', 'number', 'number', 'number'], [glsl, shader_stage_int, gen_debug, spirv_version_int, p_output, p_output_len]);