mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-16 19:54:13 +02:00
The Qt6 CMake signatures for translation handling changed multiple times with minor versions.
This commit is contained in:
+70
-16
@@ -148,26 +148,80 @@ endif()
|
|||||||
# build rewrote tracked files as a side effect, and under high parallelism
|
# build rewrote tracked files as a side effect, and under high parallelism
|
||||||
# lupdate rewriting a .ts while lrelease read the same file made the build
|
# lupdate rewriting a .ts while lrelease read the same file made the build
|
||||||
# fail with "Premature end of document".
|
# fail with "Premature end of document".
|
||||||
|
set_source_files_properties(
|
||||||
|
${TS_FILES}
|
||||||
|
PROPERTIES OUTPUT_LOCATION "${QET_DIR}/lang"
|
||||||
|
)
|
||||||
if(QT_VERSION_MAJOR EQUAL 6)
|
if(QT_VERSION_MAJOR EQUAL 6)
|
||||||
qt_add_lrelease(
|
if(Qt6_VERSION VERSION_LESS "6.2")
|
||||||
TARGETS ${PROJECT_NAME}
|
# Qt 6.0–6.1
|
||||||
TS_FILES ${TS_FILES}
|
qt6_add_translation(QM_FILES ${TS_FILES})
|
||||||
QM_OUTPUT_DIRECTORY "${QET_DIR}/lang"
|
|
||||||
QM_FILES_OUTPUT_VARIABLE QM_FILES
|
# qt6_add_translation() only creates custom commands. Something must
|
||||||
)
|
# depend on their outputs for them to run during the default build.
|
||||||
qt_add_lupdate(
|
add_custom_target(${PROJECT_NAME}_lrelease ALL
|
||||||
TS_FILES ${TS_FILES}
|
DEPENDS ${QM_FILES}
|
||||||
SOURCE_TARGETS ${PROJECT_NAME}
|
)
|
||||||
LUPDATE_TARGET update_translations
|
|
||||||
COMMENT "Updating .ts files from sources/ (lupdate) - developer target, run explicitly"
|
add_custom_target(update_translations
|
||||||
)
|
COMMAND
|
||||||
|
$<TARGET_FILE:Qt6::lupdate>
|
||||||
|
"${CMAKE_SOURCE_DIR}/sources"
|
||||||
|
-ts ${TS_FILES}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
COMMENT
|
||||||
|
"Updating .ts files from sources/ (lupdate) - developer target"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
elseif(Qt6_VERSION VERSION_LESS "6.7")
|
||||||
|
# Qt 6.2–6.6: old target-based signature
|
||||||
|
qt_add_lrelease(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
TS_FILES ${TS_FILES}
|
||||||
|
QM_FILES_OUTPUT_VARIABLE QM_FILES
|
||||||
|
)
|
||||||
|
|
||||||
|
# Automatically creates the update_translations umbrella target.
|
||||||
|
qt_add_lupdate(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
TS_FILES ${TS_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
# Qt 6.7+: new signature
|
||||||
|
qt_add_lrelease(
|
||||||
|
TS_FILES ${TS_FILES}
|
||||||
|
LRELEASE_TARGET ${PROJECT_NAME}_lrelease
|
||||||
|
QM_FILES_OUTPUT_VARIABLE QM_FILES
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_add_lupdate(
|
||||||
|
SOURCE_TARGETS ${PROJECT_NAME}
|
||||||
|
TS_FILES ${TS_FILES}
|
||||||
|
LUPDATE_TARGET update_translations
|
||||||
|
NO_GLOBAL_TARGET
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${QET_DIR}/lang")
|
# Qt 5
|
||||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||||
|
|
||||||
|
# Likewise, qt5_add_translation() needs a target depending on its outputs,
|
||||||
|
# unless QM_FILES are already consumed elsewhere.
|
||||||
|
add_custom_target(${PROJECT_NAME}_lrelease ALL
|
||||||
|
DEPENDS ${QM_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_target(update_translations
|
add_custom_target(update_translations
|
||||||
COMMAND $<TARGET_FILE:Qt${QT_VERSION_MAJOR}::lupdate> ${CMAKE_SOURCE_DIR}/sources -ts ${TS_FILES}
|
COMMAND
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
$<TARGET_FILE:Qt5::lupdate>
|
||||||
COMMENT "Updating .ts files from sources/ (lupdate) - developer target, run explicitly"
|
"${CMAKE_SOURCE_DIR}/sources"
|
||||||
|
-ts ${TS_FILES}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
COMMENT
|
||||||
|
"Updating .ts files from sources/ (lupdate) - developer target"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user