FindFreetype.cmake 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # - Locate FreeType library
  2. # This module defines
  3. # FREETYPE_LIBRARIES, the library to link against
  4. # FREETYPE_FOUND, if false, do not try to link to FREETYPE
  5. # FREETYPE_INCLUDE_DIRS, where to find headers.
  6. # This is the concatenation of the paths:
  7. # FREETYPE_INCLUDE_DIR_ft2build
  8. # FREETYPE_INCLUDE_DIR_freetype2
  9. #
  10. # $FREETYPE_DIR is an environment variable that would
  11. # correspond to the ./configure --prefix=$FREETYPE_DIR
  12. # used in building FREETYPE.
  13. # Created by Eric Wing.
  14. # Modifications by Alexander Neundorf.
  15. # This file has been renamed to "FindFreetype.cmake" instead of the correct
  16. # "FindFreeType.cmake" in order to be compatible with the one from KDE4, Alex.
  17. # Ugh, FreeType seems to use some #include trickery which
  18. # makes this harder than it should be. It looks like they
  19. # put ft2build.h in a common/easier-to-find location which
  20. # then contains a #include to a more specific header in a
  21. # more specific location (#include <freetype/config/ftheader.h>).
  22. # Then from there, they need to set a bunch of #define's
  23. # so you can do something like:
  24. # #include FT_FREETYPE_H
  25. # Unfortunately, using CMake's mechanisms like INCLUDE_DIRECTORIES()
  26. # wants explicit full paths and this trickery doesn't work too well.
  27. # I'm going to attempt to cut out the middleman and hope
  28. # everything still works.
  29. FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
  30. $ENV{FREETYPE_DIR}
  31. NO_DEFAULT_PATH
  32. PATH_SUFFIXES include
  33. )
  34. FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
  35. PATHS
  36. /usr/local/X11R6/include
  37. /usr/local/X11/include
  38. /usr/X11/include
  39. /sw/include
  40. /opt/local/include
  41. /usr/freeware/include
  42. )
  43. FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
  44. $ENV{FREETYPE_DIR}/include/freetype2
  45. NO_DEFAULT_PATH
  46. )
  47. FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
  48. /usr/local/X11R6/include
  49. /usr/local/X11/include
  50. /usr/X11/include
  51. /sw/include
  52. /opt/local/include
  53. /usr/freeware/include
  54. PATH_SUFFIXES freetype2
  55. )
  56. FIND_LIBRARY(FREETYPE_LIBRARY
  57. NAMES freetype libfreetype freetype219
  58. PATHS
  59. $ENV{FREETYPE_DIR}
  60. NO_DEFAULT_PATH
  61. PATH_SUFFIXES lib64 lib
  62. )
  63. FIND_LIBRARY(FREETYPE_LIBRARY
  64. NAMES freetype libfreetype freetype219
  65. PATHS
  66. /usr/local/X11R6
  67. /usr/local/X11
  68. /usr/X11
  69. /sw
  70. /usr/freeware
  71. PATH_SUFFIXES lib64 lib
  72. )
  73. # set the user variables
  74. IF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
  75. SET(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
  76. ENDIF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
  77. SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}")
  78. # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if
  79. # all listed variables are TRUE
  80. INCLUDE(FindPackageHandleStandardArgs)
  81. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
  82. MARK_AS_ADVANCED(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)