Fix use of translations in Qt wizards for Qt 6

qt_create_translation was introduced in Qt 5.15. But we also still
support older Qt versions, so we cannot use it unconditionally.

Fixes: QTCREATORBUG-25070
Change-Id: I81de7e19b42e0e8cb9cb23e14909e71c534dc0da
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Kai Köhne
2020-12-09 09:18:02 +01:00
committed by Kai Koehne
parent 428ac96dd1
commit ca992488c0
4 changed files with 26 additions and 10 deletions

View File

@@ -30,5 +30,9 @@ add_executable(%{ProjectName}
target_link_libraries(%{ProjectName} Qt${QT_VERSION_MAJOR}::Core)
@if %{HasTranslation}
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
if(COMMAND qt_create_translation)
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
@endif

View File

@@ -46,5 +46,9 @@ target_compile_definitions(%{ProjectName} PRIVATE %{LibraryDefine})
@endif
@if %{HasTranslation}
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
if(COMMAND qt_create_translation)
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
@endif

View File

@@ -46,6 +46,10 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(%{ProjectName}
${PROJECT_SOURCES}
)
@if %{HasTranslation}
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
@endif
else()
if(ANDROID)
add_library(%{ProjectName} SHARED
@@ -56,13 +60,13 @@ else()
${PROJECT_SOURCES}
)
endif()
@if %{HasTranslation}
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
@endif
endif()
target_compile_definitions(%{ProjectName}
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(%{ProjectName}
PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick)
@if %{HasTranslation}
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
@endif

View File

@@ -50,6 +50,10 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(%{ProjectName}
${PROJECT_SOURCES}
)
@if %{HasTranslation}
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
@endif
else()
if(ANDROID)
add_library(%{ProjectName} SHARED
@@ -60,10 +64,10 @@ else()
${PROJECT_SOURCES}
)
endif()
@if %{HasTranslation}
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
@endif
endif()
target_link_libraries(%{ProjectName} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
@if %{HasTranslation}
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
@endif