aboutsummaryrefslogtreecommitdiff
path: root/modules/FindGettext.cmake
blob: 26bab0487e4e90452f4c09ac65815378e6fdd53f (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
47
48
49
50
51
# Try to find Gettext functionality
# Once done this will define
#
#  GETTEXT_FOUND - system has Gettext
#  GETTEXT_INCLUDE_DIR - Gettext include directory
#  GETTEXT_LIBRARIES - Libraries needed to use Gettext

# TODO: This will enable translations only if Gettext functionality is
# present in libc. Must have more robust system for release, where Gettext
# functionality can also reside in standalone Gettext library, or the one
# embedded within kdelibs (cf. gettext.m4 from Gettext source).

INCLUDE(CheckIncludeFiles)
include(CheckFunctionExists)

check_include_files(libintl.h HAVE_LIBINTL_H)

set(GETTEXT_INCLUDE_DIR)
set(GETTEXT_LIBRARIES)

if (HAVE_LIBINTL_H)
   check_function_exists(dgettext LIBC_HAS_DGETTEXT)
   if (LIBC_HAS_DGETTEXT)
      set(GETTEXT_SOURCE "built in libc")
      set(GETTEXT_FOUND TRUE)
   else (LIBC_HAS_DGETTEXT)
      FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl libintl
         PATHS
         /usr/lib
         /usr/local/lib
      )
      CHECK_LIBRARY_EXISTS(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT)
      if (LIBINTL_HAS_DGETTEXT)
         set(GETTEXT_SOURCE "in ${LIBINTL_LIBRARY}")
         set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY})
         set(GETTEXT_FOUND TRUE)
      endif (LIBINTL_HAS_DGETTEXT)
   endif (LIBC_HAS_DGETTEXT)
endif (HAVE_LIBINTL_H)

if (GETTEXT_FOUND)
   if (NOT Gettext_FIND_QUIETLY)
      message(STATUS "Found Gettext: ${GETTEXT_SOURCE}")
   endif (NOT Gettext_FIND_QUIETLY)
else (GETTEXT_FOUND)
   if (Gettext_FIND_REQUIRED)
      message(STATUS "Could NOT find Gettext")
   endif (Gettext_FIND_REQUIRED)
endif (GETTEXT_FOUND)

MARK_AS_ADVANCED(GETTEXT_INCLUDE_DIR GETTEXT_LIBRARIES)