From 6be1967c8169320e70f8ccc14bc56884ec17ce96 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sat, 3 Aug 2013 16:32:31 +0200 Subject: [PATCH 1/2] Support building of translations with Qt5 --- CMakeLists.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e14c0f0..701c9ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,13 @@ if (Qt5Core_FOUND) qt5_add_dbus_interface(${ARGN}) endmacro() endif() + find_package(Qt5LinguistTools REQUIRED) + macro(qt_add_translation) + qt5_add_translation(${ARGN}) + endmacro(qt_add_translation) + macro(qt_create_translation) + qt5_create_translation(${ARGN}) + endmacro(qt_create_translation) macro(qt_wrap_cpp) qt5_wrap_cpp(${ARGN}) endmacro() @@ -48,6 +55,12 @@ else() endif() include_directories(${QT_INCLUDES}) set(QTCORE_LIBRARIES ${QT_QTCORE_LIBRARY}) + macro(qt_add_translation) + qt4_add_translation(${ARGN}) + endmacro(qt_add_translation) + macro(qt_create_translation) + qt4_create_translation(${ARGN}) + endmacro(qt_create_translation) macro(qt_wrap_cpp) qt4_wrap_cpp(${ARGN}) endmacro() @@ -93,8 +106,8 @@ set(qtkeychain_TR_FILES ) file(GLOB qtkeychain_TR_SOURCES *.cpp *.h *.ui) -qt4_create_translation(qtkeychain_MESSAGES ${qtkeychain_TR_SOURCES} ${qtkeychain_TR_FILES}) -qt4_add_translation(qtkeychain_QM_FILES ${qtkeychain_TR_FILES}) +qt_create_translation(qtkeychain_MESSAGES ${qtkeychain_TR_SOURCES} ${qtkeychain_TR_FILES}) +qt_add_translation(qtkeychain_QM_FILES ${qtkeychain_TR_FILES}) add_custom_target(messages DEPENDS ${qtkeychain_MESSAGES}) add_custom_target(translations DEPENDS ${qtkeychain_QM_FILES}) From 8722799afe5f706af2c10c31e96da1d8a6679035 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sat, 3 Aug 2013 16:32:52 +0200 Subject: [PATCH 2/2] Add the ability to build with Qt4 even if Qt5 was found --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 701c9ae..6753722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,13 @@ set(QTKEYCHAIN_SOVERSION 0) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake/Modules") include(GNUInstallDirs) -# try Qt5 first, and prefer that if found -find_package(Qt5Core QUIET) +option(BUILD_WITH_QT4 "Build qtkeychain with Qt4 no matter if Qt5 was found" OFF) + +if( NOT BUILD_WITH_QT4 ) + # try Qt5 first, and prefer that if found + find_package(Qt5Core QUIET) +endif() + if (Qt5Core_FOUND) if(UNIX AND NOT APPLE) find_package(Qt5DBus REQUIRED)