FindLibintl.cmake does not set LIBINTL_LIBRARIES correctly

Alexander Neundorf neundorf at kde.org
Mon Feb 18 17:12:01 UTC 2013


On Sunday 20 January 2013, Treeve Jelbert wrote:
> On Sat, 19 Jan 2013 15:59:32 +0100, Treeve Jelbert wrote:
> > # grep LIBINTL CMakeCache.txt
> > LIBINTL_INCLUDE_DIR:PATH=/usr/include
> > //ADVANCED property for variable: LIBINTL_INCLUDE_DIR
> > LIBINTL_INCLUDE_DIR-ADVANCED:INTERNAL=1
> > //ADVANCED property for variable: LIBINTL_LIBC_HAS_DGETTEXT
> > LIBINTL_LIBC_HAS_DGETTEXT-ADVANCED:INTERNAL=1
> > LIBINTL_LIBC_HAS_DGETTEXT:INTERNAL=1
> > 
> > 
> > $ ls -l /usr/lib/libintl.*
> > -rw-r--r-- 1 root root 110934 Jan 18 20:51 /usr/lib/libintl.a
> > -rw-r--r-- 1 root root    915 Jan 18 20:51 /usr/lib/libintl.la
> > lrwxrwxrwx 1 root root     16 Jan 18 20:52 /usr/lib/libintl.so ->
> > libintl.so.8.1.2
> > lrwxrwxrwx 1 root root     16 Jan 18 20:52 /usr/lib/libintl.so.8 ->
> > libintl.so.8.1.2
> > -rw-r--r-- 1 root root  58924 Jan 18 20:51 /usr/lib/libintl.so.8.1.2
> > 
> > 
> > I am using glibc-2.17
> > 
> > 
> > FAILED: : && /var/lib/sorcery/build/c++  -fPIC -march=native
> > -mtune=native -m64 -pipe  -funroll-loops -O3  -Wnon-virtual-dtor
> > -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W
> > -Wpointer-arith -Wformat-security -fno-exceptions -DQT_NO_EXCEPTIONS
> > -fno-check-new -fno-common -Woverloaded-virtual
> > -fno-threadsafe-statics -Werror=return-type -fvisibility=hidden
> > -fvisibility-inlines-hidden -fvisibility=hidden
> > -fvisibility-inlines-hidden -O2 -DNDEBUG -DQT_NO_DEBUG
> > -Wl,--enable-new-dtags -Wl,--fatal-warnings -Wl,--no-undefined -lc
> > -Wl,--enable-new-dtags -Wl,--fatal-warnings -Wl,--no-undefined -lc
> > -s
> > -shared -Wl,-soname,libki18n.so.5 -o
> > staging/ki18n/src/libki18n.so.5.0.0
> > staging/ki18n/src/CMakeFiles/ki18n.dir/klocalizedstring.cpp.o
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kcatalog.cpp.o
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kuitformats.cpp.o
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kuitsemantics.cpp.o
> > staging/ki18n/src/CMakeFiles/ki18n.dir/common_helpers.cpp.o
> > staging/ki18n/src/CMakeFiles/ki18n.dir/ki18n_automoc.cpp.o
> > /opt/qt5/lib/libQt5Core.so.5.1.0
> > /opt/qt5/lib/libQt5Concurrent.so.5.1.0
> > /opt/qt5/lib/libQt5Xml.so.5.1.0
> > /opt/qt5/lib/libQt5Core.so.5.1.0 -Wl,-rpath,/opt/qt5/lib:::::::::::::
> > && :
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kcatalog.cpp.o: In function
> > `KCatalog::KCatalog(QString const&, QString const&)':
> > kcatalog.cpp:(.text+0x67f): undefined reference to
> > `libintl_bind_textdomain_codeset'
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kcatalog.cpp.o: In function
> > `KCatalogPrivate::setupGettextEnv()':
> > kcatalog.cpp:(.text+0xd1a): undefined reference to
> > `libintl_bindtextdomain'
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kcatalog.cpp.o: In function
> > `KCatalog::translate(QByteArray const&) const':
> > kcatalog.cpp:(.text+0xe68): undefined reference to `libintl_dgettext'
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kcatalog.cpp.o: In function
> > `KCatalog::translate(QByteArray const&, QByteArray const&) const':
> > kcatalog.cpp:(.text+0xfd8): undefined reference to
> > `libintl_dcgettext'
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kcatalog.cpp.o: In function
> > `KCatalog::translate(QByteArray const&, QByteArray const&, unsigned
> > long long) const':
> > kcatalog.cpp:(.text+0x10de): undefined reference to
> > `libintl_dngettext'
> > staging/ki18n/src/CMakeFiles/ki18n.dir/kcatalog.cpp.o: In function
> > `KCatalog::translate(QByteArray const&, QByteArray const&, QByteArray
> > const&, unsigned long long) const':
> > kcatalog.cpp:(.text+0x1272): undefined reference to
> > `libintl_dcngettext'
> > collect2: error: ld returned 1 exit status
> > 
> > 
> > 
> > The following small patch solved it for me
> 
> forgot the patch!
> 
> 
> commit 1f4d953f7e54fae7f74885d11f25ce3661789dce
> Author: Treeve Jelbert <treeve at sourcemage.org>
> Date:   Sun Jan 20 09:36:33 2013 +0100
> 
>      fix libintl detection and usage
> 
> diff --git a/cmake/modules/FindLibintl.cmake
> b/cmake/modules/FindLibintl.cmake
> index 52ae647..f74ae70 100644
> --- a/cmake/modules/FindLibintl.cmake
> +++ b/cmake/modules/FindLibintl.cmake
> @@ -29,8 +29,8 @@ if(LIBINTL_INCLUDE_DIR)
>     check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT)
> 
>     if (LIBINTL_LIBC_HAS_DGETTEXT)
> -    set(LIBINTL_LIBRARIES)
> -    set(LIBINTL_LIB_FOUND TRUE)
> +    set(LIBINTL_LIBRARIES "intl")
> +    set(LIBINTL_LIB_FOUND)
>     else (LIBINTL_LIBC_HAS_DGETTEXT)
>       find_library(LIBINTL_LIBRARIES NAMES intl libintl )
>       if(LIBINTL_LIBRARIES)


the patch is wrong.
This is the code as it is now:

if(LIBINTL_INCLUDE_DIR)
  include(CheckFunctionExists)
  check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT)

  if (LIBINTL_LIBC_HAS_DGETTEXT)
    set(LIBINTL_LIBRARIES)
    set(LIBINTL_LIB_FOUND TRUE)
  else (LIBINTL_LIBC_HAS_DGETTEXT)
    find_library(LIBINTL_LIBRARIES NAMES intl libintl )
    if(LIBINTL_LIBRARIES)
      set(LIBINTL_LIB_FOUND TRUE)
    endif(LIBINTL_LIBRARIES)
  endif (LIBINTL_LIBC_HAS_DGETTEXT)

endif(LIBINTL_INCLUDE_DIR)


The first part checks whether dgettext is available without linking to a 
separate library. In that case, LIBINTL_LIBRARIES is empty.
If it's not the case, it goes into the branch with the find_library() call.

So please create a minimal testcase 
"
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
find_package(LibIntl)
"
(with FindLibIntl.cmake being in the same directory),
and figure out what's going on exactly. Just insert some message(STATUS) 
output where necessary, or run cmake --trace.

Alex


More information about the Kde-frameworks-devel mailing list