Fix [type] command file url forward slashes issue when use mingw

This commit is contained in:
画卦伏羲 2023-07-28 01:34:20 +08:00 committed by GitHub
parent 4420f9b33b
commit 3c98026a1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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