Skip to content

Commit

Permalink
Merge pull request #1985 from sewbacca/feature/mingw
Browse files Browse the repository at this point in the history
MinGW / MSYS2 Support
  • Loading branch information
slime73 authored Nov 26, 2023
2 parents 99e7022 + 11d4bdd commit e3a0ba3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
37 changes: 23 additions & 14 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 All @@ -188,7 +188,7 @@ Please see https://github.com/love2d/megasource
find_package(ModPlug REQUIRED)
find_package(OpenAL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main)
find_package(Theora REQUIRED)
find_package(Vorbis REQUIRED)
find_package(ZLIB REQUIRED)
Expand All @@ -198,7 +198,7 @@ Please see https://github.com/love2d/megasource
add_definitions(-D HAS_SOCKLEN_T)

set(LOVE_INCLUDE_DIRS
${SDL2_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS}
${VORBIS_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
Expand All @@ -210,7 +210,7 @@ Please see https://github.com/love2d/megasource

set(LOVE_LINK_LIBRARIES
${OPENGL_gl_LIBRARY}
${SDL2_LIBRARY}
${SDL2_LIBRARIES}
${FREETYPE_LIBRARY}
${OPENAL_LIBRARY}
${MODPLUG_LIBRARY}
Expand Down Expand Up @@ -1316,6 +1316,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 +1414,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 +1514,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 +1529,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 +1766,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 +1799,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 +1827,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 e3a0ba3

Please sign in to comment.