diff --git a/KF5I18nConfig.cmake.in b/KF5I18nConfig.cmake.in --- a/KF5I18nConfig.cmake.in +++ b/KF5I18nConfig.cmake.in @@ -7,3 +7,44 @@ include("${CMAKE_CURRENT_LIST_DIR}/KF5I18nTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/KF5I18NMacros.cmake") +option(KI18N_DOWNLOAD_TRANSLATIONS "Automatically execute 'make fetch-translations`" OFF) +set(KI18N_BRANCH "stable" CACHE STRING "Branch from l10n.kde.org to fetch from: trunk | stable | lts | trunk_kde4 | stable_kde4") + +if(KI18N_DOWNLOAD_TRANSLATIONS) + set(_EXTRA_ARGS "ALL") +else() + set(_EXTRA_ARGS) +endif() + +execute_process(COMMAND git config --get remote.origin.url + OUTPUT_VARIABLE reponame + RESULT_VARIABLE exitCode + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" +) + +if(exitCode EQUAL 0) + string(STRIP ${reponame} reponame) + string(FIND ${reponame} : idx) + math(EXPR idx "${idx}+1") + string(SUBSTRING ${reponame} ${idx} -1 reponame) +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..." +) + +add_custom_target(fetch-translations + 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 ${KI18N_BRANCH} --project "${reponame}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/po" + COMMENT "Downloading translations..." + OUTPUT "${CMAKE_BINARY_DIR}/po" + DEPENDS "${CMAKE_BINARY_DIR}/releaseme" +) +ki18n_install(${CMAKE_BINARY_DIR}/po)