diff --git a/cmake/KF5I18nMacros.cmake.in b/cmake/KF5I18nMacros.cmake.in --- a/cmake/KF5I18nMacros.cmake.in +++ b/cmake/KF5I18nMacros.cmake.in @@ -89,15 +89,23 @@ # # KI18N_INSTALL(po) does the following: # - Compiles kfoo.po into kfoo.mo and installs it in -# ${LOCALE_INSTALL_DIR}/fr/LC_MESSAGES or share/locale/fr/LC_MESSAGES if -# ${LOCALE_INSTALL_DIR} is not set. -# - Installs kfoo.js in ${LOCALE_INSTALL_DIR}/fr/LC_SCRIPTS/kfoo +# /fr/LC_MESSAGES +# - Installs kfoo.js in /fr/LC_SCRIPTS/kfoo +# where is taken from the CMake variable ``LOCALE_INSTALL_DIR`` +# or, if not set, ``KDE_INSTALL_LOCALEDIR``, or, if also not set, will default +# to "share/locale". +# # # KI18N_INSTALL_TS_FILES() is deprecated, use KI18N_INSTALL() # function(KI18N_INSTALL podir) - if (NOT LOCALE_INSTALL_DIR) - set(LOCALE_INSTALL_DIR share/locale) + # LOCALE_INSTALL_DIR will not be set by KDEInstallDirs if KDE_INSTALL_DIRS_NO_DEPRECATED is set + if (LOCALE_INSTALL_DIR) + set(locale_installdir "${LOCALE_INSTALL_DIR}") + elseif(KDE_INSTALL_LOCALEDIR) + set(locale_installdir "${KDE_INSTALL_LOCALEDIR}") + else() + set(locale_installdir "share/locale") endif() # First try to find the po directory in the source directory, where the release scripts copy them before making the tarballs @@ -111,12 +119,12 @@ 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. + # locale_installdir in that case. return() endif() - get_filename_component(dirname ${LOCALE_INSTALL_DIR} NAME) - get_filename_component(destname ${LOCALE_INSTALL_DIR} DIRECTORY) + get_filename_component(dirname ${locale_installdir} NAME) + get_filename_component(destname ${locale_installdir} DIRECTORY) string(MD5 pathmd5 ${absolute_podir}) add_custom_target(pofiles-${pathmd5} ALL @@ -153,6 +161,15 @@ #install the scripts for a given language in the target folder #usage: KI18N_INSTALL_TS_FILES("ja" ${scripts_dir}) function(KI18N_INSTALL_TS_FILES lang scripts_dir) + # backward-compatible fallback to common vars as set when using KDEInstallDirs + if (LOCALE_INSTALL_DIR) + set(locale_installdir "${LOCALE_INSTALL_DIR}") + elseif(KDE_INSTALL_LOCALEDIR) + set(locale_installdir "${KDE_INSTALL_LOCALEDIR}") + else() + set(locale_installdir "share/locale") + endif() + file(GLOB_RECURSE ts_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${scripts_dir}/*) set(pmapc_files) foreach(ts_file ${ts_files}) @@ -163,7 +180,7 @@ get_filename_component(subpath ${ts_file} DIRECTORY) get_filename_component(subpath ${subpath} NAME) install(FILES ${ts_file} - DESTINATION ${LOCALE_INSTALL_DIR}/${lang}/LC_SCRIPTS/${subpath}) + DESTINATION ${locale_installdir}/${lang}/LC_SCRIPTS/${subpath}) # If current file is a pmap, also install the compiled version. get_filename_component(ts_ext ${ts_file} EXT) if(ts_ext STREQUAL ".pmap") @@ -180,7 +197,7 @@ ${pmapc_file} DEPENDS ${pmap_file}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pmapc_file} - DESTINATION ${LOCALE_INSTALL_DIR}/${lang}/LC_SCRIPTS/${subpath} + DESTINATION ${locale_installdir}/${lang}/LC_SCRIPTS/${subpath} RENAME ${pmapc_basename}) list(APPEND pmapc_files ${pmapc_file}) endif()