aboutsummaryrefslogtreecommitdiff
path: root/cmake/FindPango.cmake
blob: b934c6ff6c53d61f8a5d0540a52d7e48f040d189 (plain) (blame)
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
include(PkgConfigWithFallback)
find_pkg_config_with_fallback(Pango
    PKG_CONFIG_NAME pango
    LIB_NAMES pango-1.0
    INCLUDE_NAMES pango/pango.h
    INCLUDE_DIR_SUFFIXES pango-1.0 pango-1.0/include
    DEPENDS GObject
)

if(Pango_FOUND AND NOT Pango_VERSION)
    find_path(Pango_INCLUDE_DIR "pango/pango.h" HINTS ${Pango_INCLUDE_DIRS})

    if(Pango_INCLUDE_DIR)
        file(STRINGS "${Pango_INCLUDE_DIR}/pango/pango-features.h" Pango_MAJOR_VERSION REGEX "^#define PANGO_VERSION_MAJOR +\\(?([0-9]+)\\)?$")
        string(REGEX REPLACE "^#define PANGO_VERSION_MAJOR \\(?([0-9]+)\\)?$" "\\1" Pango_MAJOR_VERSION "${Pango_MAJOR_VERSION}")
        file(STRINGS "${Pango_INCLUDE_DIR}/pango/pango-features.h" Pango_MINOR_VERSION REGEX "^#define PANGO_VERSION_MINOR +\\(?([0-9]+)\\)?$")
        string(REGEX REPLACE "^#define PANGO_VERSION_MINOR \\(?([0-9]+)\\)?$" "\\1" Pango_MINOR_VERSION "${Pango_MINOR_VERSION}")
        file(STRINGS "${Pango_INCLUDE_DIR}/pango/pango-features.h" Pango_MICRO_VERSION REGEX "^#define PANGO_VERSION_MICRO +\\(?([0-9]+)\\)?$")
        string(REGEX REPLACE "^#define PANGO_VERSION_MICRO \\(?([0-9]+)\\)?$" "\\1" Pango_MICRO_VERSION "${Pango_MICRO_VERSION}")
        set(Pango_VERSION "${Pango_MAJOR_VERSION}.${Pango_MINOR_VERSION}.${Pango_MICRO_VERSION}")
        unset(Pango_MAJOR_VERSION)
        unset(Pango_MINOR_VERSION)
        unset(Pango_MICRO_VERSION)
    endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Pango
    FOUND_VAR Pango_FOUND
    REQUIRED_VARS Pango_LIBRARY
    VERSION_VAR Pango_VERSION
)