Merge pull request #15 from xhochy/qt45-build-compability

Qt4<->5 build compability
This commit is contained in:
Frank Osterfeld 2013-08-05 01:49:07 -07:00
commit 3e420a5e81
1 changed files with 22 additions and 4 deletions

View File

@ -11,8 +11,13 @@ set(QTKEYCHAIN_SOVERSION 0)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake/Modules") set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake/Modules")
include(GNUInstallDirs) include(GNUInstallDirs)
# try Qt5 first, and prefer that if found option(BUILD_WITH_QT4 "Build qtkeychain with Qt4 no matter if Qt5 was found" OFF)
find_package(Qt5Core QUIET)
if( NOT BUILD_WITH_QT4 )
# try Qt5 first, and prefer that if found
find_package(Qt5Core QUIET)
endif()
if (Qt5Core_FOUND) if (Qt5Core_FOUND)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
find_package(Qt5DBus REQUIRED) find_package(Qt5DBus REQUIRED)
@ -22,6 +27,13 @@ if (Qt5Core_FOUND)
qt5_add_dbus_interface(${ARGN}) qt5_add_dbus_interface(${ARGN})
endmacro() endmacro()
endif() 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) macro(qt_wrap_cpp)
qt5_wrap_cpp(${ARGN}) qt5_wrap_cpp(${ARGN})
endmacro() endmacro()
@ -48,6 +60,12 @@ else()
endif() endif()
include_directories(${QT_INCLUDES}) include_directories(${QT_INCLUDES})
set(QTCORE_LIBRARIES ${QT_QTCORE_LIBRARY}) 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) macro(qt_wrap_cpp)
qt4_wrap_cpp(${ARGN}) qt4_wrap_cpp(${ARGN})
endmacro() endmacro()
@ -93,8 +111,8 @@ set(qtkeychain_TR_FILES
) )
file(GLOB qtkeychain_TR_SOURCES *.cpp *.h *.ui) file(GLOB qtkeychain_TR_SOURCES *.cpp *.h *.ui)
qt4_create_translation(qtkeychain_MESSAGES ${qtkeychain_TR_SOURCES} ${qtkeychain_TR_FILES}) qt_create_translation(qtkeychain_MESSAGES ${qtkeychain_TR_SOURCES} ${qtkeychain_TR_FILES})
qt4_add_translation(qtkeychain_QM_FILES ${qtkeychain_TR_FILES}) qt_add_translation(qtkeychain_QM_FILES ${qtkeychain_TR_FILES})
add_custom_target(messages DEPENDS ${qtkeychain_MESSAGES}) add_custom_target(messages DEPENDS ${qtkeychain_MESSAGES})
add_custom_target(translations DEPENDS ${qtkeychain_QM_FILES}) add_custom_target(translations DEPENDS ${qtkeychain_QM_FILES})