Warning, /graphics/kst-plot/cmake/modules/FindLinguistForKst.cmake is written in an unsupported language. File is not indexed.
0001 # Adapted from [trojita.git] / cmake / FindLinguistForTrojita.cmake 0002 # check for lupdate and lrelease: we can't 0003 # do it using qmake as it doesn't have 0004 # QMAKE_LUPDATE and QMAKE_LRELEASE variables :( 0005 # 0006 # I18N_LANGUAGE - if not empty, wraps only chosen language 0007 # 0008 0009 # One problem is that FindQt4.cmake will look for these and cache the results 0010 # If users have lrelease from Qt3 (e.g., Debian, Ubuntu) 0011 # then we will fail. 0012 0013 # TODO 0014 if(RUN_DISABLED_CODE) 0015 # First remove these from cache 0016 set(QT_LUPDATE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) 0017 set(QT_LRELEASE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) 0018 set(QT_LCONVERT_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) 0019 0020 FIND_PROGRAM(QT_LUPDATE_EXECUTABLE NAMES lupdate-qt4 lupdate PATHS 0021 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" 0022 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" 0023 $ENV{QTDIR}/bin 0024 ) 0025 0026 if(QT_LUPDATE_EXECUTABLE) 0027 message(STATUS "Found lupdate: ${QT_LUPDATE_EXECUTABLE}") 0028 else(QT_LUPDATE_EXECUTABLE) 0029 if(LinguistForKst_FIND_REQUIRED) 0030 message(FATAL_ERROR "Could NOT find lupdate") 0031 endif(LinguistForKst_FIND_REQUIRED) 0032 endif(QT_LUPDATE_EXECUTABLE) 0033 0034 FIND_PROGRAM(QT_LRELEASE_EXECUTABLE NAMES lrelease-qt4 lrelease PATHS 0035 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" 0036 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" 0037 $ENV{QTDIR}/bin 0038 ) 0039 0040 if(QT_LRELEASE_EXECUTABLE) 0041 message(STATUS "Found lrelease: ${QT_LRELEASE_EXECUTABLE}") 0042 else(QT_LRELEASE_EXECUTABLE) 0043 if(LinguistForKst_FIND_REQUIRED) 0044 message(FATAL_ERROR "Could NOT find lrelease") 0045 endif(LinguistForKst_FIND_REQUIRED) 0046 endif(QT_LRELEASE_EXECUTABLE) 0047 0048 FIND_PROGRAM(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt4 lconvert PATHS 0049 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" 0050 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" 0051 $ENV{QTDIR}/bin 0052 ) 0053 0054 if(QT_LCONVERT_EXECUTABLE) 0055 message(STATUS "Found lconvert: ${QT_LCONVERT_EXECUTABLE}") 0056 else(QT_LCONVERT_EXECUTABLE) 0057 if(LinguistForKst_FIND_REQUIRED) 0058 message(FATAL_ERROR "Could NOT find lconvert") 0059 endif(LinguistForKst_FIND_REQUIRED) 0060 endif(QT_LCONVERT_EXECUTABLE) 0061 0062 mark_as_advanced(QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_LCONVERT_EXECUTABLE) 0063 0064 endif(RUN_DISABLED_CODE) 0065 0066 find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt4 lconvert) 0067 0068 0069 if(NOT QT_LUPDATE_EXECUTABLE OR NOT QT_LRELEASE_EXECUTABLE OR NOT QT_LCONVERT_EXECUTABLE) 0070 # fall back to global tools if FindQt failed 0071 set(QT_LUPDATE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) 0072 set(QT_LRELEASE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) 0073 set(QT_LCONVERT_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) 0074 FIND_PROGRAM(QT_LUPDATE_EXECUTABLE NAMES lupdate-qt4 lupdate PATHS /usr/bin) 0075 FIND_PROGRAM(QT_LRELEASE_EXECUTABLE NAMES lrelease-qt4 lrelease PATHS /usr/bin) 0076 FIND_PROGRAM(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt4 lconvert PATHS /usr/bin) 0077 endif() 0078 0079 0080 if(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE) 0081 set(LinguistForKst_FOUND TRUE) 0082 0083 # QT4_WRAP_TS(outfiles infiles ...) 0084 # outfiles receives .qm generated files from 0085 # .ts files in arguments 0086 # a target lupdate is created for you 0087 # update/generate your translations files 0088 # example: QT4_WRAP_TS(foo_QM ${foo_TS}) 0089 MACRO (QT4_WRAP_TS outfiles) 0090 # a target to manually run lupdate 0091 #ADD_CUSTOM_TARGET(lupdate 0092 #COMMAND ${QT_LUPDATE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} -ts ${ARGN} 0093 #WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 0094 #) 0095 FOREACH (it ${ARGN}) 0096 GET_FILENAME_COMPONENT(it ${it} ABSOLUTE) 0097 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) 0098 0099 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.qm) 0100 ADD_CUSTOM_COMMAND(OUTPUT ${outfile} 0101 COMMAND ${QT_LRELEASE_EXECUTABLE} 0102 ARGS -compress -removeidentical -silent ${it} -qm ${outfile} 0103 DEPENDS ${it} 0104 ) 0105 0106 SET(${outfiles} ${${outfiles}} ${outfile}) 0107 ENDFOREACH (it) 0108 ENDMACRO (QT4_WRAP_TS) 0109 0110 # QT_WRAP_PO(outfiles infiles ...) 0111 # outfiles receives .qm generated files from 0112 # .po files in arguments 0113 # example: QT4_WRAP_PO(foo_TS ${foo_PO}) 0114 MACRO (QT4_WRAP_PO outfiles) 0115 FOREACH (it ${ARGN}) 0116 GET_FILENAME_COMPONENT(it ${it} ABSOLUTE) 0117 # PO files are foo-en_GB.po not foo_en_GB.po like Qt expects 0118 GET_FILENAME_COMPONENT(fileWithDash ${it} NAME_WE) 0119 if(NOT I18N_LANGUAGE) 0120 set(do_wrap ON) 0121 else(NOT I18N_LANGUAGE) 0122 string(REGEX MATCH "${I18N_LANGUAGE}" ln ${fileWithDash}) 0123 if(ln) 0124 set(do_wrap ON) 0125 else(ln) 0126 set(do_wrap OFF) 0127 endif(ln) 0128 endif(NOT I18N_LANGUAGE) 0129 if(do_wrap) 0130 STRING(REPLACE "-" "_" filenameBase "${fileWithDash}") 0131 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale) 0132 SET(tsfile ${CMAKE_CURRENT_BINARY_DIR}/locale/${filenameBase}.ts) 0133 SET(qmfile ${CMAKE_CURRENT_BINARY_DIR}/locale/${filenameBase}.qm) 0134 0135 if (NOT EXISTS "${it}") 0136 GET_FILENAME_COMPONENT(path ${it} PATH) 0137 STRING(REGEX MATCH "[^-]+$" lang "${fileWithDash}") 0138 set (it "${path}/${lang}.po") 0139 endif (NOT EXISTS "${it}") 0140 0141 # lconvert from PO to TS and then run lupdate to generate the correct strings 0142 # finally run lrelease as used above 0143 ADD_CUSTOM_COMMAND(OUTPUT ${qmfile} 0144 COMMAND ${QT_LCONVERT_EXECUTABLE} 0145 ARGS -i ${it} -o ${tsfile} 0146 COMMAND ${QT_LUPDATE_EXECUTABLE} 0147 ARGS ${CMAKE_CURRENT_SOURCE_DIR} -silent -noobsolete -ts ${tsfile} 0148 COMMAND ${QT_LRELEASE_EXECUTABLE} 0149 ARGS -compress -removeidentical -silent ${tsfile} -qm ${qmfile} 0150 DEPENDS ${it} 0151 ) 0152 SET(${outfiles} ${${outfiles}} ${qmfile}) 0153 endif(do_wrap) 0154 ENDFOREACH (it) 0155 ENDMACRO (QT4_WRAP_PO) 0156 0157 else(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE) 0158 set(LinguistForKst_FOUND FALSE) 0159 endif(QT_LUPDATE_EXECUTABLE AND QT_LRELEASE_EXECUTABLE AND QT_LCONVERT_EXECUTABLE)