From c5533ae6836e7a39b282678489ca1e031795ae21 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Mon, 18 Nov 2013 10:47:58 +0000 Subject: [PATCH 1/2] Query qmake5 for QT_TRANSLATION_DIR --- CMakeLists.txt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a18ad83..23c70f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,8 +120,22 @@ qt_add_translation(qtkeychain_QM_FILES ${qtkeychain_TR_FILES}) add_custom_target(messages DEPENDS ${qtkeychain_MESSAGES}) add_custom_target(translations DEPENDS ${qtkeychain_QM_FILES}) -#install(FILES ${qtkeychain_QM_FILES} -# DESTINATION ${QT_TRANSLATIONS_DIR}) +if(NOT QT_TRANSLATIONS_DIR) + # If this directory is missing, we are in a Qt5 environment. + # Extract the qmake executable location + get_target_property(QT5_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION) + # Ask Qt5 where to put the translations + EXEC_PROGRAM( ${QT5_QMAKE_EXECUTABLE} + ARGS "-query QT_INSTALL_TRANSLATIONS" + OUTPUT_VARIABLE qt_translations_dir ) + # make sure we have / and not \ as qmake gives on windows + FILE(TO_CMAKE_PATH "${qt_translations_dir}" qt_translations_dir) + SET(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The + location of the Qt translations" FORCE) +endif() + +install(FILES ${qtkeychain_QM_FILES} + DESTINATION ${QT_TRANSLATIONS_DIR}) if(NOT QTKEYCHAIN_STATIC) add_library(${QTKEYCHAIN_TARGET_NAME} SHARED ${qtkeychain_SOURCES} ${qtkeychain_MOC_OUTFILES} ${qtkeychain_QM_FILES}) From 59084e35443a0f20367370087aa2b0aea621e67f Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Mon, 18 Nov 2013 11:20:08 +0000 Subject: [PATCH 2/2] Pass -query and the identifier as separate args --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23c70f7..046369b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,7 @@ if(NOT QT_TRANSLATIONS_DIR) get_target_property(QT5_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION) # Ask Qt5 where to put the translations EXEC_PROGRAM( ${QT5_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_TRANSLATIONS" + ARGS -query QT_INSTALL_TRANSLATIONS OUTPUT_VARIABLE qt_translations_dir ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${qt_translations_dir}" qt_translations_dir)