Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt 5.0.2 + CMake 2.8.11.1 + QT5_CREATE_TRANSLATION: how to prevent delete existing ts file during clean
Forum Updated to NodeBB v4.3 + New Features

Qt 5.0.2 + CMake 2.8.11.1 + QT5_CREATE_TRANSLATION: how to prevent delete existing ts file during clean

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 1 Posters 3.1k Views 1 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.
  • AnatolySA Offline
    AnatolySA Offline
    AnatolyS
    wrote on last edited by
    #1

    I use QT5_CREATE_TRANSLATION inside my CMakelists.txt to keep my ts files in actual state. It is very useful. But when I call make clean my ts files are cleaned also. If I understand right it is because of

    add_custom_command(OUTPUT ${_ts_file}
    COMMAND ${Qt5_LUPDATE_EXECUTABLE}
    ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
    DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM)

    inside the QT5_CREATE_TRANSLATION function.

    Is there way to prevent ts file deletion during the clean operation?

    Thanks in advance.

    1 Reply Last reply
    0
    • AnatolySA Offline
      AnatolySA Offline
      AnatolyS
      wrote on last edited by
      #2

      I have written the following patch for Qt5LinguistToolsMacros.cmake which can solve the above problem:
      @
      *** C:/Qt/Qt5.0.2/5.0.2/msvc2010/lib/cmake/Qt5LinguistTools/Qt5LinguistToolsMacros.cmake.old Wed Jun 19 12:00:16 2013
      --- C:/Qt/Qt5.0.2/5.0.2/msvc2010/lib/cmake/Qt5LinguistTools/Qt5LinguistToolsMacros.cmake Wed Jun 19 11:48:38 2013


      *** 52,57 ****
      --- 52,59 ----
      list(APPEND _my_sources ${_abs_FILE})
      endif()
      endforeach()

      • declare temp ts files list

      • set(_my_temptsfiles)
        foreach(_ts_file ${_my_tsfiles})
            if(_my_sources)
              # make a list file to call lupdate on, so we don't make our commands too
        

      *** 71,83 ****

              file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
            endif()
            add_custom_command(
      

      ! OUTPUT ${_ts_file}
      COMMAND ${Qt5_LUPDATE_EXECUTABLE}
      ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
      DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM)
      endforeach()
      ! qt5_add_translation(${_qm_files} ${_my_tsfiles})
      set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
      endfunction()

      --- 73,93 ----

              file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
            endif()
      
      •     get_filename_component(_ts_nm ${_ts_file} NAME)
        
      • set(_tmpts_file "${CMAKE_CURRENT_BINARY_DIR}/${_ts_nm}")
      • list(APPEND _my_temptsfiles ${_tmpts_file})
      •     get_source_file_property(_qm_output_location ${_ts_file} OUTPUT_LOCATION)
            add_custom_command(
        

      ! OUTPUT ${_tmpts_file}
      COMMAND ${Qt5_LUPDATE_EXECUTABLE}
      ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}

      • COMMAND ${CMAKE_COMMAND} -E copy ${_ts_file} ${_tmpts_file}
        DEPENDS ${_my_sources} ${_ts_lst_file} VERBATIM)
      • if( _qm_output_location )
      • set_property(SOURCE ${_tmpts_file} PROPERTY OUTPUT_LOCATION ${_qm_output_location})
      • endif()
        endforeach()
        ! qt5_add_translation(${_qm_files} ${_my_temptsfiles})
        set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
        endfunction()
        @
      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