From 046001e57181271c368252367208972e52864f31 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Sun, 25 May 2014 13:50:18 +0200 Subject: [PATCH] Make: improve detection of X11 with Qt 5 In collaboration with Scott Kostyshak: With Qt 4 we could use Q_WS_X11, defined by FindQt4.cmake. In Qt 5, there is no FindQt5.cmake. Instead we now define our own variable, QT_USES_X11 by using class QX11Info available only on X11. (http://qt-project.org/doc/qt-5/QX11Info.html) The main consequence of this improved support is that now the keytests can be run (ctest -R "keytest") when LyX is compiled with Qt 5. Before, with Qt 5 we did not know if X11 was available, which is needed by xvkbd, so the tests were not enabled. Note, however, that many tests fail with Qt version 5.2.1 because there was a change in the event handling mechanism in Qt that causes xvkbd to be unable to pass capital letters (so case sensitive greps in the tests fail). This needs to be investigated and reported. --- CMakeLists.txt | 1 + development/autotests/CMakeLists.txt | 2 +- development/cmake/ConfigureChecks.cmake | 30 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04f3954350..0ceebc96a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -512,6 +512,7 @@ endif() find_package(Qt5Core QUIET) if (Qt5Core_FOUND) find_package(Qt5Widgets REQUIRED) + find_package(Qt5X11Extras) set(QTVERSION ${Qt5Core_VERSION}) macro (qt_use_modules) qt5_use_modules(${ARGN}) diff --git a/development/autotests/CMakeLists.txt b/development/autotests/CMakeLists.txt index 9a6e6c4e8c..c1e19a4aff 100644 --- a/development/autotests/CMakeLists.txt +++ b/development/autotests/CMakeLists.txt @@ -8,7 +8,7 @@ set(LYX_HOME "out-home") set(LOCALE_DIR "${CMAKE_CURRENT_BINARY_DIR}/locale") file(MAKE_DIRECTORY "${LOCALE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/${LYX_HOME}") -if(Q_WS_X11) +if(QT_USES_X11) set(Missing) set(XVFBDLIBS) # Make sure, the needed programs are in PATH diff --git a/development/cmake/ConfigureChecks.cmake b/development/cmake/ConfigureChecks.cmake index 71291a53a5..035a62b0f6 100644 --- a/development/cmake/ConfigureChecks.cmake +++ b/development/cmake/ConfigureChecks.cmake @@ -112,3 +112,33 @@ check_cxx_source_compiles( " SIZEOF_WCHAR_T_IS_4) +if (Qt5X11Extras_FOUND) + get_target_property(_x11extra_prop Qt5::X11Extras IMPORTED_CONFIGURATIONS) + get_target_property(_x11extra_lib Qt5::X11Extras IMPORTED_SONAME_${_x11extra_prop}) + set(CMAKE_REQUIRED_LIBRARIES ${_x11extra_lib}) + set(CMAKE_REQUIRED_INCLUDES ${Qt5X11Extras_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_FLAGS ${Qt5X11Extras_EXECUTABLE_COMPILE_FLAGS}) + check_cxx_source_compiles( + " + #include + int main() + { + bool isX11 = QX11Info::isPlatformX11(); + } + " + QT_USES_X11) +elseif(QT4_FOUND) + set(CMAKE_REQUIRED_LIBRARIES ${QT_QTGUI_LIBRARY}) + set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) + check_cxx_source_compiles( + " + #include + int main() + { + QX11Info *qxi = new QX11Info; + qxi->~QX11Info(); + } + " + QT_USES_X11) +endif() +