MantisBT - CMake
View Issue Details
0013691CMakeModulespublic2012-11-16 15:212013-04-17 08:54
Herbert Thielen 
Rolf Eike Beer 
normalmajoralways
closedfixed 
CMake 2.8.10.1 
CMake 2.8.10.2CMake 2.8.10.2 
0013691: FindGettext.cmake does not set GETTEXT_FOUND on success
When using "find_package(Gettext)", the variable GETTEXT_FOUND is not set even if the gettext tools are installed and can be found.
Use a CMakeLists.txt with e.g.

===== snip =====
find_package(Gettext)
if (GETTEXT_FOUND)
  message (WARNING "All is fine, gettext found.")
else (GETTEXT_FOUND)
  message (WARNING "Did not find gettext.")
endif (GETTEXT_FOUND)
===== snap =====

and run 'cmake --trace path/to/project/dir'. The FindGettext.cmake modules tells you when msgmerge etc. are found, but even if the tools are found, the output of the lines above will be "Did not find gettext" because GETTEXT_FOUND is not set in the scope of CMakeLists.txt.

Probably this is not related to Windows, but I didn't try this version on other platforms.
The following patch helped:

$ diff -u FindGettext.cmake~ FindGettext.cmake
--- FindGettext.cmake~ 2012-11-06 20:45:28.000000000 +0100
+++ FindGettext.cmake 2012-11-16 17:57:47.139133300 +0100
@@ -210,4 +210,4 @@

 endfunction()

-set(GETTEXT_FOUND ${Gettext_FOUND})
+set(GETTEXT_FOUND ${Gettext_FOUND} PARENT_SCOPE)
No tags attached.
Issue History
2012-11-16 15:21Herbert ThielenNew Issue
2012-11-16 15:38Rolf Eike BeerNote Added: 0031583
2012-11-16 15:48Herbert ThielenNote Added: 0031584
2012-11-17 05:17Amine ChadlyNote Added: 0031592
2012-11-22 05:47Dmitrijs LedkovsNote Added: 0031676
2012-11-22 06:59Herbert ThielenNote Added: 0031677
2012-11-22 12:19Dmitrijs LedkovsNote Added: 0031678
2012-11-22 12:23Dmitrijs LedkovsNote Added: 0031679
2012-11-25 09:30Rolf Eike BeerNote Added: 0031701
2012-11-25 09:30Rolf Eike BeerAssigned To => Rolf Eike Beer
2012-11-25 09:30Rolf Eike BeerStatusnew => resolved
2012-11-25 09:30Rolf Eike BeerResolutionopen => fixed
2012-11-25 09:30Rolf Eike BeerOSWindows =>
2012-11-25 09:30Rolf Eike BeerOS VersionWindows 7 =>
2012-11-25 09:30Rolf Eike BeerPlatformMicrosoft =>
2012-11-25 09:30Rolf Eike BeerFixed in Version => CMake 2.8.11
2012-11-25 09:30Rolf Eike BeerTarget Version => CMake 2.8.11
2012-11-25 09:30Rolf Eike BeerSummaryFindGettext.cmake does not set GETTEXT_FOUND in PARENT_SCOPE => FindGettext.cmake does not set GETTEXT_FOUND on success
2012-11-26 08:58Brad KingNote Added: 0031706
2012-11-27 15:23David ColeFixed in VersionCMake 2.8.11 => CMake 2.8.10.2
2012-11-27 15:23David ColeTarget VersionCMake 2.8.11 => CMake 2.8.10.2
2013-04-17 08:54Robert MaynardNote Added: 0032885
2013-04-17 08:54Robert MaynardStatusresolved => closed

Notes
(0031583)
Rolf Eike Beer   
2012-11-16 15:38   
This change is wrong, no Find*.cmake module sets this variable in PARENT_SCOPE.
(0031584)
Herbert Thielen   
2012-11-16 15:48   
Sorry, I'm not an experienced cmake script developer. At least it helped for me, the problem root cause may be something else.
(0031592)
Amine Chadly   
2012-11-17 05:17   
Herbert, it does looks like you calling the FindGettext from the wrong scope don't you think ?
(0031676)
Dmitrijs Ledkovs   
2012-11-22 05:47   
This now fails:
if ("${GETTEXT_FOUND}" STREQUAL "TRUE")

Please use:
if (GETTEXT_FOUND)

This one works with both old and new CMake.

@Developers close as invalid/won't fix? Is this change appropriate in a point release? It breaks previously working CMakeLists.txt.
(0031677)
Herbert Thielen   
2012-11-22 06:59   
@Amine: What exactly do you mean with 'from the wrong scope'? The line
  find_package(Gettext)
is the first statement in CMakeLists.txt which resides in a subdirectory of my source tree. In the same CMakeLists.txt, there is a sequence
  if (GETTEXT_FOUND)
  ...
  else (GETTEXT_FOUND)
    message (WARNING "Did not find gettext, will not create message object")
  endif (GETTEXT_FOUND)

@Ddmitrijs: I'm using 'if (GETTEXT_FOUND)' - something else wrong?


If I run cmake in the build directory, I get
  $ cmake --version
  cmake version 2.8.10.1
  $ cmake -DCMAKE_BUILD_TYPE=Debug ..
  -- Found Gettext: /usr/bin/msgmerge (found version "0.18.1")
  CMake Warning at src/locale/CMakeLists.txt:69 (message):
    Did not find gettext, will not create message object
  
  
  -- Configuring done
  -- Generating done
  -- Build files have been written to: ...


Using cmake 2.8.7 (as available in Ubuntu 12.04 64-Bit), all is fine:


$ cmake --version
cmake version 2.8.7
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Gettext: /usr/bin/msgmerge
-- Configuring done
-- Generating done
-- Build files have been written to: ...
(0031678)
Dmitrijs Ledkovs   
2012-11-22 12:19   
Well, quite. I now believe this is a bug in cmake.

OpenSUSE applied this patch:
http://www.mail-archive.com/opensuse-commit@opensuse.org/msg28785.html [^]

And so do I in Ubuntu Raring right now.

GETTEXT_FOUND is not set to anything it appears in the 2.8.10.1. CMake developers please fix. This is now critical.

Ubuntu & OpenSUSE have now patched this issue in cmake, but other platforms are affected.
(0031679)
Dmitrijs Ledkovs   
2012-11-22 12:23   
(also mantis fails to correctly parse urls with @ in them)
(0031701)
Rolf Eike Beer   
2012-11-25 09:30   
Fix merged to next:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94f37851ef5c6dccbe2dd647a3b38e3196393298 [^]
(0031706)
Brad King   
2012-11-26 08:58   
Rebased fix on a pre-2.8.10 commit:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7be2534 [^]
(0032885)
Robert Maynard   
2013-04-17 08:54   
Closing resolved issues that have not been updated in more than 4 months.