Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. CMake set_source_files_properties error
Qt 6.11 is out! See what's new in the release blog

CMake set_source_files_properties error

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 4.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Based on the arrowpad example, it looks like you are not setting everything properly.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • T Teg Miles

      When I'm adding translation files to the CMakeLists this error appears:

      C:\Qt\6.7.1\msvc2019_64\lib\cmake\Qt6LinguistTools\Qt6LinguistToolsMacros.cmake:689:EVAL:1: error: set_source_files_properties given non-existent target for TARGET_DIRECTORY

      How to fix it?

      The CMakeLists:

      cmake_minimum_required(VERSION 3.5)
      
      project(Movar_cpp VERSION 1.0.2 LANGUAGES CXX)
      
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      find_package(Qt6 REQUIRED COMPONENTS Widgets
          LinguistTools WebEngineWidgets TextToSpeech)
      qt_standard_project_setup()
      
      qt_add_resources(images
          PREFIX "/icons"
          FILES movar.png
      )
      
      qt_add_translations(Movar_cpp
          TS_FILES
          i18n/Movar_cpp_uk_UA.ts
          i18n/Movar_cpp_en_US.ts
          i18n/Movar_cpp_ja_JP.ts
          )
      
      qt_add_executable(Movar_cpp
          mainwindow.ui
          mainwindow.h
          mainwindow.cpp
          main.cpp
          dictionarysettings.h
          dictionarysettings.cpp
          dictionarysettings.ui
          fileloader.h
          fileloader.cpp
          app_resources.qrc
          adaptedcompleter.h
          adaptedcompleter.cpp
          adaptedstringlistmodel.h
          adaptedstringlistmodel.cpp
      )
      
      target_link_libraries(Movar_cpp PRIVATE
          Qt6::Widgets
          Qt6::WebEngineWidgets
          Qt6::TextToSpeech)
      
      set_target_properties(Movar_cpp PROPERTIES
          WIN32_EXECUTABLE ON
      )
      
      install(TARGETS Movar_cpp
          BUNDLE  DESTINATION .
          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
      )
      
      
      ekkescornerE Online
      ekkescornerE Online
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #3

      @Teg-Miles take a look at my posts about translations https://t1p.de/ekkeCMakeTranslation
      you're missing set_source_files_properties...

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Teg Miles
        wrote on last edited by
        #4

        qt_add_translations() doesn't work as it described in Qt6 tutorial.
        I changed it to:

        qt_add_lrelease(TS_FILES
            i18n/Movar_cpp_en_US.ts
            i18n/Movar_cpp_ja_JP.ts
            i18n/Movar_cpp_uk_UA.ts
        )
        

        and the translations work fine now.

        1 Reply Last reply
        0
        • ekkescornerE Online
          ekkescornerE Online
          ekkescorner
          Qt Champions 2016
          wrote on last edited by
          #5

          what is your Qt version ?

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps

          T 1 Reply Last reply
          0
          • ekkescornerE ekkescorner

            what is your Qt version ?

            T Offline
            T Offline
            Teg Miles
            wrote on last edited by
            #6

            @ekkescorner 6.7.0

            1 Reply Last reply
            0
            • ekkescornerE Online
              ekkescornerE Online
              ekkescorner
              Qt Champions 2016
              wrote on last edited by
              #7

              for me it works perfect without in Qt 6.7
              but I set the languages in qt_standard_project_setup, which is recommended with 6.7+
              see also https://www.qt.io/blog/revisited-i18n-with-cmake

              ekke ... Qt Champion 2016 | 2024 ... mobile business apps

              T 1 Reply Last reply
              1
              • ekkescornerE ekkescorner

                for me it works perfect without in Qt 6.7
                but I set the languages in qt_standard_project_setup, which is recommended with 6.7+
                see also https://www.qt.io/blog/revisited-i18n-with-cmake

                T Offline
                T Offline
                Teg Miles
                wrote on last edited by
                #8

                @ekkescorner It doesn't work either for me. And then I wrote en_US, uk_UA, ja_JP in I18N_TRANSLATED_LANGUAGES arguments it creates _en.ts files anyway. Is there some inbuilt settings for English language?

                1 Reply Last reply
                0
                • ekkescornerE Online
                  ekkescornerE Online
                  ekkescorner
                  Qt Champions 2016
                  wrote on last edited by ekkescorner
                  #9

                  I know the default SOURCE language is en
                  do you mean you get en_US AND en ?
                  this would be OK if your development-language (SOURCE) is en
                  then as default qt_add_translations will use en for development, also creates a special en for plurals only plus all TRANSLATED languages

                  in my apps where en is my SOURCE language I want to have all translated also in en, so I set NO_GENERATE_PLURALS_TS_FILE

                  ekke ... Qt Champion 2016 | 2024 ... mobile business apps

                  T 1 Reply Last reply
                  0
                  • ekkescornerE ekkescorner

                    I know the default SOURCE language is en
                    do you mean you get en_US AND en ?
                    this would be OK if your development-language (SOURCE) is en
                    then as default qt_add_translations will use en for development, also creates a special en for plurals only plus all TRANSLATED languages

                    in my apps where en is my SOURCE language I want to have all translated also in en, so I set NO_GENERATE_PLURALS_TS_FILE

                    T Offline
                    T Offline
                    Teg Miles
                    wrote on last edited by
                    #10

                    @ekkescorner I found in yours article solution for fixing en_US and en simultaneous ts files creation:

                    qt_standard_project_setup(
                        I18N_SOURCE_LANGUAGE en_US
                        I18N_TRANSLATED_LANGUAGES uk_UA ja_JP
                    )
                    

                    Finally I created CMakeLists that works for me:

                    cmake_minimum_required(VERSION 3.5)
                    
                    project(Movar_cpp VERSION 1.0.2 LANGUAGES CXX)
                    
                    set(CMAKE_CXX_STANDARD 17)
                    set(CMAKE_CXX_STANDARD_REQUIRED ON)
                    
                    find_package(Qt6 REQUIRED COMPONENTS Widgets
                        LinguistTools WebEngineWidgets TextToSpeech)
                    qt_standard_project_setup()
                    
                    qt_add_lupdate(
                        TS_FILES
                        translations/Movar_cpp_en_US.ts
                        translations/Movar_cpp_ja_JP.ts
                        translations/Movar_cpp_uk_UA.ts
                    
                        SOURCES
                        mainwindow.cpp
                        dictionarysettings.cpp
                        fileloader.cpp
                        mainwindow.ui
                        dictionarysettings.ui
                    )
                    
                    qt_add_lrelease(
                        TS_FILES
                        translations/Movar_cpp_en_US.ts
                        translations/Movar_cpp_ja_JP.ts
                        translations/Movar_cpp_uk_UA.ts
                    )
                    
                    qt_add_executable(Movar_cpp
                        mainwindow.ui
                        mainwindow.h
                        mainwindow.cpp
                        main.cpp
                        dictionarysettings.h
                        dictionarysettings.cpp
                        dictionarysettings.ui
                        fileloader.h
                        fileloader.cpp
                        app_resources.qrc
                        adaptedcompleter.h
                        adaptedcompleter.cpp
                        adaptedstringlistmodel.h
                        adaptedstringlistmodel.cpp
                    )
                    
                    add_dependencies(${CMAKE_PROJECT_NAME} update_translations)
                    
                    target_link_libraries(Movar_cpp PRIVATE
                        Qt6::Widgets
                        Qt6::WebEngineWidgets
                        Qt6::TextToSpeech)
                    
                    set_target_properties(Movar_cpp PROPERTIES
                        WIN32_EXECUTABLE ON
                    )
                    
                    install(TARGETS Movar_cpp
                        BUNDLE  DESTINATION .
                        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
                    
                    )
                    
                    

                    I used qt_add_lupdate and qt_add_lrelease.
                    And there must be added function add_dependencies().
                    As I understand, it's old bug with lacking "update_translations" in beforementioned functions.
                    Without it ts files will be empty.

                    1 Reply Last reply
                    0
                    • T Teg Miles has marked this topic as solved on
                    • ekkescornerE Online
                      ekkescornerE Online
                      ekkescorner
                      Qt Champions 2016
                      wrote on last edited by
                      #11

                      curios. but good to hear that you found a working solution.

                      ekke ... Qt Champion 2016 | 2024 ... mobile business apps

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved