Browse Source

Merge pull request #9691 from zeule/cmake

cmake: restore out-of-source build
adaptive-webui-19844
Eugene Shalygin 6 years ago committed by GitHub
parent
commit
5ccd4b3611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      cmake/Modules/QbtTranslations.cmake
  2. 2
      src/CMakeLists.txt
  3. 24
      src/app/CMakeLists.txt
  4. 2
      src/webui/webui.pri
  5. 54
      src/webui/www/translations/webui_translations.qrc
  6. 50
      src/webui/www/webui.qrc

48
cmake/Modules/QbtTranslations.cmake

@ -0,0 +1,48 @@
# macros to handle translation files
# qbt_add_translations(<target> QRC_FILE <filename> TS_FILES <filenames>)
# handles out of source builds for Qt resource files that include translations
# The function generates translations out of the supplied list of .ts files in the build directory,
# copies the .qrc file there, calls qt5_add_resources() adds its output to the target sources list.
function(qbt_add_translations _target)
set(oneValueArgs QRC_FILE)
set(multiValueArgs TS_FILES)
cmake_parse_arguments(QBT_TR "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_target_property(_binaryDir ${_target} BINARY_DIR)
if (NOT QBT_TR_QRC_FILE)
message(FATAL_ERROR "QRC file is empty")
endif()
if (NOT QBT_TR_TS_FILES)
message(FATAL_ERROR "TS_FILES files are empty")
endif()
if(IS_ABSOLUTE "${QBT_TR_QRC_FILE}")
file(RELATIVE_PATH _qrcToTs "${CMAKE_CURRENT_SOURCE_DIR}" "${QBT_TR_QRC_FILE}")
else()
set(_qrcToTs "${QBT_TR_QRC_FILE}")
endif()
get_filename_component(_qrcToTsDir "${_qrcToTs}" DIRECTORY)
get_filename_component(_qmFilesBinaryDir "${CMAKE_CURRENT_BINARY_DIR}/${_qrcToTsDir}" ABSOLUTE)
# to make qt5_add_translation() work as we need
set_source_files_properties(${QBT_TR_TS_FILES} PROPERTIES OUTPUT_LOCATION "${_qmFilesBinaryDir}")
qt5_add_translation(_qmFiles ${QBT_TR_TS_FILES})
set(_qrc_dest_dir "${_binaryDir}/${_qrcToTsDir}")
set(_qrc_dest_file "${_binaryDir}/${QBT_TR_QRC_FILE}")
message(STATUS "copying ${QBT_TR_QRC_FILE} to ${_qrc_dest_dir}")
file(COPY ${QBT_TR_QRC_FILE} DESTINATION ${_qrc_dest_dir})
set_source_files_properties("${_qrc_dest_file}" PROPERTIES
GENERATED True
OBJECT_DEPENDS "${_qmFiles}")
# With AUTORCC enabled rcc is ran by cmake before language files are generated,
# and thus we call rcc explicitly
qt5_add_resources(_resources "${_qrc_dest_file}")
target_sources(${_target} PRIVATE "${_resources}")
endfunction()

2
src/CMakeLists.txt

@ -13,7 +13,7 @@ if (Boost_VERSION VERSION_LESS 106000)
add_definitions(-DBOOST_NO_CXX11_RVALUE_REFERENCES) add_definitions(-DBOOST_NO_CXX11_RVALUE_REFERENCES)
endif() endif()
find_package(Qt5 ${requiredQtVersion} REQUIRED COMPONENTS Core Network Xml) find_package(Qt5 ${requiredQtVersion} REQUIRED COMPONENTS Core Network Xml LinguistTools)
find_package(Qt5Widgets ${requiredQtVersion}) find_package(Qt5Widgets ${requiredQtVersion})
if (Qt5Widgets_FOUND) if (Qt5Widgets_FOUND)
find_package(Qt5DBus ${requiredQtVersion}) find_package(Qt5DBus ${requiredQtVersion})

24
src/app/CMakeLists.txt

@ -23,29 +23,19 @@ set_target_properties(qBittorrent
) )
# translations # translations
file(GLOB QBT_TS_FILES ../lang/*.ts) include(QbtTranslations)
get_filename_component(QBT_QM_FILES_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/../lang" ABSOLUTE)
set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${QBT_QM_FILES_BINARY_DIR}")
find_package(Qt5 COMPONENTS LinguistTools REQUIRED)
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES})
get_filename_component(_lang_qrc_src "${CMAKE_CURRENT_SOURCE_DIR}/../lang/lang.qrc" ABSOLUTE)
get_filename_component(_lang_qrc_dst "${CMAKE_CURRENT_BINARY_DIR}/../lang/lang.qrc" ABSOLUTE)
get_filename_component(_lang_qrc_dst_dir "${CMAKE_CURRENT_BINARY_DIR}/../lang" ABSOLUTE)
message(STATUS "copying ${_lang_qrc_src} -> ${_lang_qrc_dst}") file(GLOB QBT_TS_FILES ../lang/*.ts)
file(COPY ${_lang_qrc_src} DESTINATION ${_lang_qrc_dst_dir}) qbt_add_translations(qBittorrent QRC_FILE "../lang/lang.qrc" TS_FILES ${QBT_TS_FILES})
set_source_files_properties("${_lang_qrc_dst}" PROPERTIES GENERATED True) if (WEBUI)
foreach(qm_file ${QBT_QM_FILES}) file(GLOB QBT_WEBUI_TS_FILES ../webui/www/translations/*.ts)
set_source_files_properties("${_lang_qrc_dst}" PROPERTIES OBJECT_DEPENDS ${qm_file}) qbt_add_translations(qBittorrent QRC_FILE "../webui/www/translations/webui_translations.qrc" TS_FILES ${QBT_WEBUI_TS_FILES})
endforeach() endif()
set(QBT_APP_RESOURCES set(QBT_APP_RESOURCES
../icons/icons.qrc ../icons/icons.qrc
../searchengine/searchengine.qrc ../searchengine/searchengine.qrc
"${_lang_qrc_dst}"
) )
# With AUTORCC rcc is ran by cmake before language files are generated, # With AUTORCC rcc is ran by cmake before language files are generated,

2
src/webui/webui.pri

@ -27,7 +27,7 @@ SOURCES += \
$$PWD/webapplication.cpp \ $$PWD/webapplication.cpp \
$$PWD/webui.cpp $$PWD/webui.cpp
RESOURCES += $$PWD/www/webui.qrc RESOURCES += $$PWD/www/webui.qrc $$PWD/www/translations/webui_translations.qrc
# WebUI Translation # WebUI Translation
isEmpty(QMAKE_LRELEASE) { isEmpty(QMAKE_LRELEASE) {

54
src/webui/www/translations/webui_translations.qrc

@ -0,0 +1,54 @@
<RCC>
<qresource prefix="/www/translations">
<file>webui_ar.qm</file>
<file>webui_be.qm</file>
<file>webui_bg.qm</file>
<file>webui_ca.qm</file>
<file>webui_cs.qm</file>
<file>webui_da.qm</file>
<file>webui_de.qm</file>
<file>webui_el.qm</file>
<file>webui_en.qm</file>
<file>webui_en_AU.qm</file>
<file>webui_en_GB.qm</file>
<file>webui_eo.qm</file>
<file>webui_es.qm</file>
<file>webui_eu.qm</file>
<file>webui_fi.qm</file>
<file>webui_fr.qm</file>
<file>webui_gl.qm</file>
<file>webui_he.qm</file>
<file>webui_hi_IN.qm</file>
<file>webui_hr.qm</file>
<file>webui_hu.qm</file>
<file>webui_hy.qm</file>
<file>webui_id.qm</file>
<file>webui_is.qm</file>
<file>webui_it.qm</file>
<file>webui_ja.qm</file>
<file>webui_ka.qm</file>
<file>webui_ko.qm</file>
<file>webui_lt.qm</file>
<file>webui_lv_LV.qm</file>
<file>webui_ms_MY.qm</file>
<file>webui_nb.qm</file>
<file>webui_nl.qm</file>
<file>webui_oc.qm</file>
<file>webui_pl.qm</file>
<file>webui_pt_BR.qm</file>
<file>webui_pt_PT.qm</file>
<file>webui_ro.qm</file>
<file>webui_ru.qm</file>
<file>webui_sk.qm</file>
<file>webui_sl.qm</file>
<file>webui_sr.qm</file>
<file>webui_sv.qm</file>
<file>webui_tr.qm</file>
<file>webui_uk.qm</file>
<file>webui_uz@Latn.qm</file>
<file>webui_vi.qm</file>
<file>webui_zh.qm</file>
<file>webui_zh_HK.qm</file>
<file>webui_zh_TW.qm</file>
</qresource>
</RCC>

50
src/webui/www/webui.qrc

@ -45,55 +45,5 @@
<file>public/css/login.css</file> <file>public/css/login.css</file>
<file>public/login.html</file> <file>public/login.html</file>
<file>public/scripts/lib/mootools-1.2-core-yc.js</file> <file>public/scripts/lib/mootools-1.2-core-yc.js</file>
<file>translations/webui_ar.qm</file>
<file>translations/webui_be.qm</file>
<file>translations/webui_bg.qm</file>
<file>translations/webui_ca.qm</file>
<file>translations/webui_cs.qm</file>
<file>translations/webui_da.qm</file>
<file>translations/webui_de.qm</file>
<file>translations/webui_el.qm</file>
<file>translations/webui_en.qm</file>
<file>translations/webui_en_AU.qm</file>
<file>translations/webui_en_GB.qm</file>
<file>translations/webui_eo.qm</file>
<file>translations/webui_es.qm</file>
<file>translations/webui_eu.qm</file>
<file>translations/webui_fi.qm</file>
<file>translations/webui_fr.qm</file>
<file>translations/webui_gl.qm</file>
<file>translations/webui_he.qm</file>
<file>translations/webui_hi_IN.qm</file>
<file>translations/webui_hr.qm</file>
<file>translations/webui_hu.qm</file>
<file>translations/webui_hy.qm</file>
<file>translations/webui_id.qm</file>
<file>translations/webui_is.qm</file>
<file>translations/webui_it.qm</file>
<file>translations/webui_ja.qm</file>
<file>translations/webui_ka.qm</file>
<file>translations/webui_ko.qm</file>
<file>translations/webui_lt.qm</file>
<file>translations/webui_lv_LV.qm</file>
<file>translations/webui_ms_MY.qm</file>
<file>translations/webui_nb.qm</file>
<file>translations/webui_nl.qm</file>
<file>translations/webui_oc.qm</file>
<file>translations/webui_pl.qm</file>
<file>translations/webui_pt_BR.qm</file>
<file>translations/webui_pt_PT.qm</file>
<file>translations/webui_ro.qm</file>
<file>translations/webui_ru.qm</file>
<file>translations/webui_sk.qm</file>
<file>translations/webui_sl.qm</file>
<file>translations/webui_sr.qm</file>
<file>translations/webui_sv.qm</file>
<file>translations/webui_tr.qm</file>
<file>translations/webui_uk.qm</file>
<file>translations/webui_uz@Latn.qm</file>
<file>translations/webui_vi.qm</file>
<file>translations/webui_zh.qm</file>
<file>translations/webui_zh_HK.qm</file>
<file>translations/webui_zh_TW.qm</file>
</qresource> </qresource>
</RCC> </RCC>

Loading…
Cancel
Save