MantisBT - CMake
View Issue Details
0014904CMakeModulespublic2014-05-05 10:162016-06-10 14:31
Aurélien Gâteau 
Kitware Robot 
normalminoralways
closedmoved 
CMake 2.8.12.2 
 
0014904: Gettext module does not allow installing .po files with the same name from different directories
I have the following directory hierarchy:

app/
  src/
  po/
    es/
      app.po
    fr/
      app.po
  CMakeLists.txt

I would like to have all code handling the translation files in the top-level CMakeLists.txt file so that new translations can be added inside the "po" directory without adding any CMake code.

app/CMakeLists.txt looks like this:

    find_package(Gettext REQUIRED)

    foreach(lang fr es)
        gettext_process_po_files(${lang} ALL
            INSTALL_DESTINATION share/locale
            PO_FILES po/${lang}/test.po)
    endforeach()

But this does not work. Running CMake outputs the following error:

CMake Error: Attempt to add a custom rule to output "(...)/app/build/app.gmo.rule" which already has a custom rule.
- Unpack attached test-case
- Run cmake
I worked around that bug by copying the code from gettext_process_po_files() in my project and adjusting it like this:

diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake
index 6a1e36e..4b3ada7 100644
--- a/Modules/FindGettext.cmake
+++ b/Modules/FindGettext.cmake
@@ -203,7 +203,7 @@ function(GETTEXT_PROCESS_PO_FILES _lang)
    foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
       get_filename_component(_name ${_current_PO_FILE} NAME)
       string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
- set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
+ set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}-${_basename}.gmo)
       add_custom_command(OUTPUT ${_gmoFile}
             COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
             WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
@@ -211,7 +211,7 @@ function(GETTEXT_PROCESS_PO_FILES _lang)
          )
 
       if(_parsedArguments_INSTALL_DESTINATION)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_
+ install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES
       endif()
       list(APPEND _gmoFiles ${_gmoFile})
    endforeach()

Not sure if this is the best fix, though.
No tags attached.
bz2 cmake-gettext-pofile-name.tar.bz2 (506) 2014-05-05 10:16
https://public.kitware.com/Bug/file/5141/cmake-gettext-pofile-name.tar.bz2
Issue History
2014-05-05 10:16Aurélien GâteauNew Issue
2014-05-05 10:16Aurélien GâteauFile Added: cmake-gettext-pofile-name.tar.bz2
2016-06-10 14:29Kitware RobotNote Added: 0042543
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0042543)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.