Warning, /frameworks/ki18n/cmake/build-pofiles.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2017 Aleix Pol Gonzalez <aleixpol@kde.org>
0002 # SPDX-FileCopyrightText: 2017 Harald Sitter <sitter@kde.org>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005 
0006 file(GLOB_RECURSE pofiles RELATIVE "${PO_DIR}" "${PO_DIR}/**.po")
0007 
0008 include(ProcessorCount)
0009 ProcessorCount(numberOfProcesses)
0010 
0011 set(i 0)
0012 set(commands)
0013 
0014 function(_processCommands)
0015     if(NOT commands)
0016         return()
0017     endif()
0018 
0019     execute_process(
0020         ${commands}
0021         RESULT_VARIABLE code
0022     )
0023     if(code)
0024         message(FATAL_ERROR "failed generating ${PO_DIR}")
0025     endif()
0026 endfunction()
0027 
0028 foreach(pofile IN LISTS pofiles)
0029     get_filename_component(name ${pofile} NAME)
0030     # Regex the basename, cmake only allows stripping the longest extension, we
0031     # need the shortest or we'll screw up "org.kde.plasma.kittens.po"
0032     # https://bugs.kde.org/show_bug.cgi?id=379116
0033     string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" name ${name})
0034     get_filename_component(langdir ${pofile} DIRECTORY)
0035     set(dest ${COPY_TO}/${langdir}/LC_MESSAGES)
0036     file(MAKE_DIRECTORY ${dest})
0037 
0038     list(APPEND commands COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${dest}/${name}.mo ${PO_DIR}/${pofile})
0039     math(EXPR i "${i}+1")
0040     if(i EQUAL ${numberOfProcesses})
0041         _processCommands()
0042         set(i 0)
0043         set(commands)
0044     endif()
0045 endforeach()
0046 
0047 _processCommands()