summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Korn <uwelk@xhochy.com>2014-03-14 15:55:26 (GMT)
committerDavid Edmundson <kde@davidedmundson.co.uk>2014-03-14 15:55:26 (GMT)
commitdca59397c00d27f3de0da4269fe53d4dda5520cb (patch)
treed1602d00abb721ecafce111f620f96567a100816
parent938509e23a3a02609d96dd82abdcb5a51d104b57 (diff)
downloadtelepathy-qt4-dca59397c00d27f3de0da4269fe53d4dda5520cb.tar.gz
telepathy-qt4-dca59397c00d27f3de0da4269fe53d4dda5520cb.tar.xz
Simplify FindQt5.cmake
Make further use of Qt 5's cmake integration Reviewed-by: David Edmundson
-rw-r--r--cmake/modules/FindQt5.cmake53
1 files changed, 31 insertions, 22 deletions
diff --git a/cmake/modules/FindQt5.cmake b/cmake/modules/FindQt5.cmake
index 922ebc1..957f7b3 100644
--- a/cmake/modules/FindQt5.cmake
+++ b/cmake/modules/FindQt5.cmake
@@ -44,25 +44,31 @@ IF(QT_INCLUDES AND QT_LIBRARIES AND QT_MAJOR_VERSION MATCHES 5)
RETURN()
ENDIF(QT_INCLUDES AND QT_LIBRARIES AND QT_MAJOR_VERSION MATCHES 5)
-IF(NOT QT_QMAKE_EXECUTABLE)
- FIND_PROGRAM(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake qmake5 qmake-qt5
- PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin")
- SET(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt qmake program.")
-ENDIF(NOT QT_QMAKE_EXECUTABLE)
-
-EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
-IF(NOT QTVERSION MATCHES "5.*")
- SET(QT_FOUND FALSE)
- SET(QT5_FOUND FALSE)
- IF(Qt5_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "CMake was unable to find Qt5, put qmake in your path or set QTDIR/QT_QMAKE_EXECUTABLE.")
- ENDIF(Qt5_FIND_REQUIRED)
- RETURN()
-ENDIF(NOT QTVERSION MATCHES "5.*")
-
-FIND_PACKAGE(PkgConfig REQUIRED)
-
-FIND_PACKAGE(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core DBus Gui Network Test Widgets Xml)
+IF(NOT Qt5Core_DIR )
+ IF(NOT QT_QMAKE_EXECUTABLE)
+ FIND_PROGRAM(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake qmake5 qmake-qt5
+ PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin")
+ SET(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt qmake program.")
+ ENDIF(NOT QT_QMAKE_EXECUTABLE)
+
+ EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
+ IF(NOT QTVERSION MATCHES "5.*")
+ SET(QT_FOUND FALSE)
+ SET(QT5_FOUND FALSE)
+ IF(Qt5_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "CMake was unable to find Qt5, put qmake in your path or set QTDIR/QT_QMAKE_EXECUTABLE.")
+ ENDIF(Qt5_FIND_REQUIRED)
+ RETURN()
+ ENDIF(NOT QTVERSION MATCHES "5.*")
+ENDIF(NOT Qt5Core_DIR )
+
+find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
+find_package(Qt5DBus ${REQUIRED_QT_VERSION} REQUIRED)
+find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
+find_package(Qt5Test ${REQUIRED_QT_VERSION} REQUIRED)
+find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
+find_package(Qt5Network ${REQUIRED_QT_VERSION} REQUIRED)
+find_package(Qt5Xml ${REQUIRED_QT_VERSION} REQUIRED)
# Copy includes and library names into the same style as pkgconfig used for Qt4
set(QT_INCLUDES ${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
@@ -77,9 +83,12 @@ set(QT_QTXML_LIBRARY ${Qt5Xml_LIBRARIES})
set(QT_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTWIDGETS_LIBRARY} ${QT_QTXML_LIBRARY})
-STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}")
-STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}")
-STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}")
+SET(QT_VERSION_MAJOR ${Qt5Core_VERSION_MAJOR})
+SET(QT_VERSION_MINOR ${Qt5Core_VERSION_MINOR})
+SET(QT_VERSION_PATCH ${Qt5Core_VERSION_PATCH})
+SET(QT_VERSION ${Qt5Core_VERSION})
+
+GET_PROPERTY(QT_QMAKE_EXECUTABLE TARGET ${Qt5Core_QMAKE_EXECUTABLE} PROPERTY IMPORTED_LOCATION)
IF(NOT QT_INCLUDE_DIR)
EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_HEADERS" OUTPUT_VARIABLE QTHEADERS)