Browse Source

modules: make FindSDL2.cmake also find debug libraries.

Fixes an issue with SDL2d.dll not being copied to the output directory
with vcpkg.
pull/255/head
Squareys 8 years ago committed by Vladimír Vondruš
parent
commit
52b7c26022
  1. 28
      modules/FindSDL2.cmake

28
modules/FindSDL2.cmake

@ -10,6 +10,8 @@
# Additionally these variables are defined for internal usage:
#
# SDL2_LIBRARY - SDL2 library
# SDL2_LIBRARY_DEBUG - SDL2 debug library
# SDL2_LIBRARY_RELEASE - SDL2 release library
# SDL2_INCLUDE_DIR - Root include dir
#
@ -50,16 +52,23 @@ else()
set(_SDL_LIBRARY_PATH_SUFFIX lib/x86)
endif()
find_library(SDL2_LIBRARY
find_library(SDL2_LIBRARY_RELEASE
# Compiling SDL2 from scratch on macOS creates dead libSDL2.so symlink
# which CMake somehow prefers before the SDL2-2.0.dylib file. Making
# the dylib first so it is preferred.
# 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})
find_library(SDL2_LIBRARY_DEBUG
NAMES SDL2d
PATH_SUFFIXES ${_SDL_LIBRARY_PATH_SUFFIX})
set(SDL2_LIBRARY_NEEDED SDL2_LIBRARY)
set(_SDL2_PATH_SUFFIXES SDL2)
endif()
include(SelectLibraryConfigurations)
select_library_configurations(SDL2)
# Include dir
find_path(SDL2_INCLUDE_DIR
# We must search file which is present only in SDL2 and not in SDL1.
@ -120,10 +129,19 @@ if(NOT TARGET SDL2::SDL2)
# Work around BUGGY framework support on macOS
# https://cmake.org/Bug/view.php?id=14105
if(CORRADE_TARGET_APPLE AND ${SDL2_LIBRARY} MATCHES "\\.framework$")
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION ${SDL2_LIBRARY}/SDL2)
if(CORRADE_TARGET_APPLE AND SDL2_LIBRARY_RELEASE MATCHES "\\.framework$")
set_property(TARGET SDL2::SDL2 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE ${SDL2_LIBRARY_RELEASE}/SDL2)
else()
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION ${SDL2_LIBRARY})
if(SDL2_LIBRARY_RELEASE)
set_property(TARGET SDL2::SDL2 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE ${SDL2_LIBRARY_RELEASE})
endif()
if(SDL2_LIBRARY_DEBUG)
set_property(TARGET SDL2::SDL2 APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_DEBUG ${SDL2_LIBRARY_DEBUG})
endif()
endif()
# Link additional `dl` and `pthread` libraries required by a static

Loading…
Cancel
Save