# Defines variables:
# - SDL2_INCLUDE_DIRS
# - SDL2_LIBRARIES

set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:$ENV{SDL2_HOME}/lib/pkgconfig")
find_package(PkgConfig)
pkg_check_modules(SDL2_PKGCONF QUIET sdl2)

find_path(SDL2_INCLUDE_DIR
  NAMES SDL.h
  HINTS ${SDL2_PKGCONF_INCLUDEDIR} ${SDL2_PKGCONF_INCLUDE_DIRS} $ENV{SDL2_HOME}/include
  PATH_SUFFIXES SDL2
)

find_library(SDL2_LIBRARY
  NAMES SDL2
  HINTS ${SDL2_PKGCONF_LIBDIR} ${SDL2_PKGCONF_LIBRARY_DIRS} $ENV{SDL2_HOME}/lib
)

mark_as_advanced(SDL2_INCLUDE_DIR SDL2_LIBRARY)

set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
set(SDL2_LIBRARIES ${SDL2_LIBRARY})
