From 86a9f01dab7224db6c386b71fb3adfb6bdeb3424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Nov 2019 17:35:05 +0100 Subject: [PATCH] modules: link to all dependencies of statically-built SDL on Windows. --- doc/changelog.dox | 2 ++ modules/FindSDL2.cmake | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/doc/changelog.dox b/doc/changelog.dox index a80aa7ccb..5fbc172d4 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -93,6 +93,8 @@ See also: - Fixed a bad interaction between @ref Magnum/Platform/AbstractXApplication.h and @ref Magnum/Platform/GlfwApplication.h (see [mosra/magnum#389](https://github.com/mosra/magnum/pull/389)) +- `FindSDL2.cmake` got updated to link to all dependencies when using a + statically built SDL on Windows @subsection changelog-latest-bugfixes Bug fixes diff --git a/modules/FindSDL2.cmake b/modules/FindSDL2.cmake index 50ab04529..b628e41f5 100644 --- a/modules/FindSDL2.cmake +++ b/modules/FindSDL2.cmake @@ -178,6 +178,29 @@ if(NOT TARGET SDL2::SDL2) set_property(TARGET SDL2::SDL2 APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${_SDL2_FRAMEWORK_LIBRARIES}) endif() + + # Windows dependencies for a static library. Unfortunately there's no + # easy way to figure out if a *.lib is static or dynamic, so we're + # adding only if a DLL is not found. + if(CORRADE_TARGET_WINDOWS AND NOT CORRADE_TARGET_WINDOWS_RT AND SDL2_DLL_RELEASE AND NOT SDL2_DLL_DEBUG) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY INTERFACE_LINK_LIBRARIES + # https://github.com/SDL-mirror/SDL/blob/release-2.0.10/CMakeLists.txt#L1338 + user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32 + # https://github.com/SDL-mirror/SDL/blob/release-2.0.10/CMakeLists.txt#L1384 + dinput8) + # https://github.com/SDL-mirror/SDL/blob/release-2.0.10/CMakeLists.txt#L1422 + # additionally has dxerr for MSVC if DirectX SDK is not used, but + # according to https://walbourn.github.io/wheres-dxerr-lib/ this + # thing is long deprecated. + if(MINGW) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY INTERFACE_LINK_LIBRARIES + # https://github.com/SDL-mirror/SDL/blob/release-2.0.10/CMakeLists.txt#L1386 + dxerr8 + # https://github.com/SDL-mirror/SDL/blob/release-2.0.10/CMakeLists.txt#L1388 + mingw32) + endif() + endif() + else() add_library(SDL2::SDL2 INTERFACE IMPORTED) endif()