aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2018-08-03 00:44:59 +0200
committerAleix Pol <aleixpol@kde.org>2018-08-06 16:22:28 +0200
commit02881711cfce2281d35984469fb361120824bfb3 (patch)
treedba6edc82e847612af51bf86036e95cd55f1f6fc
parente5077dd490dbca798e06607fa0ddaec633a7e6c3 (diff)
downloadextra-cmake-modules-02881711cfce2281d35984469fb361120824bfb3.tar.gz
extra-cmake-modules-02881711cfce2281d35984469fb361120824bfb3.tar.bz2
Make it possible for ECM to detect po files at configure time
Summary: ECMPoQmTools will need to have the translations downloaded at configure time instead of on build time, otherwise it needs an awkward second configure. To that end we introduce a KDE_L10N_SYNC_TRANSLATIONS variable that allows it to do so. ECMPoTools will download the translations in the build directory, because cmake shouldn't touch the sources. Have it check the build directory too when the macro is called. Test Plan: Built analitza translations. Reviewers: #frameworks, cgiboudeaux Reviewed By: cgiboudeaux Subscribers: cgiboudeaux, kde-frameworks-devel, kde-buildsystem Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D14569
-rw-r--r--kde-modules/KDECMakeSettings.cmake34
-rw-r--r--modules/ECMPoQmTools.cmake14
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)