[vlmc-devel] CMake: Fix translation tools detection & usage
Hugo Beauzée-Luyssen
git at videolan.org
Fri Mar 4 18:07:09 CET 2016
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Mar 4 18:04:52 2016 +0100| [61119c89a487bbd7f8c75ac99d62bbebb4ab4dcf] | committer: Hugo Beauzée-Luyssen
CMake: Fix translation tools detection & usage
> https://code.videolan.org/videolan/vlmc/commit/61119c89a487bbd7f8c75ac99d62bbebb4ab4dcf
---
ts/CMakeLists.txt | 70 ++++++++++++++-----------------------------------------
1 file changed, 18 insertions(+), 52 deletions(-)
diff --git a/ts/CMakeLists.txt b/ts/CMakeLists.txt
index 11e2445..179f70a 100644
--- a/ts/CMakeLists.txt
+++ b/ts/CMakeLists.txt
@@ -7,39 +7,10 @@
## RCC file
SET(TS_QRC ${CMAKE_SOURCE_DIR}/ts/resources-ts.qrc)
-IF(NOT QT_LUPDATE_EXECUTABLE)
- MESSAGE(WARNING "VLMC could not find lupdate. You won't be able to update translations.")
-ENDIF(NOT QT_LUPDATE_EXECUTABLE)
+if(Qt5LinguistTools_FOUND)
-IF(NOT QT_LRELEASE_EXECUTABLE)
- MESSAGE(WARNING "VLMC could not find lrelease. Your build won't contain translations.")
- ## Create an empty RCC file
- FILE(WRITE ${TS_QRC} "<RCC></RCC>")
-ENDIF(NOT QT_LRELEASE_EXECUTABLE)
-
-
-## Wraps the supplied .ts files in lrelease commands
-MACRO(QT4_ADD_TRANSLATIONS outfiles)
- FILE(WRITE ${TS_QRC} "<RCC><qresource prefix=\"ts\">\n")
- FOREACH (it ${ARGN})
- GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
- GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
-
- FILE(APPEND ${TS_QRC} "<file>${outfile}.qm</file>\n")
-
- SET(outfile ${CMAKE_SOURCE_DIR}/ts/${outfile}.qm)
-
- ADD_CUSTOM_COMMAND(
- OUTPUT ${outfile}
- COMMAND ${QT_LRELEASE_EXECUTABLE}
- ARGS -compress -silent -nounfinished ${it} -qm ${outfile}
- MAIN_DEPENDENCY ${it}
- )
-
- SET(${outfiles} ${${outfiles}} ${outfile})
- ENDFOREACH(it)
- FILE(APPEND ${TS_QRC} "</qresource></RCC>")
-ENDMACRO(QT4_ADD_TRANSLATIONS)
+# Don't remove TS files on make clean.
+set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
## Set availbale translations file ids here
OPTION(LANGUAGES "Using translations")
@@ -94,27 +65,22 @@ FOREACH(LANGUAGE ${LANGUAGES})
LIST(APPEND vlmc_TS ${temp_TS})
ENDFOREACH()
-IF(QT_LRELEASE_EXECUTABLE)
- ## Wraps the collected translations
- qt5_add_translation(vlmc_QMS ${vlmc_TS})
-
- ## Create a target that runs lrelease for all the .ts files
- ## "ALL" means that it will be run by default.
- ADD_CUSTOM_TARGET(translations ALL DEPENDS ${vlmc_QMS})
-ENDIF(QT_LRELEASE_EXECUTABLE)
+## Wraps the collected translations
+qt5_add_translation(vlmc_QMS ${vlmc_TS})
-IF(QT_LUPDATE_EXECUTABLE)
- ## Search for all translatable strings in the sources directory
- FILE(GLOB_RECURSE translate_SRCS ${CMAKE_SOURCE_DIR}/src/*.cpp
- ${CMAKE_SOURCE_DIR}/src/*.hpp)
- FILE(GLOB_RECURSE translate_HDRS ${CMAKE_SOURCE_DIR}/src/*.h)
- FILE(GLOB_RECURSE translate_UIS ${CMAKE_SOURCE_DIR}/src/*.ui)
+## Create a target that runs lrelease for all the .ts files
+## "ALL" means that it will be run by default.
+ADD_CUSTOM_TARGET(translations ALL DEPENDS ${vlmc_QMS})
- SET(translate_SRCS ${translate_SRCS} ${translate_HDRS} ${translate_UIS})
+## Search for all translatable strings in the sources directory
+qt5_create_translation(vlmc_TS_UPDATE ${CMAKE_SOURCE_DIR}/src ${vlmc_TS})
- ## Create a target that runs lupdate for all the sources and UI files
- ADD_CUSTOM_TARGET(lupdate
- COMMAND ${QT_LUPDATE_EXECUTABLE} -noobsolete ${translate_SRCS} -ts ${vlmc_TS} ${CMAKE_SOURCE_DIR}/ts/template.ts
- )
-ENDIF(QT_LUPDATE_EXECUTABLE)
+## Create a target that runs lupdate for all the sources and UI files
+message(STATUS "ts: ${vlmc_TS_UPDATE}")
+ADD_CUSTOM_TARGET(lupdate DEPENDS ${vlmc_TS_UPDATE})
+else()
+ MESSAGE(WARNING "VLMC could not find Qt5 linguist tools. i18n support will be disabled.")
+ ## Create an empty RCC file
+ FILE(WRITE ${TS_QRC} "<RCC></RCC>")
+endif()
More information about the Vlmc-devel
mailing list