FindFreetype.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  36. NO_DEFAULT_PATH
  37. PATH_SUFFIXES include
  38. )
  39. FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
  40. PATHS
  41. /usr/local/X11R6/include
  42. /usr/local/X11/include
  43. /usr/X11/include
  44. /sw/include
  45. /opt/local/include
  46. /usr/freeware/include
  47. )
  48. FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
  49. $ENV{FREETYPE_DIR}/include/freetype2
  50. NO_DEFAULT_PATH
  51. )
  52. FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
  53. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  54. NO_DEFAULT_PATH
  55. PATH_SUFFIXES include/freetype2
  56. )
  57. FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
  58. /usr/local/X11R6/include
  59. /usr/local/X11/include
  60. /usr/X11/include
  61. /sw/include
  62. /opt/local/include
  63. /usr/freeware/include
  64. PATH_SUFFIXES freetype2
  65. )
  66. FIND_LIBRARY(FREETYPE_LIBRARY
  67. NAMES freetype libfreetype freetype219
  68. PATHS
  69. $ENV{FREETYPE_DIR}
  70. NO_DEFAULT_PATH
  71. PATH_SUFFIXES lib64 lib
  72. )
  73. FIND_LIBRARY(FREETYPE_LIBRARY
  74. NAMES freetype libfreetype freetype219
  75. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  76. NO_DEFAULT_PATH
  77. PATH_SUFFIXES lib64 lib
  78. )
  79. FIND_LIBRARY(FREETYPE_LIBRARY
  80. NAMES freetype libfreetype freetype219
  81. PATHS
  82. /usr/local/X11R6
  83. /usr/local/X11
  84. /usr/X11
  85. /sw
  86. /usr/freeware
  87. PATH_SUFFIXES lib64 lib
  88. )
  89. # set the user variables
  90. IF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
  91. SET(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
  92. ENDIF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
  93. SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}")
  94. # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if
  95. # all listed variables are TRUE
  96. INCLUDE(FindPackageHandleStandardArgs)
  97. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
  98. MARK_AS_ADVANCED(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)