mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-24 21:38:39 -04:00
on Windows first search for SDL2 libraries, then download from libsdl.org (#388)
* on Windows first search for SDL2 libraries, then download from libsdl.org * add mingw dependecies * get runtime dependencies for SDL_Mixer and libmodplug on MinGW * search for SDL2 libs first, install libfluidsynth if found on MinGW * use target filename * don't install DLLs to target file dir * fix typo * search for DLLs names using dlltool * little cleanup
This commit is contained in:
parent
7b0cf3f333
commit
123423c7ad
@ -6,8 +6,8 @@ include(ExternalProject)
|
||||
# Adds the cmake directory to the CMake include path.
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# 3.12 is needed for modern FindPython.
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
# 3.16 is needed for GET_RUNTIME_DEPENDENCIES.
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project("Woof"
|
||||
VERSION 8.1.0
|
||||
DESCRIPTION "Woof! is a continuation of Lee Killough's Doom source port MBF targeted at modern systems."
|
||||
@ -57,7 +57,8 @@ check_symbol_exists(strsignal "string.h" HAVE_STRSIGNAL)
|
||||
# In some instances, we can do useful things if a library can't be found.
|
||||
|
||||
# SDL2. On Windows, we use the official development library.
|
||||
if(NOT SDL2_DIR)
|
||||
find_package(SDL2 2.0.7)
|
||||
if(NOT SDL2_FOUND)
|
||||
if(WIN32)
|
||||
message(STATUS "Downloading SDL2 Development Library...")
|
||||
if(MSVC)
|
||||
@ -78,12 +79,13 @@ if(NOT SDL2_DIR)
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
set(SDL2_DIR "${CMAKE_CURRENT_BINARY_DIR}/SDL2-2.0.18")
|
||||
find_package(SDL2)
|
||||
endif()
|
||||
endif()
|
||||
find_package(SDL2 2.0.7)
|
||||
|
||||
# SDL2_mixer. On Windows, we use the official development library.
|
||||
if(NOT SDL2_MIXER_DIR)
|
||||
find_package(SDL2_mixer 2.0.2)
|
||||
if(NOT SDL2_MIXER_FOUND)
|
||||
if(WIN32)
|
||||
message(STATUS "Downloading SDL2_mixer Development Library...")
|
||||
if(MSVC)
|
||||
@ -104,12 +106,13 @@ if(NOT SDL2_MIXER_DIR)
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
set(SDL2_MIXER_DIR "${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer-2.0.4")
|
||||
find_package(SDL2_mixer)
|
||||
endif()
|
||||
endif()
|
||||
find_package(SDL2_mixer 2.0.2)
|
||||
|
||||
# SDL2_net. On Windows, we use the official development library.
|
||||
if(NOT SDL2_NET_DIR)
|
||||
find_package(SDL2_net)
|
||||
if(NOT SDL2_NET_FOUND)
|
||||
if(WIN32)
|
||||
message(STATUS "Downloading SDL2_net Development Library...")
|
||||
if(MSVC)
|
||||
@ -130,9 +133,9 @@ if(NOT SDL2_NET_DIR)
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
set(SDL2_NET_DIR "${CMAKE_CURRENT_BINARY_DIR}/SDL2_net-2.0.1")
|
||||
find_package(SDL2_net)
|
||||
endif()
|
||||
endif()
|
||||
find_package(SDL2_net)
|
||||
|
||||
# Python 3.
|
||||
#
|
||||
|
@ -176,7 +176,7 @@ endif()
|
||||
|
||||
# Assemble library files.
|
||||
set(WOOF_DLLS "")
|
||||
if(WIN32)
|
||||
if(WIN32 AND NOT MINGW)
|
||||
# SDL2
|
||||
list(APPEND WOOF_DLLS "${SDL2_DLL_DIR}/SDL2.dll")
|
||||
|
||||
@ -209,3 +209,66 @@ else()
|
||||
install(TARGETS woof RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
install(FILES ${WOOF_DLLS} DESTINATION .)
|
||||
|
||||
if(MINGW)
|
||||
find_program(DLLTOOL_EXECUTABLE
|
||||
NAMES dlltool dlltool.exe
|
||||
DOC "The path to the DLLTOOL utility"
|
||||
)
|
||||
|
||||
find_library(MODPLUG libmodplug)
|
||||
|
||||
if (MODPLUG AND DLLTOOL_EXECUTABLE)
|
||||
execute_process(COMMAND
|
||||
"${DLLTOOL_EXECUTABLE}" -I "${MODPLUG}"
|
||||
OUTPUT_VARIABLE MODPLUG_DLL_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
find_program(LIBMODPLUG_DLL NAMES ${MODPLUG_DLL_NAME})
|
||||
install(CODE "set(LIBMODPLUG_DLL \"${LIBMODPLUG_DLL}\")")
|
||||
else()
|
||||
message(WARNING "Can't find libmodplug")
|
||||
endif()
|
||||
|
||||
find_library(FLUIDSYNTH libfluidsynth)
|
||||
|
||||
if (FLUIDSYNTH AND DLLTOOL_EXECUTABLE)
|
||||
execute_process(COMMAND
|
||||
"${DLLTOOL_EXECUTABLE}" -I "${FLUIDSYNTH}"
|
||||
OUTPUT_VARIABLE FLUIDSYNTH_DLL_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
find_program(FLUIDSYNTH_DLL NAMES ${FLUIDSYNTH_DLL_NAME})
|
||||
install(CODE "set(FLUIDSYNTH_DLL \"${FLUIDSYNTH_DLL}\")")
|
||||
else()
|
||||
message(WARNING "Can't find libfluidsynth")
|
||||
endif()
|
||||
|
||||
install(CODE "set(MINGW_PATH \"${SDL2_DLL_DIR}\")")
|
||||
|
||||
install(CODE [[
|
||||
file(GET_RUNTIME_DEPENDENCIES
|
||||
EXECUTABLES "$<TARGET_FILE_DIR:woof>/$<TARGET_FILE_NAME:woof>"
|
||||
LIBRARIES ${LIBMODPLUG_DLL} ${FLUIDSYNTH_DLL}
|
||||
RESOLVED_DEPENDENCIES_VAR R_DEPS
|
||||
UNRESOLVED_DEPENDENCIES_VAR U_DEPS
|
||||
DIRECTORIES ${MINGW_PATH}
|
||||
PRE_EXCLUDE_REGEXES "api-ms-*" "ext-ms-*"
|
||||
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
|
||||
)
|
||||
|
||||
file(INSTALL
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
TYPE SHARED_LIBRARY
|
||||
FOLLOW_SYMLINK_CHAIN
|
||||
FILES ${R_DEPS} ${LIBMODPLUG_DLL} ${FLUIDSYNTH_DLL}
|
||||
)
|
||||
|
||||
list(LENGTH U_DEPS U_LENGTH)
|
||||
if("${U_LENGTH}" GREATER 0)
|
||||
message(WARNING "Unresolved dependencies: ${U_DEPS}")
|
||||
endif()
|
||||
]])
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user