Can a MINGW definition be added as a platform in playdate_game.cmake for compiling for simulator using (mingw) gcc?

On windows it is possible to use the mingw32 (64bit) gcc compiler instead of visual studio c compiler as well and all thats needed is to add a MINGW definition in playdate_game.cmake

like this :

elseif (MINGW)
    add_custom_command(
        TARGET ${PLAYDATE_GAME_NAME} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy
        ${CMAKE_CURRENT_BINARY_DIR}/lib${PLAYDATE_GAME_NAME}.dll
        ${CMAKE_CURRENT_SOURCE_DIR}/Source/pdex.dll)

then people can run a msys2 prompt with mingw32 (64 bit version) and run
cmake .. -G "MSYS Makefiles" to generate the make file and then
make to compile the pdex.dll etc

this dll loads fine in the simulator when i tested it.

i think this setup might be easier to setup for compiling C programs with visual studio code if people already have that installed as you can load a msys prompt inside visual studio code. Its how i usually compile windows program's using gcc (mingw) toolchains in windows

I did not test it but theoretically it might allow for debugging using gdb debugger inside visual studio code as well

5 Likes

+1 would love to have clang added to the cmake for windows sim

MSVC is becoming increasingly out of date, both with modern C standards (visual studio still barfs on designated initializers), as well as common extensions (e.g. attribute((cleanup)) that all other compilers support (clang, gcc, hell even intel's obscure compiler supports this!).

Just filed an merge request for adding this. Thanks! :slight_smile:

4 Likes

thank you for doing this

1 Like