Browse Source

modules: make FindSDL2.cmake work with MinGW version 2.0.5 and higher.

Why nobody told me *all these years*?
pull/331/head
Vladimír Vondruš 7 years ago
parent
commit
53b583fe7a
  1. 3
      doc/changelog.dox
  2. 33
      modules/FindSDL2.cmake

3
doc/changelog.dox

@ -197,6 +197,9 @@ See also:
- @ref building-packages-msys "MSYS2 packages" are now in official - @ref building-packages-msys "MSYS2 packages" are now in official
repositories, installable directly via `pacman` repositories, installable directly via `pacman`
- `FindSDL2.cmake` was updated to work with MinGW version 2.0.5 and newer,
since these dropped the old directory hierarchy. Older versions have both
the original and the new hierarchy, so it should work with these as well.
- Updated *extremely* outdated Emscripten boilerplate from the - Updated *extremely* outdated Emscripten boilerplate from the
[base-emscripten bootstrap project](https://github.com/mosra/magnum-bootstrap/tree/base-emscripten) [base-emscripten bootstrap project](https://github.com/mosra/magnum-bootstrap/tree/base-emscripten)
(the HTML markup was unchanged since 2013, heh) (the HTML markup was unchanged since 2013, heh)

33
modules/FindSDL2.cmake

@ -45,11 +45,29 @@
if(CORRADE_TARGET_EMSCRIPTEN) if(CORRADE_TARGET_EMSCRIPTEN)
set(_SDL2_PATH_SUFFIXES SDL) set(_SDL2_PATH_SUFFIXES SDL)
else() else()
# Precompiled libraries for Windows are in x86/x64 subdirectories set(_SDL2_PATH_SUFFIXES SDL2)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(WIN32)
set(_SDL_LIBRARY_PATH_SUFFIX lib/x64) # Precompiled libraries for MSVC are in x86/x64 subdirectories
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) if(MSVC)
set(_SDL_LIBRARY_PATH_SUFFIX lib/x86) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_SDL2_LIBRARY_PATH_SUFFIX lib/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(_SDL2_LIBRARY_PATH_SUFFIX lib/x86)
endif()
# Both includes and libraries for MinGW are in some directory deep
# inside. There's also a CMake config file but it has HARDCODED path
# to /opt/local/i686-w64-mingw32, which doesn't make ANY SENSE,
# especially on Windows.
elseif(MINGW)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_SDL2_LIBRARY_PATH_SUFFIX x86_64-w64-mingw32/lib)
list(APPEND _SDL2_PATH_SUFFIXES x86_64-w64-mingw32/include/SDL2)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(_SDL2_LIBRARY_PATH_SUFFIX i686-w64-mingw32/lib)
list(APPEND _SDL2_PATH_SUFFIXES i686-w64-mingw32/include/SDL2)
endif()
endif()
endif() endif()
find_library(SDL2_LIBRARY_RELEASE find_library(SDL2_LIBRARY_RELEASE
@ -58,15 +76,14 @@ else()
# the dylib first so it is preferred. Not sure how this maps to debug # the dylib first so it is preferred. Not sure how this maps to debug
# config though :/ # config though :/
NAMES SDL2-2.0 SDL2 NAMES SDL2-2.0 SDL2
PATH_SUFFIXES ${_SDL_LIBRARY_PATH_SUFFIX}) PATH_SUFFIXES ${_SDL2_LIBRARY_PATH_SUFFIX})
find_library(SDL2_LIBRARY_DEBUG find_library(SDL2_LIBRARY_DEBUG
NAMES SDL2d NAMES SDL2d
PATH_SUFFIXES ${_SDL_LIBRARY_PATH_SUFFIX}) PATH_SUFFIXES ${_SDL2_LIBRARY_PATH_SUFFIX})
# FPHSA needs one of the _DEBUG/_RELEASE variables to check that the # FPHSA needs one of the _DEBUG/_RELEASE variables to check that the
# library was found -- using SDL_LIBRARY, which will get populated by # library was found -- using SDL_LIBRARY, which will get populated by
# select_library_configurations() below. # select_library_configurations() below.
set(SDL2_LIBRARY_NEEDED SDL2_LIBRARY) set(SDL2_LIBRARY_NEEDED SDL2_LIBRARY)
set(_SDL2_PATH_SUFFIXES SDL2)
endif() endif()
include(SelectLibraryConfigurations) include(SelectLibraryConfigurations)

Loading…
Cancel
Save