Open oznogon opened 3 years ago
Project gave up on an upstream fix. For anyone who comes across this, here's what was added to CMake as a workaround.
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
execute_process(COMMAND sed -i -e s/Windows.h/windows.h/ "${CMAKE_CURRENT_BINARY_DIR}/discord/c/discord_game_sdk.h")
endif()
Describe the bug
When cross-compiling a project implementing the Game SDK on case-sensitive filesystems with mingw, compilation for Windows targets can fail because
Windows
is capitalized in#include <Windows.h>
.Steps to reproduce
Build any project that includes the Discord Game SDK (
#include <discord_game_sdk.h>
) with a Windows build target using mingw on a case-sensitive filesystem. For example, this is reproducible when cross-compiling a project using Ubuntu 18.04, 20.04, and Debian 10.5, including builds from WSL.Expected behavior
Cross-compiling for Windows works without errors.
Observed behavior
A fatal compiler error terminates compilation because the case-sensitive
Windows.h
doesn't exist:Screenshots
N/A
Implementation specifics
Additional context
Workarounds:
In line 5 of
c/discord_game_sdk.h
in the Game SDK, lowercaseWindows.h
.OR add conditional defines to
discord_game_sdk.h
to use the lowercase filename, depending on your project:For an automated build process, hack through it with a regex (
s/Windows\.h/windows\.h/
).OR, on the build system, symlink mingw's
Windows.h
towindows.h
. Implementation can vary between operating systems and distributions.OR, create a
Windows.h
in the project that does nothing but includewindows.h
.OR, conditionally omit Discord integration from the project when cross-compiling Windows builds. :(
Context: https://stackoverflow.com/questions/15466613/lowercase-windows-h-and-uppercase-windows-h-difference
Windows.h
windows.h
windows.h
(or any arbitrary case usage) should also work on WindowsSee also:
windows.h
: https://github.com/discord/discord-rpc/blob/master/src/dllmain.cpp#L1discord-rpc
's Travis pipelines used mingw: https://github.com/discord/discord-rpc/pull/130