Skip to content

Commit

Permalink
modules: updated FindSDL2.cmake.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosra committed May 19, 2019
1 parent b2e6fe5 commit 53fd0bf
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions modules/FindSDL2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,29 @@
if(CORRADE_TARGET_EMSCRIPTEN)
set(_SDL2_PATH_SUFFIXES SDL)
else()
# Precompiled libraries for Windows are in x86/x64 subdirectories
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_SDL_LIBRARY_PATH_SUFFIX lib/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(_SDL_LIBRARY_PATH_SUFFIX lib/x86)
set(_SDL2_PATH_SUFFIXES SDL2)
if(WIN32)
# Precompiled libraries for MSVC are in x86/x64 subdirectories
if(MSVC)
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()

find_library(SDL2_LIBRARY_RELEASE
Expand All @@ -58,15 +76,14 @@ else()
# the dylib first so it is preferred. Not sure how this maps to debug
# config though :/
NAMES SDL2-2.0 SDL2
PATH_SUFFIXES ${_SDL_LIBRARY_PATH_SUFFIX})
PATH_SUFFIXES ${_SDL2_LIBRARY_PATH_SUFFIX})
find_library(SDL2_LIBRARY_DEBUG
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
# library was found -- using SDL_LIBRARY, which will get populated by
# select_library_configurations() below.
set(SDL2_LIBRARY_NEEDED SDL2_LIBRARY)
set(_SDL2_PATH_SUFFIXES SDL2)
endif()

include(SelectLibraryConfigurations)
Expand Down

0 comments on commit 53fd0bf

Please sign in to comment.