FindFreetype.cmake 3.5 KB

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