Skip to content

Commit

Permalink
Add support for MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
sewbacca committed Nov 25, 2023
1 parent 99e7022 commit b08aa24
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
39 changes: 28 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if(APPLE)
message(WARNING "Use the prebuilt .app or the xcode project in platform/xcode/ instead.")
endif()

if(MSVC)
if(MSVC OR MINGW)
set(LOVE_CONSOLE_EXE_NAME lovec)
endif()

Expand Down Expand Up @@ -179,7 +179,7 @@ if(MEGA)
else()
if(MSVC)
message(FATAL_ERROR "
It is currently only possible to build with megasource on Windows.
It is currently only possible to build with megasource or (experimental) mingw on Windows.
Please see https://github.com/love2d/megasource
")
endif()
Expand Down Expand Up @@ -222,6 +222,14 @@ Please see https://github.com/love2d/megasource
${ZLIB_LIBRARY}
)

if(MINGW)
set(LOVE_LINK_LIBRARIES
mingw32
SDL2main
${LOVE_LINK_LIBRARIES}
)
endif()

if(LOVE_MPG123)
find_package(MPG123 REQUIRED)
set(LOVE_LINK_LIBRARIES
Expand Down Expand Up @@ -1316,6 +1324,9 @@ set(LOVE_SRC_3P_ENET
add_library(love_3p_enet ${LOVE_SRC_3P_ENET})
target_link_libraries(love_3p_enet ${LOVE_LUA_LIBRARY})
target_include_directories(love_3p_enet PUBLIC src/libraries/enet/libenet/include)
if(MINGW)
target_link_libraries(love_3p_enet winmm.a)
endif()

#
# GLAD
Expand Down Expand Up @@ -1411,7 +1422,7 @@ set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT
src/libraries/glslang/glslang/OSDependent/osinclude.h
)

if(MSVC)
if(MSVC OR MINGW)
set(LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT
${LOVE_SRC_3P_GLSLANG_GLSLANG_OSDEPENDENT}
src/libraries/glslang/glslang/OSDependent/Windows/main.cpp
Expand Down Expand Up @@ -1511,7 +1522,13 @@ set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET

set(LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET)

if(MSVC)
if(MINGW)
set(WIN32_LIB_EXT .a)
else()
set(WIN32_LIB_EXT .lib)
endif()

if(MSVC OR MINGW)
set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET
${LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET}
src/libraries/luasocket/libluasocket/wsocket.c
Expand All @@ -1520,7 +1537,7 @@ if(MSVC)

set(LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET
${LOVE_LINK_L3P_LUASOCKET_LIBLUASOCKET}
ws2_32.lib
ws2_32${WIN32_LIB_EXT}
)
else()
set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET
Expand Down Expand Up @@ -1757,11 +1774,11 @@ link_directories(${LOVE_LINK_DIRS})

set(LOVE_RC)

if(MSVC)
if(MSVC OR MINGW)
set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES}
ws2_32.lib
winmm.lib
dwmapi.lib
ws2_32${WIN32_LIB_EXT}
winmm${WIN32_LIB_EXT}
dwmapi${WIN32_LIB_EXT}
)

set(LOVE_RC
Expand Down Expand Up @@ -1790,7 +1807,7 @@ add_executable(${LOVE_EXE_NAME} WIN32 src/love.cpp ${LOVE_RC})
target_link_libraries(${LOVE_EXE_NAME} ${LOVE_LIB_NAME})
set_target_properties(${LOVE_EXE_NAME} PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON)

if(MSVC)
if(MSVC OR MINGW)
add_executable(${LOVE_CONSOLE_EXE_NAME} src/love.cpp ${LOVE_RC})
target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME})
endif()
Expand Down Expand Up @@ -1818,7 +1835,7 @@ if(LOVE_MOVE_DLLS)
endforeach()
endif()

if (NOT MSVC)
if (NOT MSVC OR MINGW)
return()
endif()

Expand Down
Binary file modified extra/windows/love.rc
Binary file not shown.
4 changes: 3 additions & 1 deletion src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
#endif

// DLL-stuff.
#if defined(_MSC_VER)
#if defined(_MSC_VER) || defined(__MINGW32__)
# define LOVE_EXPORT __declspec(dllexport)
#elif defined(__GNUC__) || defined(__clang__)
# define LOVE_EXPORT __attribute__((visibility("default")))
Expand All @@ -116,8 +116,10 @@
#ifndef LOVE_WINDOWS_UWP
# define LOVE_LEGENDARY_CONSOLE_IO_HACK
#endif // LOVE_WINDOWS_UWP
#ifndef __MINGW32__
# define NOMINMAX
#endif
#endif

#if defined(LOVE_MACOSX) || defined(LOVE_IOS)
# define LOVE_LEGENDARY_APP_ARGV_HACK
Expand Down

0 comments on commit b08aa24

Please sign in to comment.