FindFontconfig.cmake 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # - Try to find the Fontconfig
  2. # Once done this will define
  3. #
  4. # FONTCONFIG_FOUND - system has Fontconfig
  5. # FONTCONFIG_INCLUDE_DIR - The include directory to use for the fontconfig headers
  6. # FONTCONFIG_LIBRARIES - Link these to use FONTCONFIG
  7. # FONTCONFIG_DEFINITIONS - Compiler switches required for using FONTCONFIG
  8. # Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
  9. #
  10. # Redistribution and use in source and binary forms, with or without
  11. # modification, are permitted provided that the following conditions
  12. # are met:
  13. #
  14. # 1. Redistributions of source code must retain the copyright
  15. # notice, this list of conditions and the following disclaimer.
  16. # 2. Redistributions in binary form must reproduce the copyright
  17. # notice, this list of conditions and the following disclaimer in the
  18. # documentation and/or other materials provided with the distribution.
  19. # 3. The name of the author may not be used to endorse or promote products
  20. # derived from this software without specific prior written permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  23. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24. # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. #
  33. if (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
  34. # in cache already
  35. set(FONTCONFIG_FOUND TRUE)
  36. else (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
  37. if (NOT WIN32)
  38. # use pkg-config to get the directories and then use these values
  39. # in the find_path() and find_library() calls
  40. find_package(PkgConfig)
  41. pkg_check_modules(PC_FONTCONFIG fontconfig)
  42. set(FONTCONFIG_DEFINITIONS ${PC_FONTCONFIG_CFLAGS_OTHER})
  43. endif (NOT WIN32)
  44. find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h
  45. PATHS
  46. ${PC_FONTCONFIG_INCLUDEDIR}
  47. ${PC_FONTCONFIG_INCLUDE_DIRS}
  48. /usr/X11/include
  49. )
  50. find_library(FONTCONFIG_LIBRARIES NAMES fontconfig
  51. PATHS
  52. ${PC_FONTCONFIG_LIBDIR}
  53. ${PC_FONTCONFIG_LIBRARY_DIRS}
  54. )
  55. include(FindPackageHandleStandardArgs)
  56. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Fontconfig DEFAULT_MSG FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)
  57. mark_as_advanced(FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)
  58. endif (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)