Changeset View
Changeset View
Standalone View
Standalone View
find-modules/FindFontconfig.cmake
- This file was added.
1 | #.rst: | ||||
---|---|---|---|---|---|
2 | # FindFontconfig | ||||
3 | # -------------- | ||||
4 | # | ||||
5 | # Try to find Fontconfig. | ||||
6 | # Once done this will define the following variables: | ||||
7 | # | ||||
8 | # ``Fontconfig_FOUND`` | ||||
9 | # True if Fontconfig is available | ||||
10 | # ``Fontconfig_INCLUDE_DIRS`` | ||||
11 | # The include directory to use for the Fontconfig headers | ||||
12 | # ``Fontconfig_LIBRARIES`` | ||||
13 | # The Fontconfig libraries for linking | ||||
14 | # ``Fontconfig_DEFINITIONS`` | ||||
15 | # Compiler switches required for using Fontconfig | ||||
16 | # ``Fontconfig_VERSION`` | ||||
17 | # The version of Fontconfig that has been found | ||||
18 | # | ||||
19 | # If ``Fontconfig_FOUND`` is True, it will also define the following | ||||
20 | # imported target: | ||||
21 | # | ||||
22 | # ``Fontconfig::Fontconfig`` | ||||
23 | | ||||
krop: Missing 'Since' | |||||
24 | #============================================================================= | ||||
25 | # Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org> | ||||
26 | # Copyright (c) 2018 Volker Krause <vkrause@kde.org> | ||||
27 | # | ||||
28 | # Redistribution and use in source and binary forms, with or without | ||||
29 | # modification, are permitted provided that the following conditions | ||||
30 | # are met: | ||||
31 | # | ||||
32 | # 1. Redistributions of source code must retain the copyright | ||||
33 | # notice, this list of conditions and the following disclaimer. | ||||
34 | # 2. Redistributions in binary form must reproduce the copyright | ||||
35 | # notice, this list of conditions and the following disclaimer in the | ||||
36 | # documentation and/or other materials provided with the distribution. | ||||
37 | # 3. The name of the author may not be used to endorse or promote products | ||||
38 | # derived from this software without specific prior written permission. | ||||
39 | # | ||||
40 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||
41 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
42 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
43 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
44 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
45 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
46 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
47 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
48 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
49 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
50 | #============================================================================= | ||||
51 | | ||||
52 | # use pkg-config to get the directories and then use these values | ||||
53 | # in the FIND_PATH() and FIND_LIBRARY() calls | ||||
54 | find_package(PkgConfig) | ||||
55 | pkg_check_modules(PC_FONTCONFIG QUIET fontconfig) | ||||
56 | | ||||
57 | set(Fontconfig_DEFINITIONS ${PC_FONTCONFIG_CFLAGS_OTHER}) | ||||
krop: QUIET here as well | |||||
58 | | ||||
If you use IMPORTED_TARGET you can skip most stuff below. i.e. In fact, I'd argue it's just easier to have pkg_check_modules called upstream rather than having an intermediary in ECM or so. apol: If you use IMPORTED_TARGET you can skip most stuff below. i.e.
`pkg_check_modules(Flatpak… | |||||
Does that mean we can rely on pkgconfig? So far I got the impression we have to treat that as optional in ECM code? vkrause: Does that mean we can rely on pkgconfig? So far I got the impression we have to treat that as… | |||||
Maybe you are right, I don't know what problems pkgconfig my incur in that can't be fixed upstream. apol: Maybe you are right, I don't know what problems pkgconfig my incur in that can't be fixed… | |||||
ECM requires CMake 2.8.12. 'IMPORTED_TARGET' is not available in this version. krop: ECM requires CMake 2.8.12. 'IMPORTED_TARGET' is not available in this version. | |||||
59 | find_path(Fontconfig_INCLUDE_DIRS fontconfig/fontconfig.h | ||||
60 | PATHS | ||||
61 | ${PC_FONTCONFIG_INCLUDE_DIRS} | ||||
62 | /usr/X11/include | ||||
63 | ) | ||||
64 | | ||||
65 | find_library(Fontconfig_LIBRARIES NAMES fontconfig | ||||
66 | PATHS | ||||
67 | ${PC_FONTCONFIG_LIBRARY_DIRS} | ||||
68 | ) | ||||
69 | | ||||
70 | set(Fontconfig_VERSION ${PC_FONTCONFIG_VERSION}) | ||||
71 | if (NOT Fontconfig_VERSION) | ||||
72 | find_file(Fontconfig_VERSION_HEADER | ||||
73 | NAMES "fontconfig/fontconfig.h" | ||||
74 | HINTS ${Fontconfig_INCLUDE_DIRS} | ||||
75 | ) | ||||
76 | mark_as_advanced(Fontconfig_VERSION_HEADER) | ||||
77 | if (Fontconfig_VERSION_HEADER) | ||||
78 | file(READ ${Fontconfig_VERSION_HEADER} _fontconfig_version_header_content) | ||||
79 | string(REGEX MATCH "#define FC_MAJOR[ \t]+[0-9]+" Fontconfig_MAJOR_VERSION_MATCH ${_fontconfig_version_header_content}) | ||||
80 | string(REGEX MATCH "#define FC_MINOR[ \t]+[0-9]+" Fontconfig_MINOR_VERSION_MATCH ${_fontconfig_version_header_content}) | ||||
81 | string(REGEX MATCH "#define FC_REVISION[ \t]+[0-9]+" Fontconfig_PATCH_VERSION_MATCH ${_fontconfig_version_header_content}) | ||||
82 | string(REGEX REPLACE ".*FC_MAJOR[ \t]+(.*)" "\\1" Fontconfig_MAJOR_VERSION ${Fontconfig_MAJOR_VERSION_MATCH}) | ||||
83 | string(REGEX REPLACE ".*FC_MINOR[ \t]+(.*)" "\\1" Fontconfig_MINOR_VERSION ${Fontconfig_MINOR_VERSION_MATCH}) | ||||
84 | string(REGEX REPLACE ".*FC_REVISION[ \t]+(.*)" "\\1" Fontconfig_PATCH_VERSION ${Fontconfig_PATCH_VERSION_MATCH}) | ||||
85 | set(Fontconfig_VERSION "${Fontconfig_MAJOR_VERSION}.${Fontconfig_MINOR_VERSION}.${Fontconfig_PATCH_VERSION}") | ||||
86 | endif() | ||||
87 | endif() | ||||
88 | | ||||
89 | include(FindPackageHandleStandardArgs) | ||||
90 | find_package_handle_standard_args(Fontconfig | ||||
91 | FOUND_VAR Fontconfig_FOUND | ||||
92 | REQUIRED_VARS Fontconfig_LIBRARIES Fontconfig_INCLUDE_DIRS | ||||
93 | VERSION_VAR Fontconfig_VERSION | ||||
94 | ) | ||||
95 | mark_as_advanced(Fontconfig_LIBRARIES Fontconfig_INCLUDE_DIRS) | ||||
96 | | ||||
97 | if(Fontconfig_FOUND AND NOT TARGET Fontconfig::Fontconfig) | ||||
98 | add_library(Fontconfig::Fontconfig UNKNOWN IMPORTED) | ||||
99 | set_target_properties(Fontconfig::Fontconfig PROPERTIES | ||||
100 | IMPORTED_LOCATION "${Fontconfig_LIBRARIES}" | ||||
101 | INTERFACE_INCLUDE_DIRECTORIES "${Fontconfig_INCLUDE_DIRS}" | ||||
102 | INTERFACE_COMPILER_DEFINITIONS "${Fontconfig_DEFINITIONS}" | ||||
103 | ) | ||||
104 | endif() | ||||
105 | | ||||
106 | include(FeatureSummary) | ||||
107 | set_package_properties(Fontconfig PROPERTIES | ||||
108 | URL "https://www.fontconfig.org/" | ||||
109 | DESCRIPTION "Fontconfig is a library for configuring and customizing font access" | ||||
110 | ) |
Missing 'Since'