# - find SDL2
# SDL2_INCLUDE_DIR - Where to find SDL2 header files (directory)
# SDL2_LIBRARIES - SDL2 libraries
# SDL2_LIBRARY_RELEASE - Where the release library is
# SDL2_LIBRARY_DEBUG - Where the debug library is
# SDL2_FOUND - Set to TRUE if we found everything (library, includes and executable)

# Generated by CModuler, a CMake Module Generator - http://gitorious.org/cmoduler

IF( SDL2_INCLUDE_DIR AND SDL2_LIBRARY_RELEASE AND SDL2_LIBRARY_DEBUG )
    SET(SDL2_FIND_QUIETLY TRUE)
ENDIF( SDL2_INCLUDE_DIR AND SDL2_LIBRARY_RELEASE AND SDL2_LIBRARY_DEBUG )

FIND_PATH( SDL2_INCLUDE_DIR SDL.h  )

FIND_LIBRARY(SDL2_LIBRARY_RELEASE NAMES SDL2 )

FIND_LIBRARY(SDL2_LIBRARY_DEBUG NAMES SDL2  HINTS /usr/lib/debug/usr/lib/ )

IF( SDL2_LIBRARY_RELEASE OR SDL2_LIBRARY_DEBUG AND SDL2_INCLUDE_DIR )
	SET( SDL2_FOUND TRUE )
ENDIF( SDL2_LIBRARY_RELEASE OR SDL2_LIBRARY_DEBUG AND SDL2_INCLUDE_DIR )

IF( SDL2_LIBRARY_DEBUG AND SDL2_LIBRARY_RELEASE )
	# if the generator supports configuration types then set
	# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
	IF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
		SET( SDL2_LIBRARIES optimized ${SDL2_LIBRARY_RELEASE} debug ${SDL2_LIBRARY_DEBUG} )
	ELSE( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
    # if there are no configuration types and CMAKE_BUILD_TYPE has no value
    # then just use the release libraries
		SET( SDL2_LIBRARIES ${SDL2_LIBRARY_RELEASE} )
	ENDIF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
ELSEIF( SDL2_LIBRARY_RELEASE )
	SET( SDL2_LIBRARIES ${SDL2_LIBRARY_RELEASE} )
ELSE( SDL2_LIBRARY_DEBUG AND SDL2_LIBRARY_RELEASE )
	SET( SDL2_LIBRARIES ${SDL2_LIBRARY_DEBUG} )
ENDIF( SDL2_LIBRARY_DEBUG AND SDL2_LIBRARY_RELEASE )

IF( SDL2_FOUND )
	MESSAGE( STATUS "Found SDL2 header file in ${SDL2_INCLUDE_DIR}")
	MESSAGE( STATUS "Found SDL2 libraries: ${SDL2_LIBRARIES}")
ELSE(SDL2_FOUND)
	MESSAGE( FATAL_ERROR "Could not find SDL2" )
ENDIF(SDL2_FOUND)
