PDA

View Full Version : Problems with localization when moving to Qt5 (cmake)



WereWind
19th April 2017, 09:45
Hello everyone.

I'm moving a quite huge app in cmake from Qt4 to Qt5. So far it was quite easy however I ran into some problems when I tried adding localization. Since the projact has a lot of subfolders the translation files are handled in a separate function


function (create_translations TRANSLATIONS_FILE_PATH)
file (GLOB_RECURSE FILES_TO_TRANSLATE
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/*.ui")

file (GLOB_RECURSE TRANSLATION_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/*.ts")

qt5_create_translation (CURRENT_TRANSLATIONS_FILE_PATH
"${FILES_TO_TRANSLATE}"
"${TRANSLATION_FILES}")

set ("${TRANSLATIONS_FILE_PATH}"
"${CURRENT_TRANSLATIONS_FILE_PATH}"
PARENT_SCOPE)
endfunction ()

And in the proper CMakeLists.txt files there is something like


create_translations (MY_TRANSLATIONS)
install (FILES ${MY_TRANSLATIONS}
DESTINATION "${TARGET_TRANSLATIONS_INSTALL_PATH}")

The cmake runs well and .qm files are properly created. However the make fails almost immediately with the following error


/bin/sh: 1: @/home/path/to/build/someapp/CMakeFiles/someapp_ru_lst_file: not found someapp/CMakeFiles/someapp.dir/build.make:88: recipe for target '/home/path/to/sources/translations/someapp_ru.ts' failed
make[2]: * [/home/path/to/sources/translations/someapp_ru.ts] Error 127
make[1]: * [someapp/CMakeFiles/someapp.dir/all] Error 2 CMakeFiles/Makefile2:608: recipe for target 'someapp/CMakeFiles/someapp.dir/all' failed

The curious thing is that the file /home/path/to/build/someapp/CMakeFiles/someapp_ru_lst_file that is reported missing actually exists, so I have no idea what went wrong