Issue using CMake with CodeBlocks and MSYS

Hello there! Arisotura here, from melonDS land.

So, here’s the thing. When I started development on melonDS, I used CodeBlocks as my IDE, along with the msys64 toolchain. The idea was to avoid using MSVC, and also keep melonDS portable.

Flash forward to now. We’re using CMake, but the old CodeBlocks project for Windows has also stuck around (because it works, and getting shit working under Windows is a pain).

I’m aiming at getting rid of it. So far:

  • CMake has CodeBlocks generators, but not for using it with MSYS.
  • Upon closer inspection, standalone CMake-generated makefiles for MSYS and Unix are identical, the only variation is how Windows paths are laid out (/C/blarg vs C:/blarg).
  • Actually, this isn’t even a problem for MSYS. I generated standalone makefiles for both MSYS and Unix and both ran fine.
  • However, generating a CodeBlocks project with Unix makefiles isn’t working: it chokes on the link process.

I inspected one of those link.txt files to see why it was failing.

gcc-ar qcs libcore.a  CMakeFiles/core.dir/ARCodeList.cpp.obj CMakeFiles/core.dir/AREngine.cpp.obj CMakeFiles/core.dir/ARM.cpp.obj CMakeFiles/core.dir/ARMInterpreter.cpp.obj CMakeFiles/core.dir/ARMInterpreter_ALU.cpp.obj CMakeFiles/core.dir/ARMInterpreter_Branch.cpp.obj CMakeFiles/core.dir/ARMInterpreter_LoadStore.cpp.obj CMakeFiles/core.dir/Config.cpp.obj CMakeFiles/core.dir/CP15.cpp.obj CMakeFiles/core.dir/CRC32.cpp.obj CMakeFiles/core.dir/DMA.cpp.obj CMakeFiles/core.dir/GBACart.cpp.obj CMakeFiles/core.dir/GPU.cpp.obj CMakeFiles/core.dir/GPU2D.cpp.obj CMakeFiles/core.dir/GPU3D.cpp.obj CMakeFiles/core.dir/GPU3D_OpenGL.cpp.obj CMakeFiles/core.dir/GPU3D_Soft.cpp.obj CMakeFiles/core.dir/NDS.cpp.obj CMakeFiles/core.dir/NDSCart.cpp.obj CMakeFiles/core.dir/OpenGLSupport.cpp.obj CMakeFiles/core.dir/RTC.cpp.obj CMakeFiles/core.dir/Savestate.cpp.obj CMakeFiles/core.dir/SPI.cpp.obj CMakeFiles/core.dir/SPU.cpp.obj CMakeFiles/core.dir/Wifi.cpp.obj CMakeFiles/core.dir/WifiAP.cpp.obj
true

Turns out the issue wasn’t with the link command itself, but with the second line. For whatever reason, CMake adds that ‘true’ line at the end. I don’t quite see what it’s for, but the MSYS shell seems to silently ignore any ‘true’ or ‘false’ command.

On the other hand, CodeBlocks seems to be using its own shell thing, which does choke on the ‘true’ line. I removed those and was able to build a perfectly good melonDS executable.

(upon closer inspection, I do have a true.exe at /usr/bin in my msys64 directory; seems CodeBlocks is just failing to find it?)

So, any insight into this would be appreciated.

@brad.king

@Arisotura please try to narrow down your example to a small CMakeLists.txt file that still produces the true command in link.txt.