Skip to content

Commit

Permalink
Fix [type] command file url forward slashes issue when use mingw
Browse files Browse the repository at this point in the history
  • Loading branch information
FuXiii authored Jul 27, 2023
1 parent 4420f9b commit 3c98026
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions glslang/OSDependent/Web/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,28 @@ if(ENABLE_GLSLANG_JS)
endif()

if(NOT ENABLE_EMSCRIPTEN_ENVIRONMENT_NODE)
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)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
add_custom_command(TARGET glslang.js POST_BUILD
COMMAND type "${glslang_after_js_path}" >> "${glslang_js_path}")
COMMAND ${CMAKE_COMMAND} -E cat ${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js >> ${CMAKE_CURRENT_BINARY_DIR}/glslang.js
)
else()
add_custom_command(TARGET glslang.js POST_BUILD
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/glslang.after.js >> ${CMAKE_CURRENT_BINARY_DIR}/glslang.js)
if (MINGW)
message(FATAL_ERROR "Must use at least CMake 3.18")
endif()

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()
endif()
endif()

0 comments on commit 3c98026

Please sign in to comment.