View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014904CMakeModulespublic2014-05-05 10:162016-06-10 14:31
ReporterAurélien Gâteau 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake 2.8.12.2 
Target VersionFixed in Version 
Summary0014904: Gettext module does not allow installing .po files with the same name from different directories
DescriptionI 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.
Steps To Reproduce- Unpack attached test-case
- Run cmake
Additional InformationI 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.
TagsNo tags attached.
Attached Filesbz2 file icon cmake-gettext-pofile-name.tar.bz2 [^] (506 bytes) 2014-05-05 10:16

 Relationships

  Notes
(0042543)
Kitware Robot (administrator)
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.

 Issue History
Date Modified Username Field Change
2014-05-05 10:16 Aurélien Gâteau New Issue
2014-05-05 10:16 Aurélien Gâteau File Added: cmake-gettext-pofile-name.tar.bz2
2016-06-10 14:29 Kitware Robot Note Added: 0042543
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team