diff options
| -rw-r--r-- | kde-modules/KDECMakeSettings.cmake | 34 | ||||
| -rw-r--r-- | modules/ECMPoQmTools.cmake | 14 | 
2 files changed, 41 insertions, 7 deletions
| diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index 8029ed90..2d20c60d 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -91,6 +91,13 @@  # should be downloaded when building the project.  #  # Since 5.34.0 +# +# ``KDE_L10N_SYNC_TRANSLATIONS`` (OFF by default) will download the translations at configuration +# time instead of build time. +# +# Since 5.50.0 +# +#  #=============================================================================  # Copyright 2014      Alex Merry <alex.merry@kde.org> @@ -312,9 +319,10 @@ endfunction()  if(NOT EXISTS ${CMAKE_SOURCE_DIR}/po AND NOT TARGET fetch-translations)      option(KDE_L10N_AUTO_TRANSLATIONS "Automatically 'make fetch-translations`" OFF) +    option(KDE_L10N_SYNC_TRANSLATIONS "Fetch translations when KDECMakeSettings.cmake is processed." OFF)      set(KDE_L10N_BRANCH "trunk" CACHE STRING "Branch from l10n.kde.org to fetch from: trunk | stable | lts | trunk_kde4 | stable_kde4") -    if(KDE_L10N_AUTO_TRANSLATIONS) +    if(KDE_L10N_AUTO_TRANSLATIONS AND NOT KDE_L10N_SYNC_TRANSLATIONS)          set(_EXTRA_ARGS "ALL")      else()          set(_EXTRA_ARGS) @@ -323,9 +331,12 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/po AND NOT TARGET fetch-translations)      set(_reponame "")      _repository_name(_reponame "${CMAKE_SOURCE_DIR}") +    set(releaseme_clone_commands +        COMMAND git clone --depth 1 https://anongit.kde.org/releaseme.git +    )      add_custom_command(          OUTPUT "${CMAKE_BINARY_DIR}/releaseme" -        COMMAND git clone --depth 1 "https://anongit.kde.org/releaseme.git" +        ${releaseme_clone_commands}          COMMENT "Fetching releaseme scripts to download translations..."      ) @@ -336,18 +347,27 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/po AND NOT TARGET fetch-translations)          set(extra BYPRODUCTS ${_l10n_po_dir} ${_l10n_poqm_dir})      endif() -    add_custom_target(fetch-translations ${_EXTRA_ARGS} -        COMMENT "Downloading translations for ${_reponame} branch ${KDE_L10N_BRANCH}..." -        COMMAND git -C "${CMAKE_BINARY_DIR}/releaseme" pull -        COMMAND cmake -E remove_directory ${_l10n_po_dir} -        COMMAND cmake -E remove_directory ${_l10n_poqm_dir} +    set(fetch_commands          COMMAND ruby "${CMAKE_BINARY_DIR}/releaseme/fetchpo.rb"              --origin ${KDE_L10N_BRANCH}              --project "${_reponame}"              --output-dir "${_l10n_po_dir}"              --output-poqm-dir "${_l10n_poqm_dir}"              "${CMAKE_CURRENT_SOURCE_DIR}" +    ) + +    add_custom_target(fetch-translations ${_EXTRA_ARGS} +        COMMENT "Downloading translations for ${_reponame} branch ${KDE_L10N_BRANCH}..." +        COMMAND git -C "${CMAKE_BINARY_DIR}/releaseme" pull +        COMMAND cmake -E remove_directory ${_l10n_po_dir} +        COMMAND cmake -E remove_directory ${_l10n_poqm_dir} +        ${fetch_commands}          ${extra}          DEPENDS "${CMAKE_BINARY_DIR}/releaseme"      ) + +    if (KDE_L10N_SYNC_TRANSLATIONS AND (NOT EXISTS ${_l10n_po_dir} OR NOT EXISTS ${_l10n_poqm_dir})) +        execute_process(${releaseme_clone_commands}) +        execute_process(${fetch_commands}) +    endif()  endif() diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake index 49557b8e..9a281221 100644 --- a/modules/ECMPoQmTools.cmake +++ b/modules/ECMPoQmTools.cmake @@ -213,6 +213,20 @@ function(ecm_install_po_files_as_qm podir)          set(install_destination share/locale)      endif() +    get_filename_component(absolute_podir ${podir} ABSOLUTE) + +    # we try to find the po directory in the binary directory, in case it was downloaded +    # using ECM +    if (NOT (EXISTS "${absolute_podir}" AND IS_DIRECTORY "${absolute_podir}")) +        get_filename_component(absolute_podir ${CMAKE_BINARY_DIR}/${podir} ABSOLUTE) +    endif() + +    if (NOT (EXISTS "${absolute_podir}" AND IS_DIRECTORY "${absolute_podir}")) +        # Nothing to do if there's no podir and it would create an empty +        # LOCALE_INSTALL_DIR in that case. +        return() +    endif() +      file(GLOB po_files "${podir}/*/*.po")      foreach(po_file ${po_files})          get_filename_component(po_dir ${po_file} DIRECTORY) | 
