FindFreetype.cmake 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #=============================================================================
  14. # Copyright 2007-2009 Kitware, Inc.
  15. #
  16. # Distributed under the OSI-approved BSD License (the "License");
  17. # see accompanying file Copyright.txt for details.
  18. #
  19. # This software is distributed WITHOUT ANY WARRANTY; without even the
  20. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. # See the License for more information.
  22. #=============================================================================
  23. # (To distribute this file outside of CMake, substitute the full
  24. # License text for the above reference.)
  25. # Created by Eric Wing.
  26. # Modifications by Alexander Neundorf.
  27. # This file has been renamed to "FindFreetype.cmake" instead of the correct
  28. # "FindFreeType.cmake" in order to be compatible with the one from KDE4, Alex.
  29. # Ugh, FreeType seems to use some #include trickery which
  30. # makes this harder than it should be. It looks like they
  31. # put ft2build.h in a common/easier-to-find location which
  32. # then contains a #include to a more specific header in a
  33. # more specific location (#include <freetype/config/ftheader.h>).
  34. # Then from there, they need to set a bunch of #define's
  35. # so you can do something like:
  36. # #include FT_FREETYPE_H
  37. # Unfortunately, using CMake's mechanisms like INCLUDE_DIRECTORIES()
  38. # wants explicit full paths and this trickery doesn't work too well.
  39. # I'm going to attempt to cut out the middleman and hope
  40. # everything still works.
  41. FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
  42. HINTS
  43. $ENV{FREETYPE_DIR}
  44. PATH_SUFFIXES include
  45. PATHS
  46. /usr/local/X11R6/include
  47. /usr/local/X11/include
  48. /usr/X11/include
  49. /sw/include
  50. /opt/local/include
  51. /usr/freeware/include
  52. )
  53. FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h
  54. HINTS
  55. $ENV{FREETYPE_DIR}/include/freetype2
  56. PATHS
  57. /usr/local/X11R6/include
  58. /usr/local/X11/include
  59. /usr/X11/include
  60. /sw/include
  61. /opt/local/include
  62. /usr/freeware/include
  63. PATH_SUFFIXES freetype2
  64. )
  65. FIND_LIBRARY(FREETYPE_LIBRARY
  66. NAMES freetype libfreetype freetype219
  67. HINTS
  68. $ENV{FREETYPE_DIR}
  69. PATH_SUFFIXES lib64 lib
  70. PATHS
  71. /usr/local/X11R6
  72. /usr/local/X11
  73. /usr/X11
  74. /sw
  75. /usr/freeware
  76. )
  77. # set the user variables
  78. IF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
  79. SET(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
  80. ENDIF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
  81. SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}")
  82. # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if
  83. # all listed variables are TRUE
  84. INCLUDE(FindPackageHandleStandardArgs)
  85. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
  86. MARK_AS_ADVANCED(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)