MinGW: Cross compiling broken: CMake can't find windres and ignores CMAKE_RC_COMPILER.
I'm trying to cross-compile glfw-3.3.2 for Windows from Debian Buster. I'm using mingw-w64 for my compiler, and all the tools have the x86_64-w64-mingw32- prefix, including windres. I'm using the version of CMake that came with my distribution, which is 3.13.4. Without editing anything except at the generator screen, I get the following error:
[ 15%] Building RC object examples/CMakeFiles/wave.dir/glfw.rc.obj /bin/sh: 1: windres: not found
At first I thought this was an error in glfw, but then I found that glfw by default sets it to what it should be, and that CMake didn't care:
Even after changing CMAKE_RC_COMPILER in the menu to where it was really located, it still gave me the same error as above, and the Makefiles hadn't changed from using windres instead of x86_64-w64-mingw32-windres. I eventually that CMakeFiles/3.13.4/CMakeRCCompiler.cmake in the build directory had "windres" hardcoded into it.
set(CMAKE_RC_COMPILER "windres") set(CMAKE_RC_COMPILER_ARG1 "") set(CMAKE_RC_COMPILER_LOADED 1) set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC) set(CMAKE_RC_OUTPUT_EXTENSION .obj) set(CMAKE_RC_COMPILER_ENV_VAR "RC")
Try to cross-compile any library that uses CMake with MinGW-w64 on Debian. The version that I know causes this error is CMake 3.13. I also ran into the same error when I tried to cross-compile zlib 1.2.11. CMakeFiles/3.13.4/CMakeRCCompiler.cmake had "windres" hardcoded into it in the build directory.