aboutsummaryrefslogtreecommitdiff
path: root/kde-modules/KDECMakeSettings.cmake
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2017-03-23 00:24:51 +0100
committerAleix Pol <aleixpol@kde.org>2017-04-06 19:22:08 +0200
commite62222982aba53475aed6ad8119c270bc1d92ce1 (patch)
tree27ff5122503843be27dcd1e4fb709de589f4ac0f /kde-modules/KDECMakeSettings.cmake
parentc20a9f69e8e2703cf42f320f26db122f3a6733df (diff)
downloadextra-cmake-modules-e62222982aba53475aed6ad8119c270bc1d92ce1.tar.gz
extra-cmake-modules-e62222982aba53475aed6ad8119c270bc1d92ce1.tar.bz2
Introduce fetch-translations build command
Summary: Makes it possible to fetch translations when building the project. To do so it fetches kde:releaseme and uses the new fetchpo.rb program to download the translations into the build directory. This should make it much easier to integrate translations in the development process. Test Plan: Downloaded and installed translations for some projects Reviewers: #frameworks, #build_system, kfunk, ltoscano, aacid, ilic, sitter Reviewed By: sitter Subscribers: sitter Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D5143
Diffstat (limited to 'kde-modules/KDECMakeSettings.cmake')
-rw-r--r--kde-modules/KDECMakeSettings.cmake59
1 files changed, 59 insertions, 0 deletions
diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake
index 620042a4..02502e8d 100644
--- a/kde-modules/KDECMakeSettings.cmake
+++ b/kde-modules/KDECMakeSettings.cmake
@@ -71,6 +71,19 @@
# - Uninstall target functionality since 1.7.0.
# - ``APPLE_FORCE_X11`` option since 5.14.0 (detecting X11 was previously the default behavior)
# - ``APPLE_SUPPRESS_X11_WARNING`` option since 5.14.0
+#
+# Translations
+# ~~~~~~~~~~~~
+# A fetch-translations target will be set up that will download translations
+# for projects using l10n.kde.org.
+#
+# ``KDE_L10N_BRANCH`` will be responsible for choosing which l10n branch to use
+# for the translations.
+#
+# ``KDE_L10N_AUTO_TRANSLATIONS`` (OFF by default) will indicate whether translations
+# should be downloaded when building the project.
+#
+# Since 5.34.0
#=============================================================================
# Copyright 2014 Alex Merry <alex.merry@kde.org>
@@ -269,3 +282,49 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()
###################################################################
+# Download translations
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/po)
+ option(KDE_L10N_AUTO_TRANSLATIONS "Automatically 'make fetch-translations`" 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_DOWNLOAD_TRANSLATIONS)
+ set(_EXTRA_ARGS "ALL")
+ else()
+ set(_EXTRA_ARGS)
+ endif()
+
+ execute_process(COMMAND git config --get remote.origin.url
+ OUTPUT_VARIABLE giturl
+ RESULT_VARIABLE exitCode
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ )
+
+ if(exitCode EQUAL 0)
+ string(REGEX MATCHALL ".+[:\\/]([\\w\\-\\d])(.git)?\\s*" "" ${giturl})
+ set(reponame ${CMAKE_MATCH_1})
+ endif()
+
+ if(NOT reponame)
+ set(reponame ${CMAKE_PROJECT_NAME})
+ endif()
+
+ add_custom_command(
+ OUTPUT "${CMAKE_BINARY_DIR}/releaseme"
+ COMMAND git clone --depth 1 "https://anongit.kde.org/releaseme.git"
+ COMMENT "Fetching releaseme scripts to download translations..."
+ )
+
+ if(CMAKE_VERSION VERSION_GREATER 3.2)
+ set(extra BYPRODUCTS "${CMAKE_BINARY_DIR}/po")
+ 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 ${CMAKE_BINARY_DIR}/po
+ COMMAND ruby "${CMAKE_BINARY_DIR}/releaseme/fetchpo.rb" --origin ${KDE_L10N_BRANCH} --project "${reponame}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/po"
+ ${extra}
+ DEPENDS "${CMAKE_BINARY_DIR}/releaseme"
+ )
+endif()