FindSDL2.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # - Find SDL library
  2. # Find the native SDL includes and library
  3. # This module defines
  4. # SDL2_INCLUDE_DIRS, where to find SDL.h, Set when SDL2_INCLUDE_DIR is found.
  5. # SDL2_LIBRARIES, libraries to link against to use SDL.
  6. # SDL2_ROOT_DIR, The base directory to search for SDL.
  7. # This can also be an environment variable.
  8. # SDL2_FOUND, If false, do not try to use SDL.
  9. #
  10. # also defined, but not for general use are
  11. # SDL2_LIBRARY, where to find the SDL library.
  12. #=============================================================================
  13. # Copyright 2015 Blender Foundation.
  14. #
  15. # Distributed under the OSI-approved BSD License (the "License");
  16. # see accompanying file Copyright.txt for details.
  17. #
  18. # This software is distributed WITHOUT ANY WARRANTY; without even the
  19. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. # See the License for more information.
  21. #=============================================================================
  22. # If SDL2_ROOT_DIR was defined in the environment, use it.
  23. IF(NOT SDL2_ROOT_DIR AND NOT $ENV{SDL2_ROOT_DIR} STREQUAL "")
  24. SET(SDL2_ROOT_DIR $ENV{SDL2_ROOT_DIR})
  25. ENDIF()
  26. SET(_sdl2_SEARCH_DIRS
  27. ${SDL2_ROOT_DIR}
  28. ~/Library/Frameworks
  29. /Library/Frameworks
  30. /usr/local
  31. /usr
  32. /sw # Fink
  33. /opt/local # DarwinPorts
  34. /opt/csw # Blastwave
  35. )
  36. FIND_PATH(SDL2_INCLUDE_DIR
  37. NAMES
  38. SDL.h
  39. HINTS
  40. ${_sdl2_SEARCH_DIRS}
  41. PATH_SUFFIXES
  42. include/SDL2 include
  43. )
  44. FIND_LIBRARY(SDL2_LIBRARY
  45. NAMES
  46. SDL2
  47. HINTS
  48. ${_sdl2_SEARCH_DIRS}
  49. PATH_SUFFIXES
  50. lib64 lib
  51. )
  52. # handle the QUIETLY and REQUIRED arguments and set SDL2_FOUND to TRUE if
  53. # all listed variables are TRUE
  54. INCLUDE(FindPackageHandleStandardArgs)
  55. FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 DEFAULT_MSG
  56. SDL2_LIBRARY SDL2_INCLUDE_DIR)
  57. IF(SDL2_FOUND)
  58. SET(SDL2_LIBRARIES ${SDL2_LIBRARY})
  59. SET(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
  60. ENDIF(SDL2_FOUND)
  61. MARK_AS_ADVANCED(
  62. SDL2_INCLUDE_DIR
  63. SDL2_LIBRARY
  64. )