Commit fb4af655 authored by Ludovic Fauvet's avatar Ludovic Fauvet

cmake: improve translation mechanism.

- Improve detection of lupdate/lrelease binaries.
- Provide 'make lupdate' command to update all translations.
parent 9abbeb99
......@@ -92,6 +92,7 @@ IF (UNIX)
SET (VLMC_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_MANUAL_SUBDIR})
ENDIF (UNIX)
SUBDIRS(ts)
SUBDIRS(launcher)
SUBDIRS(src)
......
......@@ -3,36 +3,6 @@
SUBDIRS(EffectsEngine/Plugins/src)
MACRO(ADD_TRANSLATION_FILES _sources )
FOREACH (_current_FILE ${ARGN})
GET_FILENAME_COMPONENT(_in ${_current_FILE} ABSOLUTE)
GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)
SET(_out ${CMAKE_SOURCE_DIR}/ts/${_basename}.qm)
ADD_CUSTOM_COMMAND(
OUTPUT ${_out}
COMMAND ${QT_LRELEASE_EXECUTABLE}
ARGS -verbose ${_in} -qm ${_out}
DEPENDS ${_in}
)
SET(${_sources} ${${_sources}} ${_out} )
ENDFOREACH (_current_FILE)
ENDMACRO(ADD_TRANSLATION_FILES)
FILE (GLOB TS_FILES ${CMAKE_SOURCE_DIR}/ts/*.ts)
set_property( DIRECTORY PROPERTY APPEND PROPERTY COMPILE_DEFINITIONS TS_DIR="${CMAKE_SOURCE_DIR}/ts/" )
ADD_TRANSLATION_FILES (VLMC_QM ${TS_FILES})
# creating a custom target is needed to make the files build
# "ALL" means that it will be run by default
ADD_CUSTOM_TARGET (translations ALL
DEPENDS ${VLMC_QM})
SET(VLMC_SRCS
main.cpp
Actions/ActionStack.cpp
......
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(NOT QT_LRELEASE_EXECUTABLE)
MESSAGE(WARNING "VLMC could not find lrelease. Your build won't contain translations.")
ENDIF(NOT QT_LRELEASE_EXECUTABLE)
## Wraps the supplied .ts files in lrelease commands
MACRO(QT4_ADD_TRANSLATIONS outfiles)
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
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)
ENDMACRO(QT4_ADD_TRANSLATIONS)
## Collect all translations files
FILE (GLOB vlmc_TS ${CMAKE_SOURCE_DIR}/ts/*.ts)
IF(QT_LRELEASE_EXECUTABLE)
## Wraps the collected translations
QT4_ADD_TRANSLATIONS(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)
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)
SET(translate_SRCS ${translate_SRCS} ${translate_HDRS} ${translate_UIS})
## 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}
)
ENDIF(QT_LUPDATE_EXECUTABLE)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment