Add MSYS2 support
This required proper ordering of libraries in the main build script and coming up with a workaround in the SDL2 finder to ensure -lmingw32 always came first in the link order.
This commit is contained in:
parent
622340e479
commit
ba625b652b
4 changed files with 30 additions and 13 deletions
|
|
@ -26,8 +26,8 @@
|
|||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Currently works with the following generators:
|
||||
# - Unix Makefiles
|
||||
# - Ninja
|
||||
# - Unix Makefiles (Linux, MSYS2)
|
||||
# - Ninja (Linux, MSYS2)
|
||||
# - Visual Studio
|
||||
|
||||
# Cache variable that allows you to point CMake at a directory containing
|
||||
|
|
@ -91,7 +91,24 @@ if(SDL2_FOUND)
|
|||
IMPORTED_LOCATION "${SDL2_LIBRARY}")
|
||||
|
||||
# SDL2main imported target.
|
||||
add_library(SDL2::SDL2main UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::SDL2main PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}")
|
||||
if(MINGW)
|
||||
# Gross hack to get mingw32 first in the linker order.
|
||||
add_library(SDL2::_SDL2main_detail UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::_SDL2main_detail PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}")
|
||||
|
||||
# Ensure that SDL2main comes before SDL2 in the linker order. CMake
|
||||
# isn't smart enough to keep proper ordering for indirect dependencies
|
||||
# so we have to spell it out here.
|
||||
target_link_libraries(SDL2::_SDL2main_detail INTERFACE SDL2::SDL2)
|
||||
|
||||
add_library(SDL2::SDL2main INTERFACE IMPORTED)
|
||||
set_target_properties(SDL2::SDL2main PROPERTIES
|
||||
IMPORTED_LIBNAME mingw32)
|
||||
target_link_libraries(SDL2::SDL2main INTERFACE SDL2::_SDL2main_detail)
|
||||
else()
|
||||
add_library(SDL2::SDL2main UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::SDL2main PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Currently works with the following generators:
|
||||
# - Unix Makefiles
|
||||
# - Ninja
|
||||
# - Unix Makefiles (Linux, MSYS2)
|
||||
# - Ninja (Linux, MSYS2)
|
||||
# - Visual Studio
|
||||
|
||||
# Cache variable that allows you to point CMake at a directory containing
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Currently works with the following generators:
|
||||
# - Unix Makefiles
|
||||
# - Ninja
|
||||
# - Unix Makefiles (Linux, MSYS2)
|
||||
# - Ninja (Linux, MSYS2)
|
||||
# - Visual Studio
|
||||
|
||||
# Cache variable that allows you to point CMake at a directory containing
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ set(DEHACKED_SOURCE_FILES
|
|||
set(SOURCE_FILES ${COMMON_SOURCE_FILES} ${GAME_SOURCE_FILES})
|
||||
set(SOURCE_FILES_WITH_DEH ${SOURCE_FILES} ${DEHACKED_SOURCE_FILES})
|
||||
|
||||
set(EXTRA_LIBS textscreen pcsound opl SDL2::SDL2main SDL2::SDL2 SDL2::mixer SDL2::net)
|
||||
set(EXTRA_LIBS SDL2::SDL2main SDL2::SDL2 SDL2::mixer SDL2::net textscreen pcsound opl)
|
||||
if(SAMPLERATE_FOUND)
|
||||
list(APPEND EXTRA_LIBS samplerate::samplerate)
|
||||
endif()
|
||||
|
|
@ -197,7 +197,7 @@ endif()
|
|||
|
||||
target_include_directories("${PROGRAM_PREFIX}setup"
|
||||
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
|
||||
target_link_libraries("${PROGRAM_PREFIX}setup" setup textscreen SDL2::SDL2main SDL2::SDL2 SDL2::mixer SDL2::net)
|
||||
target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::SDL2main SDL2::SDL2 SDL2::mixer SDL2::net setup textscreen)
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties("${PROGRAM_PREFIX}setup" PROPERTIES
|
||||
|
|
@ -207,9 +207,9 @@ endif()
|
|||
add_executable(midiread midifile.c z_native.c i_system.c m_argv.c m_misc.c)
|
||||
target_compile_definitions(midiread PRIVATE "-DTEST")
|
||||
target_include_directories(midiread PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
|
||||
target_link_libraries(midiread PRIVATE SDL2::SDL2)
|
||||
target_link_libraries(midiread SDL2::SDL2main SDL2::SDL2)
|
||||
|
||||
add_executable(mus2mid mus2mid.c memio.c z_native.c i_system.c m_argv.c m_misc.c)
|
||||
target_compile_definitions(mus2mid PRIVATE "-DSTANDALONE")
|
||||
target_include_directories(mus2mid PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
|
||||
target_link_libraries(mus2mid PRIVATE SDL2::SDL2)
|
||||
target_link_libraries(mus2mid SDL2::SDL2main SDL2::SDL2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue