FindSDL_ttf.cmake 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # - Locate SDL_ttf library
  2. # This module defines
  3. # SDLTTF_LIBRARY, the library to link against
  4. # SDLTTF_FOUND, if false, do not try to link to SDL
  5. # SDLTTF_INCLUDE_DIR, where to find SDL/SDL.h
  6. #
  7. # $SDLDIR is an environment variable that would
  8. # correspond to the ./configure --prefix=$SDLDIR
  9. # used in building SDL.
  10. # Created by Eric Wing. This was influenced by the FindSDL.cmake
  11. # module, but with modifications to recognize OS X frameworks and
  12. # additional Unix paths (FreeBSD, etc).
  13. # On OSX, this will prefer the Framework version (if found) over others.
  14. # People will have to manually change the cache values of
  15. # SDLTTF_LIBRARY to override this selection.
  16. FIND_PATH(SDLTTF_INCLUDE_DIR SDL_ttf.h
  17. $ENV{SDLTTFDIR}/include
  18. $ENV{SDLDIR}/include
  19. ~/Library/Frameworks/SDL_ttf.framework/Headers
  20. /Library/Frameworks/SDL_ttf.framework/Headers
  21. /usr/local/include/SDL
  22. /usr/include/SDL
  23. /usr/local/include/SDL12
  24. /usr/local/include/SDL11 # FreeBSD ports
  25. /usr/include/SDL12
  26. /usr/include/SDL11
  27. /usr/local/include
  28. /usr/include
  29. /sw/include/SDL # Fink
  30. /sw/include
  31. /opt/local/include/SDL # DarwinPorts
  32. /opt/local/include
  33. /opt/csw/include/SDL # Blastwave
  34. /opt/csw/include
  35. /opt/include/SDL
  36. /opt/include
  37. )
  38. # I'm not sure if I should do a special casing for Apple. It is
  39. # unlikely that other Unix systems will find the framework path.
  40. # But if they do ([Next|Open|GNU]Step?),
  41. # do they want the -framework option also?
  42. IF(${SDLTTF_INCLUDE_DIR} MATCHES ".framework")
  43. # Extract the path the framework resides in so we can use it for the -F flag
  44. STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" SDLTTF_FRAMEWORK_PATH_TEMP ${SDLTTF_INCLUDE_DIR})
  45. IF("${SDLTTF_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
  46. OR "${SDLTTF_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
  47. )
  48. # String is in default search path, don't need to use -F
  49. SET(SDLTTF_LIBRARY "-framework SDL_ttf" CACHE STRING "SDL_ttf framework for OSX")
  50. ELSE("${SDLTTF_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
  51. OR "${SDLTTF_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
  52. )
  53. # String is not /Library/Frameworks, need to use -F
  54. SET(SDLTTF_LIBRARY "-F${SDLTTF_FRAMEWORK_PATH_TEMP} -framework SDL_ttf" CACHE STRING "SDL_ttf framework for OSX")
  55. ENDIF("${SDLTTF_FRAMEWORK_PATH_TEMP}" STREQUAL "/Library/Frameworks"
  56. OR "${SDLTTF_FRAMEWORK_PATH_TEMP}" STREQUAL "/System/Library/Frameworks"
  57. )
  58. # Clear the temp variable so nobody can see it
  59. SET(SDLTTF_FRAMEWORK_PATH_TEMP "" CACHE INTERNAL "")
  60. ELSE(${SDLTTF_INCLUDE_DIR} MATCHES ".framework")
  61. FIND_LIBRARY(SDLTTF_LIBRARY
  62. NAMES SDL_ttf
  63. PATHS
  64. $ENV{SDLTTFDIR}/lib
  65. $ENV{SDLDIR}/lib
  66. /usr/local/lib
  67. /usr/lib
  68. /sw/lib
  69. /opt/local/lib
  70. /opt/csw/lib
  71. /opt/lib
  72. )
  73. ENDIF(${SDLTTF_INCLUDE_DIR} MATCHES ".framework")
  74. SET(SDLTTF_FOUND "NO")
  75. IF(SDLTTF_LIBRARY)
  76. SET(SDLTTF_FOUND "YES")
  77. ENDIF(SDLTTF_LIBRARY)