Empty .ts files after lupdate (CMake and macOS 6.3.2)
-
Hi there!
I need help again here because I was not able to find a solution on the web. I do not manage to get a translation file. Here is minimal example:
Created a new project "Qt Widget Application"
Choose CMake
Selected Qt 6.3.2 for macOS as kit
Selected a language (English)
Created the project.Add a label to the design file with "Test Label" as text.
Add QObject::tr("Test String"); to mainwindow.cppWhen I run the project it compiles.
Running lupdate from Qt Creator:lupdate warning: no TS files specified. Only diagnostics will be produced.
CMakeLists.txt was generated by Qt Creator and includes:
set(TS_FILES Test_en_GB.ts) set(PROJECT_SOURCES main.cpp mainwindow.cpp mainwindow.h mainwindow.ui ${TS_FILES} )
Is there a bug in the CMake create process? Do I need to do something extra? In one tutorial I saw that they added some lines to copy qm files. Is that missing?
-
Thanks for the link but it does not really help me. It does not say but I am assuming they are talking about the CMakeListe.txt, correct?
Here is my full CmakeList after editing:cmake_minimum_required(VERSION 3.5) project(ncNotes VERSION 0.1 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) set(TS_FILES ncNotes_en_EN.ts ncNotes_de_DE.ts) set(PROJECT_SOURCES main.cpp mainwindow.cpp mainwindow.h notemodel.cpp notemodel.h mainwindow.ui infoDialog.ui ${TS_FILES} ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(ncNotes MANUAL_FINALIZATION ${PROJECT_SOURCES} ) qt6_add_translations(ncNotes TS_FILES ncNotes_de_DE.ts) // added this line # Define target properties for Android with Qt 6 as: # set_property(TARGET ncNotes APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation # qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) // commented this out because it caused an error (see below) else() if(ANDROID) add_library(ncNotes SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() add_executable(ncNotes ${PROJECT_SOURCES} ) endif() qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) endif() target_link_libraries(ncNotes PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) set_target_properties(ncNotes PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) install(TARGETS ncNotes BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(ncNotes) endif()
Error Message:
Attempt to add a custom rule to output /Users/xxx/ncNotes/build-ncNotes-Qt_6_3_2_for_macOS-Debug/ncNotes_de_DE.qm.rule which already has a custom rule.
Is there a little more documentation or an example that could help understanding this?
-
I just redid the project with qmake an here everything works out of the box. Also adding an icon, which I was not able to do with the official documentation.
So I expect there is something wrong with the creation process of CMakeListe.txt?