diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-14 10:38:51 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-17 09:43:04 +0200 |
commit | 96e3ee06598d00e7155f3f8574759ea658a134e5 (patch) | |
tree | fac2baa25b9b1c7460e7d43772d011e12d34724a /tests/auto/cmake/test_opengl_lib | |
parent | 054b66a65748c9ebfafeca88bf31669a24994237 (diff) |
CMake: Get tests/auto/cmake tests working
The tests/auto/cmake project can be configured separately as a
standalone project with qt-cmake, or as part of the overall qtbase
standalone tests.
To do that a bunch of things were done
- Ported all Qt5 strings to Qt6
- Replaced in all projects the use of add_definitions and
include_directories with a target based approach, except for 2 tests
where we check that the old-style approach works, otherwise the
tests would file
- Removed some (possibly unneeded) EGL / OpenGL tests
- Fixed some C++ code
- Added setup code to tests/auto/cmake/CMakeLists.txt to figure out
which modules are available and should be tested
- Fixed Qt6CTestMacros.cmake to be loaded by Qt6Core
- Removed the CMake tests to not be run in qmake builds of Qt because
they would fail anyway
- Enabled the CMake tests to be part of standalone tests
- Disabled auto-passing of the C and CXX compiler cache vars when
cross-compiling so that the tests can somewhat pass on boot2qt.
This is the issue we encountered in
e2b2cd9397c76e91ac1ebe493bcac7696767c02e
- Ultimately disabled tests for boot2qt, because the -rpath-link
flag is not generated by CMake for some reason.
- Added code to setup the environment when running an executable that
was built as part of the test, so that the proper Qt libraries are
found. This handles both the standalone tests case and separate
project case.
The remaining unported tests are test_import_plugins which requires
quite a bit of work to get some modules and plugins built that were
done as part of the qmake .pro files, test_plugins that checks
some Network plugins which I'm not sure about, and
test_add_big_resource which doesn't work with namespaced builds
and there's no good way of detecting those at the moment either.
Change-Id: Ic8809c72817d1db81af6c6014c11df6473ad8c75
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/cmake/test_opengl_lib')
-rw-r--r-- | tests/auto/cmake/test_opengl_lib/CMakeLists.txt | 32 | ||||
-rw-r--r-- | tests/auto/cmake/test_opengl_lib/main.cpp | 21 |
2 files changed, 7 insertions, 46 deletions
diff --git a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt index d2304a4183..0fef37da3d 100644 --- a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt +++ b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt @@ -1,36 +1,16 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.14) project(test_opengl_lib) -find_package(Qt5Gui REQUIRED) +find_package(Qt6Gui REQUIRED) +find_package(Qt6OpenGL REQUIRED) -include_directories(${Qt5Gui_INCLUDE_DIRS} ${Qt5Gui_OPENGL_INCLUDE_DIRS} ) -add_definitions(${Qt5Gui_DEFINITIONS}) - -get_property(QtGui_enabled_features TARGET Qt5::Gui PROPERTY INTERFACE_QT_ENABLED_FEATURES) +get_property(QtGui_enabled_features TARGET Qt6::Gui PROPERTY QT_ENABLED_PUBLIC_FEATURES) list(LENGTH QtGui_enabled_features _QtGui_enabled_featuresSize) if (_QtGui_enabled_featuresSize LESS 1) - message(SEND_ERROR "The INTERFACE_QT_ENABLED_FEATURES property of Qt5::Gui is empty!") -endif() - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}") - -if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GLESv2) - list(FIND QtGui_enabled_features "opengles2" _opengles2Index) - if(_opengles2Index EQUAL -1) - message(SEND_ERROR "The INTERFACE_QT_ENABLED_FEATURES property of Qt5::Gui does not contain the opengles2 feature!") - endif() - add_definitions(-DGL_IMPLEMENTATION_GLES2) -elseif (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GL) - list(FIND QtGui_enabled_features "opengl" _openglIndex) - if(_openglIndex EQUAL -1) - message(SEND_ERROR "The INTERFACE_QT_ENABLED_FEATURES property of Qt5::Gui does not contain the opengl feature!") - endif() - add_definitions(-DGL_IMPLEMENTATION_GL) -else() - message(SEND_ERROR "Qt5Gui_OPENGL_IMPLEMENTATION does not contain valid data.") + message(SEND_ERROR "The QT_ENABLED_PUBLIC_FEATURES property of Qt6::Gui is empty!") endif() add_executable(myobject main.cpp ) -target_link_libraries(myobject ${Qt5Gui_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES}) +target_link_libraries(myobject Qt::Gui Qt::OpenGL) diff --git a/tests/auto/cmake/test_opengl_lib/main.cpp b/tests/auto/cmake/test_opengl_lib/main.cpp index 559c634a19..e3d9b6af15 100644 --- a/tests/auto/cmake/test_opengl_lib/main.cpp +++ b/tests/auto/cmake/test_opengl_lib/main.cpp @@ -28,30 +28,11 @@ #include <qglobal.h> -#ifndef QT_OPENGL_DYNAMIC -# if defined(GL_IMPLEMENTATION_GLES2) -# include <GLES2/gl2.h> -# elif defined(GL_IMPLEMENTATION_GL) -# ifdef Q_OS_WIN -# include <qt_windows.h> -# endif -# ifdef Q_OS_MAC -# include <OpenGL/gl.h> -# else -# include <GL/gl.h> -# endif -# endif -#else -# include <QOpenGLFunctions> -#endif +#include <QOpenGLFunctions> int main(int argc, char **argv) { -#ifndef QT_OPENGL_DYNAMIC - glGetError(); -#else QOpenGLFunctions functions; functions.glGetError(); -#endif return 0; } |