Mingw build: static link, posix g++, SDL2 list order.

This commit is contained in:
Muzychenko Andrey 2021-10-07 16:47:07 +03:00
parent ac289c7f48
commit 69027eca53
3 changed files with 10 additions and 4 deletions

View File

@ -14,6 +14,11 @@ if(WIN32)
list(APPEND SDL2_MIXER_PATH "${CMAKE_CURRENT_LIST_DIR}/Libs/SDL2_mixer")
endif()
# Link mingw libs static
if(MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
endif()
# SDL2main is not needed
set(SDL2_BUILDING_LIBRARY ON)
@ -195,8 +200,8 @@ target_link_libraries(SpaceCadetPinball ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY})
# On Windows, copy DLL to output
if(WIN32)
list(POP_BACK SDL2_LIBRARY SDL2_DLL_PATH)
list(POP_BACK SDL2_MIXER_LIBRARY SDL2_MIXER_DLL_PATH)
list(GET SDL2_LIBRARY -1 SDL2_DLL_PATH)
list(GET SDL2_MIXER_LIBRARY -1 SDL2_MIXER_DLL_PATH)
get_filename_component(SDL2_DLL_PATH ${SDL2_DLL_PATH} DIRECTORY)
get_filename_component(SDL2_MIXER_DLL_PATH ${SDL2_MIXER_DLL_PATH} DIRECTORY)
if(MINGW)

View File

@ -152,7 +152,7 @@ IF(SDL2_LIBRARY_TEMP)
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
SET(SDL2_LIBRARY_TEMP ${CMAKE_THREAD_LIBS_INIT} ${SDL2_LIBRARY_TEMP})
ENDIF(NOT APPLE)
# For MinGW library

View File

@ -2,7 +2,8 @@ set(TOOLCHAIN_PREFIX "x86_64-w64-mingw32")
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PREFIX}-g++")
#posix for std::this_thread, might work with just g++
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PREFIX}-g++-posix")
set(CMAKE_C_COMPILER "${TOOLCHAIN_PREFIX}-gcc")
set(CMAKE_OBJCOPY "${TOOLCHAIN_PREFIX}-objcopy")
set(CMAKE_STRIP "${TOOLCHAIN_PREFIX}-strip")