From: Manuel Nickschas Date: Wed, 24 Sep 2008 22:05:53 +0000 (+0200) Subject: More changes to the build system; make i18n generation nicer X-Git-Tag: 0.3.1~254 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=392367381225027246e8c765a7c3b7e5bf186ee2 More changes to the build system; make i18n generation nicer --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8343a9..8b7e3dbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,6 +173,11 @@ if(WIN32) set(RC_WIN32 pics/win32.rc) # for app icons on windows endif(WIN32) +# This is dirty, but I haven't found a cleaner way to ensure that the generated .qrc files +# (which will be removed with make clean) are regenerated :/ +set_directory_properties(PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES CMakeCache.txt) + # We need to create a version.gen # For this, we create our genversion binary and make sure it is run every time. add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp) @@ -183,14 +188,10 @@ add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/common/version.gen) add_dependencies(genversion_run genversion) -# Generate binary translation files -include(QuasselGenerateTranslations) -quassel_generate_i18n_resource(RC_I18N ${LINGUAS}) - # These variables will be added to the main targets (CORE, QTCLIENT, MONO) -set(COMMON_DEPS ${RC_I18N} ${RC_WIN32}) +set(COMMON_DEPS ${RC_WIN32}) set(CORE_DEPS ) set(CLIENT_DEPS ) set(KDE_DEPS ) @@ -199,6 +200,7 @@ set(KDE_DEPS ) add_subdirectory(data) add_subdirectory(icons) #add_subdirectory(pics) +add_subdirectory(i18n) add_subdirectory(src) # Make sure version.gen exists before building mod_common diff --git a/cmake/modules/QuasselGenerateTranslations.cmake b/cmake/modules/QuasselGenerateTranslations.cmake deleted file mode 100644 index a5fc97dd..00000000 --- a/cmake/modules/QuasselGenerateTranslations.cmake +++ /dev/null @@ -1,68 +0,0 @@ -# This file contains macros dealing with translation -# files for Quassel IRC. - -# Copyright (C) 2008 by the Quassel Project, devel@quassel-irc.org -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -macro(quassel_generate_qm outvar basename) - set(input ${CMAKE_SOURCE_DIR}/i18n/${basename}.ts) - set(output ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qm) - add_custom_command(OUTPUT ${output} - COMMAND ${QT_LRELEASE_EXECUTABLE} - ARGS ${input} - -qm ${output} - -silent -compress - DEPENDS ${CMAKE_SOURCE_DIR}/i18n/${basename}.ts) - set(${outvar} ${output}) -endmacro(quassel_generate_qm outvar basename) - -macro(quassel_generate_i18n_resource outvar) - set(linguas ${ARGN}) - if(QT_LRELEASE_EXECUTABLE) - # We always include quassel.ts - quassel_generate_qm(QM quassel) - set(outfiles ${QM}) - - # Find more languages - file(GLOB avail_tsfiles ${CMAKE_SOURCE_DIR}/i18n/quassel_*.ts) - foreach(TS_FILE ${avail_tsfiles}) - get_filename_component(basename ${TS_FILE} NAME_WE) - string(REGEX REPLACE "quassel_(.+)$" "\\1" lang ${basename}) - # test if we want this - set(flg 1) - if(linguas) - string(REGEX MATCH "${lang}" flg ${linguas}) - endif(linguas) - if(flg) - quassel_generate_qm(QM ${basename}) - set(outfiles ${outfiles} ${QM}) - set(gen_linguas "${gen_linguas} ${lang}") - endif(flg) - endforeach(TS_FILE ${avail_tsfiles}) - - # Write resource file - set(resfile ${CMAKE_CURRENT_BINARY_DIR}/i18n.qrc) - file(WRITE ${resfile} "\n" - "\n") - foreach(file ${outfiles}) - get_filename_component(file ${file} NAME) - file(APPEND ${resfile} " ${file}\n") - endforeach(file ${outfiles}) - file(APPEND ${resfile} "\n\n") - add_custom_command(OUTPUT ${resfile} DEPENDS ${outfiles}) - #set_directory_properties(PROPERTIES - # ADDITIONAL_MAKE_CLEAN_FILES "${outfiles} i18n.qrc") - - # Generate resource - qt4_add_resources(RC_OUT ${resfile}) - set(${outvar} ${RC_OUT}) - - message(STATUS "Including languages:${gen_linguas}") - else(QT_LRELEASE_EXECUTABLE) - message(STATUS "WARNING: lrelease not found, you won't have translations!") - endif(QT_LRELEASE_EXECUTABLE) -endmacro(quassel_generate_i18n_resource outvar) - diff --git a/cmake/modules/QuasselMacros.cmake b/cmake/modules/QuasselMacros.cmake index 099e8a22..d16dcd42 100644 --- a/cmake/modules/QuasselMacros.cmake +++ b/cmake/modules/QuasselMacros.cmake @@ -13,3 +13,16 @@ macro(setup_qt4_variables) endforeach(qtmod ${ARGV}) set(QUASSEL_QT_LIBRARIES ${QUASSEL_QT_LIBRARIES} ${QT_LIBRARIES}) endmacro(setup_qt4_variables) + +# This generates a .qm from a .ts file +macro(generate_qm outvar basename) + set(input ${basename}.ts) + set(output ${CMAKE_CURRENT_BINARY_DIR}/${basename}.qm) + add_custom_command(OUTPUT ${output} + COMMAND ${QT_LRELEASE_EXECUTABLE} + ARGS ${input} + -qm ${output} + -silent -compress + DEPENDS ${basename}.ts) + set(${outvar} ${output}) +endmacro(generate_qm outvar basename) \ No newline at end of file diff --git a/i18n/CMakeLists.txt b/i18n/CMakeLists.txt new file mode 100644 index 00000000..05aa11f1 --- /dev/null +++ b/i18n/CMakeLists.txt @@ -0,0 +1,42 @@ +# Generate and add translations +# The LINGUAS variable can be used to limit that set + +if(QT_LRELEASE_EXECUTABLE) + # We always include quassel.ts + generate_qm(QM quassel) + set(qm_files ${QM}) + + # Find more languages + file(GLOB avail_tsfiles quassel_*.ts) + foreach(TS_FILE ${avail_tsfiles}) + get_filename_component(basename ${TS_FILE} NAME_WE) + string(REGEX REPLACE "quassel_(.+)$" "\\1" lang ${basename}) + # test if we want this + set(flg 1) + if(linguas) + string(REGEX MATCH "${lang}" flg ${linguas}) + endif(linguas) + if(flg) + generate_qm(QM ${basename}) + set(qm_files ${qm_files} ${QM}) + set(gen_linguas "${gen_linguas} ${lang}") + endif(flg) + endforeach(TS_FILE ${avail_tsfiles}) + + # Write resource file + set(resfile ${CMAKE_BINARY_DIR}/i18n.qrc) + file(WRITE ${resfile} "\n" + "\n") + foreach(file ${qm_files}) + get_filename_component(file ${file} NAME) + file(APPEND ${resfile} " ${file}\n") + endforeach(file ${qm_files}) + file(APPEND ${resfile} "\n\n") + add_custom_command(OUTPUT ${resfile} DEPENDS ${qm_files}) + #set_directory_properties(PROPERTIES + # ADDITIONAL_MAKE_CLEAN_FILES "${outfiles} i18n.qrc") + + message(STATUS "Including languages:${gen_linguas}") +else(QT_LRELEASE_EXECUTABLE) + message(STATUS "WARNING: lrelease not found, you won't have translations!") +endif(QT_LRELEASE_EXECUTABLE) diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 6393b1b8..c28de2ea 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -6,8 +6,6 @@ else(QUASSEL_ICONS MATCHES "External") set(CLIENT_DEPS ${CLIENT_DEPS} hicolor.qrc) endif(QUASSEL_ICONS MATCHES "External") -if(OXYGEN_ICONS MATCHES "External") - install(DIRECTORY oxygen DESTINATION ${ICON_INSTALL_DIR}) -else(OXYGEN_ICONS MATCHES "External") +if(OXYGEN_ICONS MATCHES "Builtin") set(CLIENT_DEPS ${CLIENT_DEPS} oxygen.qrc) -endif(OXYGEN_ICONS MATCHES "External") +endif(OXYGEN_ICONS MATCHES "Builtin") diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 3dfd92a0..fe4f33e6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -50,8 +50,11 @@ set(HEADERS ${MOC_HDRS} qt4_wrap_cpp(MOC ${MOC_HDRS}) +# Languages +qt4_add_resources(RC_I18N ${CMAKE_BINARY_DIR}/i18n.qrc) + include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) # for version.inc and version.gen add_definitions(-DHAVE_VERSION_GEN) # we ensure that by deps in the main CMakeLists.txt set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES version.gen) -add_library(mod_common STATIC ${SOURCES} ${MOC}) +add_library(mod_common STATIC ${SOURCES} ${MOC} ${RC_I18N})