File: FindFontconfig.cmake

package info (click to toggle)
gr-framework 0.73.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,600 kB
  • sloc: ansic: 87,413; cpp: 45,348; objc: 3,057; javascript: 2,647; makefile: 1,129; python: 1,000; sh: 991; yacc: 855; pascal: 554; fortran: 228
file content (73 lines) | stat: -rw-r--r-- 2,289 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#.rst:
# FindFontconfig
# ------------
#
# Find the Fontconfig library.
#
# Imported targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` target:
#
# ``Fontconfig::Fontconfig``
#   The Fontconfig library, if found.
#
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``FONTCONFIG_INCLUDE_DIRS``
#   where to find fontconfig/fontconfig.h, etc.
# ``FONTCONFIG_LIBRARIES``
#   the libraries to link against to use Fontconfig.
# ``Fontconfig_FOUND``
#   If false, do not try to use Fontconfig.

if(NOT FONTCONFIG_INCLUDE_DIR)
  find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h)
endif()

if(NOT FONTCONFIG_LIBRARY)
  find_library(FONTCONFIG_LIBRARY NAMES fontconfig)
endif()

if(FONTCONFIG_INCLUDE_DIR)
  if(NOT FONTCONFIG_VERSION_STRING)
    file(READ ${FONTCONFIG_INCLUDE_DIR}/fontconfig/fontconfig.h FONTCONFIG_H_TEXT)
    string(REGEX REPLACE ".*#define FC_MAJOR[ \t]*([0-9]+).*" "\\1." FC_MAJOR_STRING ${FONTCONFIG_H_TEXT})
    string(REGEX REPLACE ".*#define FC_MINOR[ \t]*([0-9]+).*" "\\1." FC_MINOR_STRING ${FONTCONFIG_H_TEXT})
    string(REGEX REPLACE ".*#define FC_REVISION[ \t]*([0-9]+).*" "\\1" FC_REVISION_STRING ${FONTCONFIG_H_TEXT})
    string(CONCAT FONTCONFIG_VERSION_STRING "${FC_MAJOR_STRING}" "${FC_MINOR_STRING}" "${FC_REVISION_STRING}")
  endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
  Fontconfig
  VERSION_VAR
  FONTCONFIG_VERSION_STRING
  REQUIRED_VARS
  FONTCONFIG_LIBRARY
  FONTCONFIG_INCLUDE_DIR
  FONTCONFIG_VERSION_STRING
)

if(Fontconfig_FOUND)
  set(FONTCONFIG_INCLUDE_DIRS ${FONTCONFIG_INCLUDE_DIR})
  set(FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY})

  if(NOT TARGET Fontconfig::Fontconfig)
    add_library(Fontconfig::Fontconfig UNKNOWN IMPORTED)
    set_target_properties(
      Fontconfig::Fontconfig
      PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FONTCONFIG_INCLUDE_DIRS}"
                 IMPORTED_LINK_INTERFACE_LANGUAGES "C"
                 IMPORTED_LOCATION "${FONTCONFIG_LIBRARY}"
    )
  endif()
elseif(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
  message(FATAL_ERROR "${CMAKE_FIND_PACKAGE_NAME} was required but could not be found.")
endif()

mark_as_advanced(FONTCONFIG_INCLUDE_DIR FONTCONFIG_LIBRARY)