[cosmetic] separate c-lang format commit
[xbmc.git] / cmake / modules / FindFriBidi.cmake
blob6a265e1c2a3b8f75d8e8d37ec9edb9fd0e160539
1 #.rst:
2 # FindFribidi
3 # -----------
4 # Finds the GNU FriBidi library
6 # This will define the following target:
8 #   ${APP_NAME_LC}::Fribidi   - The FriBidi library
10 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
11   find_package(PkgConfig)
13   if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE))
14     pkg_check_modules(FRIBIDI fribidi IMPORTED_TARGET GLOBAL QUIET)
16     get_target_property(FRIBIDI_LIBRARY PkgConfig::FRIBIDI INTERFACE_LINK_LIBRARIES)
17     get_target_property(FRIBIDI_INCLUDE_DIR PkgConfig::FRIBIDI INTERFACE_INCLUDE_DIRECTORIES)
19   else()
20     find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi.h
21                                   PATH_SUFFIXES fribidi
22                                   HINTS ${DEPENDS_PATH}/include)
23     find_library(FRIBIDI_LIBRARY NAMES fribidi libfribidi
24                                  HINTS ${DEPENDS_PATH}/lib)
25   endif()
27   include(FindPackageHandleStandardArgs)
28   find_package_handle_standard_args(FriBidi
29                                     REQUIRED_VARS FRIBIDI_LIBRARY FRIBIDI_INCLUDE_DIR
30                                     VERSION_VAR FRIBIDI_VERSION)
32   if(FRIBIDI_FOUND)
33     if(TARGET PkgConfig::FRIBIDI)
34       add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS PkgConfig::FRIBIDI)
35     else()
36         add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
37         set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
38                                                                          IMPORTED_LOCATION "${FRIBIDI_LIBRARY}"
39                                                                          INTERFACE_INCLUDE_DIRECTORIES "${FRIBIDI_INCLUDE_DIR}")
40     endif()
41   else()
42     if(FriBidi_FIND_REQUIRED)
43       message(FATAL_ERROR "FriBidi library was not found.")
44     endif()
45   endif()
46 endif()