aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules/FindFriBidi.cmake
blob: 6a265e1c2a3b8f75d8e8d37ec9edb9fd0e160539 (plain)
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
#.rst:
# FindFribidi
# -----------
# Finds the GNU FriBidi library
#
# This will define the following target:
#
#   ${APP_NAME_LC}::Fribidi   - The FriBidi library

if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
  find_package(PkgConfig)

  if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE))
    pkg_check_modules(FRIBIDI fribidi IMPORTED_TARGET GLOBAL QUIET)

    get_target_property(FRIBIDI_LIBRARY PkgConfig::FRIBIDI INTERFACE_LINK_LIBRARIES)
    get_target_property(FRIBIDI_INCLUDE_DIR PkgConfig::FRIBIDI INTERFACE_INCLUDE_DIRECTORIES)

  else()
    find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi.h
                                  PATH_SUFFIXES fribidi
                                  HINTS ${DEPENDS_PATH}/include)
    find_library(FRIBIDI_LIBRARY NAMES fribidi libfribidi
                                 HINTS ${DEPENDS_PATH}/lib)
  endif()

  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(FriBidi
                                    REQUIRED_VARS FRIBIDI_LIBRARY FRIBIDI_INCLUDE_DIR
                                    VERSION_VAR FRIBIDI_VERSION)

  if(FRIBIDI_FOUND)
    if(TARGET PkgConfig::FRIBIDI)
      add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS PkgConfig::FRIBIDI)
    else()
        add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
        set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
                                                                         IMPORTED_LOCATION "${FRIBIDI_LIBRARY}"
                                                                         INTERFACE_INCLUDE_DIRECTORIES "${FRIBIDI_INCLUDE_DIR}")
    endif()
  else()
    if(FriBidi_FIND_REQUIRED)
      message(FATAL_ERROR "FriBidi library was not found.")
    endif()
  endif()
endif()