File: FindLibIntl.cmake

package info (click to toggle)
fcitx-unikey 0.2.7%2Bgit20220410-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 684 kB
  • sloc: cpp: 6,904; makefile: 8
file content (41 lines) | stat: -rw-r--r-- 1,288 bytes parent folder | download | duplicates (5)
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
# - find where dlopen and friends are located.
# LIBINTL_FOUND - system has dynamic linking interface available
# LIBINTL_INCLUDE_DIR - where dlfcn.h is located.
# LIBINTL_LIBRARY - libraries needed to use dlopen

include(CheckFunctionExists)

find_path(LIBINTL_INCLUDE_DIR NAMES libintl.h)
find_library(LIBINTL_LIBRARY NAMES intl)
if(LIBINTL_LIBRARY)
  set(LIBINTL_FOUND TRUE)
else(LIBINTL_LIBRARY)
  check_function_exists(dgettext LIBINTL_FOUND)
  # If dlopen can be found without linking in dl then dlopen is part
  # of libc, so don't need to link extra libs.
  set(LIBINTL_LIBRARY "")
endif(LIBINTL_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBINTL
    FOUND_VAR
        LIBINTL_FOUND
    REQUIRED_VARS
        LIBINTL_INCLUDE_DIR
)

mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY)

if(LIBINTL_FOUND AND NOT TARGET LibIntl::LibIntl)
    if (LIBINTL_LIBRARY)
        add_library(LibIntl::LibIntl UNKNOWN IMPORTED)
        set_target_properties(LibIntl::LibIntl PROPERTIES
            IMPORTED_LOCATION "${LIBINTL_LIBRARY}")
    else()
        add_library(LibIntl::LibIntl INTERFACE IMPORTED )
    endif()
    set_target_properties(LibIntl::LibIntl PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${LIBINTL_INCLUDE_DIR}"
    )
endif()