FindSDL2.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ###############################################################################
  2. # CMake module to search for the SDL libraries.
  3. #
  4. # WARNING: This module is experimental work in progress.
  5. #
  6. # Based one FindVLC.cmake by:
  7. # Copyright (c) 2011 Michael Jansen <info@michael-jansen.biz>
  8. # Modified by Tobias Hieta <tobias@hieta.se>
  9. #
  10. # Redistribution and use is allowed according to the terms of the BSD license.
  11. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  12. #
  13. ###############################################################################
  14. #
  15. ### Global Configuration Section
  16. #
  17. SET(_SDL2_REQUIRED_VARS SDL2_INCLUDE_DIR SDL2_LIBRARY)
  18. #
  19. ### SDL uses pkgconfig.
  20. #
  21. if(PKG_CONFIG_FOUND)
  22. pkg_check_modules(PC_SDL QUIET sdl2)
  23. endif(PKG_CONFIG_FOUND)
  24. #
  25. ### Look for the include files.
  26. #
  27. find_path(
  28. SDL2_INCLUDE_DIR
  29. NAMES SDL.h
  30. PATH_SUFFIXES SDL2
  31. HINTS
  32. ${PC_SDL2_INCLUDEDIR}
  33. ${PC_SDL2_INCLUDE_DIRS} # Unused for SDL but anyway
  34. DOC "SDL2 include directory"
  35. )
  36. mark_as_advanced(SDL2_INCLUDE_DIR)
  37. set(SDL2_INCLUDE_DIRS ${SDL_INCLUDE_DIR})
  38. #
  39. ### Look for the libraries (SDL and SDLsore)
  40. #
  41. find_library(
  42. SDL2_LIBRARY
  43. NAMES SDL2
  44. HINTS
  45. ${PC_SDL2_LIBDIR}
  46. ${PC_SDL2_LIBRARY_DIRS} # Unused for SDL but anyway
  47. PATH_SUFFIXES lib${LIB_SUFFIX}
  48. )
  49. get_filename_component(_SDL2_LIBRARY_DIR "${SDL2_LIBRARY}" PATH)
  50. mark_as_advanced(SDL2_LIBRARY)
  51. set(SDL2_LIBRARY_DIRS _SDL2_LIBRARY_DIR)
  52. list(REMOVE_DUPLICATES SDL2_LIBRARY_DIRS)
  53. mark_as_advanced(SDL2_LIBRARY_DIRS)
  54. #
  55. ### Check if everything was found and if the version is sufficient.
  56. #
  57. include(FindPackageHandleStandardArgs)
  58. find_package_handle_standard_args(
  59. SDL2
  60. REQUIRED_VARS ${_SDL2_REQUIRED_VARS}
  61. VERSION_VAR SDL2_VERSION_STRING
  62. )