diff --git a/cmake/build-pofiles.cmake b/cmake/build-pofiles.cmake --- a/cmake/build-pofiles.cmake +++ b/cmake/build-pofiles.cmake @@ -27,6 +27,26 @@ file(GLOB_RECURSE pofiles RELATIVE "${PO_DIR}" "${PO_DIR}/**.po") +include(ProcessorCount) +ProcessorCount(numberOfProcesses) + +set(i 0) +set(commands) + +function(_processCommands) + if(NOT commands) + return() + endif() + + execute_process( + ${commands} + RESULT_VARIABLE code + ) + if(code) + message(FATAL_ERROR "failed generating ${PO_DIR}") + endif() +endfunction() + foreach(pofile IN LISTS pofiles) get_filename_component(name ${pofile} NAME) # Regex the basename, cmake only allows stripping the longest extension, we @@ -37,12 +57,12 @@ set(dest ${COPY_TO}/${langdir}/LC_MESSAGES) file(MAKE_DIRECTORY ${dest}) - message(STATUS "building... ${pofile} to ${name}.mo" ) - execute_process( - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${dest}/${name}.mo ${PO_DIR}/${pofile} - RESULT_VARIABLE code - ) - if(code) - message(FATAL_ERROR "failed at generating ${name}.mo") + list(APPEND commands COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${dest}/${name}.mo ${PO_DIR}/${pofile}) + math(EXPR i "${i}+1") + if(i EQUAL ${numberOfProcesses}) + _processCommands() + set(i 0) endif() endforeach() + +_processCommands() diff --git a/cmake/build-tsfiles.cmake b/cmake/build-tsfiles.cmake --- a/cmake/build-tsfiles.cmake +++ b/cmake/build-tsfiles.cmake @@ -37,23 +37,47 @@ file(COPY ${PO_DIR}/${ts_file} DESTINATION ${COPY_TO}/${subpath}) endforeach() + +include(ProcessorCount) +ProcessorCount(numberOfProcesses) + +set(i 0) +set(commands) + +function(_processCommands) + if(NOT commands) + return() + endif() + + execute_process( + ${commands} + RESULT_VARIABLE code + ) + if(code) + message(FATAL_ERROR "failed generating: ${PO_DIR}") + endif() +endfunction() + file(GLOB_RECURSE pmap_files RELATIVE ${PO_DIR} "${PO_DIR}/**.pmap") foreach(pmap_file ${pmap_files}) get_filename_component(pmap_basename ${pmap_file} NAME) get_filename_component(subpath ${pmap_file} DIRECTORY) string(REPLACE "scripts" "LC_SCRIPTS" subpath ${subpath}) set(pmapc_file "${COPY_TO}/${subpath}/${pmap_basename}c") message(STATUS "building... ${pmap_file} to ${pmapc_file}" ) - execute_process( + list(APPEND commands COMMAND ${PYTHON_EXECUTABLE} -B ${_ki18n_pmap_compile_script} ${PO_DIR}/${pmap_file} ${pmapc_file} - RESULT_VARIABLE code ) - if(code) - message(FATAL_ERROR "failed at creating ${pmap_file}...") + math(EXPR i "${i}+1") + if (i EQUAL ${numberOfProcesses}) + _processCommands() + set(i 0) endif() endforeach() + +_processCommands()