summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-06-05 11:12:37 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-06-05 11:58:43 +0300
commit5bad049fd2192b6b00abde485f6e8171d68ca933 (patch)
treed149d8cee00e8f68e252d88fe87afc27b08539c9 /cmake
parent6624f10817da99a63253799f1f99162304cbd894 (diff)
qt5: Add conditional support for Qt5 in the build system
Based on patches by: Andoni Morales Alastruey <ylatuya@gmail.com> Luciana Fujii Pontello <luciana@fujii.eti.br>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/QtHelpers.cmake79
1 files changed, 79 insertions, 0 deletions
diff --git a/cmake/modules/QtHelpers.cmake b/cmake/modules/QtHelpers.cmake
new file mode 100644
index 0000000..66ac2b0
--- /dev/null
+++ b/cmake/modules/QtHelpers.cmake
@@ -0,0 +1,79 @@
+# - Try to find an installed version of Qt based on QT_VERSION
+# Once done this will define
+#
+# USE_QT4 - Building with Qt4
+# USE_QT5 - Building with Qt5
+# QT_MIN_VERSION - qt minimum
+#
+# Copyright (c) 2013, Fluendo S.L. <support@fluendo.com>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+if (${QT_VERSION} STREQUAL "5")
+ set(USE_QT5 TRUE)
+ set(QT_MIN_VERSION 5.0.1)
+ message(STATUS "Using Qt5 (min: ${QT_MIN_VERSION})")
+elseif (${QT_VERSION} STREQUAL "4")
+ set(USE_QT4 TRUE)
+ set(QT_MIN_VERSION 4.7)
+ message(STATUS "Using Qt4 (min:${QT_MIN_VERSION})")
+endif()
+
+if (USE_QT5)
+ find_package(Qt5Core)
+ find_package(Qt5Gui)
+ find_package(Qt5Widgets)
+ if (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND)
+ set(QT_FOUND true)
+ set(QT_QTCORE_FOUND true)
+ set(QT_QTGUI_FOUND true)
+ set(QT_QTCORE_LIBRARY ${Qt5Core_LIBRARIES})
+ set(QT_QTGUI_LIBRARY ${Qt5Widgets_LIBRARIES})
+ set(QT_INCLUDE_DIR ${Qt5Widgets_INCLUDE_DIRS})
+ endif()
+ find_package(Qt5Declarative)
+ if (Qt5Declarative_FOUND)
+ set(QT_QTDECLARATIVE_FOUND true)
+ set(QT_QTDECLARATIVE_LIBRARY ${Qt5Declarative_LIBRARIES})
+ set(QT_QTDECLARATIVE_INCLUDE_DIR ${Qt5Declarative_INCLUDE_DIRS})
+ endif()
+ find_package(Qt5Test)
+ if (Qt5Test_FOUND)
+ set(QT_QTTEST_FOUND true)
+ set(QT_QTTEST_LIBRARY ${Qt5Test_LIBRARIES})
+ set(QT_QTTEST_INCLUDE_DIR ${Qt5Test_INCLUDE_DIRS})
+ endif ()
+ find_package(Qt5OpenGL)
+ if (Qt5OpenGL_FOUND)
+ set(QT_QTOPENGL_FOUND true)
+ set(QT_QTOPENGL_LIBRARY ${Qt5OpenGL_LIBRARIES})
+ set(QT_QTOPENGL_INCLUDE_DIR ${Qt5OpenGL_INCLUDE_DIRS})
+ endif()
+ set(PKG_CONFIG_QTCORE_DEP Qt5Core)
+ set(PKG_CONFIG_QTGUI_DEP Qt5Widgets)
+elseif (USE_QT4)
+ find_package(Qt4 COMPONENTS QtCore QtGui)
+ set(PKG_CONFIG_QTCORE_DEP QtCore)
+ set(PKG_CONFIG_QTGUI_DEP QtGui)
+else()
+ message(FATAL_ERROR "Qt supported versions are: 4 and 5")
+endif()
+
+# qt_helper_wrap_ui(outfiles inputfile ... )
+macro(QT_HELPER_WRAP_UI)
+ if (USE_QT5)
+ qt5_wrap_ui(${ARGV})
+ elseif (USE_QT4)
+ qt4_wrap_ui(${ARGV})
+ endif()
+endmacro()
+
+# qt_helper_add_resources(outfiles inputfile ... )
+macro(QT_HELPER_ADD_RESOURCES)
+ if (USE_QT5)
+ qt5_add_resources(${ARGV})
+ elseif (USE_QT4)
+ qt4_add_resources(${ARGV})
+ endif()
+endmacro()