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