CMake: simplify QRC generation
Use configure_file() to avoid stomping on timestamps: if the list of translations doesn't change, we don't need to rebuild the translated QRC.
This commit is contained in:
parent
bfa1f618c7
commit
afb0b36f58
@ -28,12 +28,9 @@ include( CMakeParseArguments )
|
||||
macro(add_calamares_translations language)
|
||||
list( APPEND CALAMARES_LANGUAGES ${ARGV} )
|
||||
|
||||
set( _rcc_version_support --format-version 1 )
|
||||
|
||||
set( calamares_i18n_qrc_content "<!DOCTYPE RCC><RCC version=\"1.0\">\n" )
|
||||
set( calamares_i18n_qrc_content "" )
|
||||
|
||||
# calamares and qt language files
|
||||
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<qresource prefix=\"/lang\">\n" )
|
||||
foreach( lang ${CALAMARES_LANGUAGES} )
|
||||
foreach( tlsource "calamares_${lang}" "tz_${lang}" )
|
||||
if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
|
||||
@ -43,31 +40,19 @@ macro(add_calamares_translations language)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}</qresource>\n" )
|
||||
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}</RCC>\n" )
|
||||
|
||||
file( WRITE ${CMAKE_BINARY_DIR}/lang/calamares_i18n.qrc "${calamares_i18n_qrc_content}" )
|
||||
|
||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||
|
||||
## HACK HACK HACK - around rcc limitations to allow out of source-tree building
|
||||
set( trans_file calamares_i18n )
|
||||
set( trans_srcfile ${CMAKE_BINARY_DIR}/lang/${trans_file}.qrc )
|
||||
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
|
||||
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
|
||||
|
||||
# Copy the QRC file to the output directory
|
||||
add_custom_command(
|
||||
OUTPUT ${trans_infile}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${trans_srcfile} ${trans_infile}
|
||||
MAIN_DEPENDENCY ${trans_srcfile}
|
||||
)
|
||||
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
|
||||
|
||||
qt5_add_translation(QM_FILES ${TS_FILES})
|
||||
|
||||
# Run the resource compiler (rcc_options should already be set)
|
||||
add_custom_command(
|
||||
OUTPUT ${trans_outfile}
|
||||
COMMAND "${Qt5Core_RCC_EXECUTABLE}"
|
||||
ARGS ${rcc_options} ${_rcc_version_support} -name ${trans_file} -o ${trans_outfile} ${trans_infile}
|
||||
ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile}
|
||||
MAIN_DEPENDENCY ${trans_infile}
|
||||
DEPENDS ${QM_FILES}
|
||||
)
|
||||
|
5
lang/calamares_i18n.qrc.in
Normal file
5
lang/calamares_i18n.qrc.in
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/lang">
|
||||
@calamares_i18n_qrc_content@
|
||||
</qresource>
|
||||
</RCC>
|
Loading…
Reference in New Issue
Block a user