diff options
-rw-r--r-- | mkspecs/features/cmake_functions.prf | 23 | ||||
-rw-r--r-- | mkspecs/features/ctest_testcase.prf | 3 | ||||
-rw-r--r-- | src/gui/Qt5GuiConfigExtras.cmake.in | 109 | ||||
-rw-r--r-- | src/gui/gui.pro | 39 | ||||
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/auto/cmake/test_egl_lib/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/auto/cmake/test_egl_lib/main.cpp | 48 | ||||
-rw-r--r-- | tests/auto/cmake/test_opengl_lib/CMakeLists.txt | 24 | ||||
-rw-r--r-- | tests/auto/cmake/test_opengl_lib/main.cpp | 65 |
9 files changed, 326 insertions, 5 deletions
diff --git a/mkspecs/features/cmake_functions.prf b/mkspecs/features/cmake_functions.prf index 1285990206..1e7c0e23f7 100644 --- a/mkspecs/features/cmake_functions.prf +++ b/mkspecs/features/cmake_functions.prf @@ -40,3 +40,26 @@ defineReplace(cmakeTargetPaths) { } return ($$join(out, " ")) } + +defineReplace(cmakePortablePaths) { + variable = $$1 + out = + for(v, variable) { + out += ${CMAKE_FIND_ROOT_PATH}$$cmakeTargetPath($$v) + } + return ($$join(out, " ")) +} + +defineReplace(cmakeProcessLibs) { + variable = $$1 + out = + for(v, variable) { + if(!equals(v, -framework)) { + v ~= s,^-l,, + v ~= s,^-lib,, + v ~= s,.lib$,, + out += $$v + } + } + return ($$join(out, ";")) +} diff --git a/mkspecs/features/ctest_testcase.prf b/mkspecs/features/ctest_testcase.prf index 3045a21672..be972e0864 100644 --- a/mkspecs/features/ctest_testcase.prf +++ b/mkspecs/features/ctest_testcase.prf @@ -57,6 +57,8 @@ isEmpty(CMAKE_VERSION) { dependentmodules -= $$CMAKE_QT_MODULES_UNDER_TEST dependentmodules = $$cmakeModuleList($$dependentmodules) + contains(QT_CONFIG, angle): CMAKE_ANGLE_DEFINE = -DQT_WITH_ANGLE=True + CMAKE_MODULE_VERSIONS = CMAKE_MODULES_UNDER_TEST = for (MODULE_UNDER_TEST, CMAKE_QT_MODULES_UNDER_TEST) { @@ -74,6 +76,7 @@ isEmpty(CMAKE_VERSION) { cmake $$_PRO_FILE_PWD_ $$CMAKE_GENERATOR \ -DCMAKE_VERBOSE_MAKEFILE=1 \ $$CMAKE_MODULE_DEFINES \ + $$CMAKE_ANGLE_DEFINE \ -DCMAKE_BUILD_TYPE=$${CMAKE_BUILD_TYPE} \ -DCMAKE_PREFIX_PATH=$$CMAKE_PREFIX_PATH \ -DQt5_MODULE_TEST_DEPENDS=\"$${dependentmodules}\" \ diff --git a/src/gui/Qt5GuiConfigExtras.cmake.in b/src/gui/Qt5GuiConfigExtras.cmake.in index d9313d4364..03b98ed273 100644 --- a/src/gui/Qt5GuiConfigExtras.cmake.in +++ b/src/gui/Qt5GuiConfigExtras.cmake.in @@ -1,5 +1,50 @@ -!!IF !contains(QT_CONFIG, angle) +!!IF !mac + +!!IF !isEmpty(CMAKE_ANGLE_EGL_DLL_RELEASE) + +!!IF isEmpty(CMAKE_INCLUDE_DIR_IS_ABSOLUTE) +set(Qt5Gui_EGL_INCLUDE_DIRS \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$$CMAKE_INCLUDE_DIR\") +!!ELSE +set(Qt5Gui_EGL_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR\") +!!ENDIF + +set(Qt5Gui_OPENGL_INCLUDE_DIRS ${Qt5Gui_EGL_INCLUDE_DIRS}) + +macro(_populate_qt5gui_gl_target_properties TargetName Configuration LIB_LOCATION IMPLIB_LOCATION) + set_property(TARGET Qt5::${TargetName} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) + + set_target_properties(Qt5::${TargetName} PROPERTIES +!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) + \"IMPORTED_LOCATION_${Configuration}\" \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${LIB_LOCATION}\" +!!ELSE + \"IMPORTED_LOCATION_${Configuration}\" \"$${CMAKE_LIB_DIR}${LIB_LOCATION}\" +!!ENDIF +!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) + \"IMPORTED_IMPLIB_${Configuration}\" \"${_qt5Gui_install_prefix}/$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\" +!!ELSE + \"IMPORTED_IMPLIB_${Configuration}\" \"$${CMAKE_LIB_DIR}${IMPLIB_LOCATION}\" +!!ENDIF + ) +endmacro() + +add_library(Qt5::Gui_EGL SHARED IMPORTED) +_populate_qt5gui_gl_target_properties(Gui_EGL RELEASE $${CMAKE_ANGLE_EGL_DLL_RELEASE} $${CMAKE_ANGLE_EGL_IMPLIB_RELEASE}) +add_library(Qt5::Gui_GLESv2 SHARED IMPORTED) +_populate_qt5gui_gl_target_properties(Gui_GLESv2 RELEASE $${CMAKE_ANGLE_GLES2_DLL_RELEASE} $${CMAKE_ANGLE_GLES2_IMPLIB_RELEASE}) + +set_property(TARGET Qt5::Gui_EGL APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Qt5Gui_EGL_INCLUDE_DIRS}) +set_property(TARGET Qt5::Gui_GLESv2 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Qt5Gui_OPENGL_INCLUDE_DIRS}) + +!!IF !isEmpty(CMAKE_DEBUG_TYPE) +_populate_qt5gui_gl_target_properties(Gui_EGL DEBUG $${CMAKE_ANGLE_EGL_DLL_DEBUG} $${CMAKE_ANGLE_EGL_IMPLIB_DEBUG}) +_populate_qt5gui_gl_target_properties(Gui_GLESv2 DEBUG $${CMAKE_ANGLE_GLES2_DLL_DEBUG} $${CMAKE_ANGLE_GLES2_IMPLIB_DEBUG}) +!!ENDIF + +set(Qt5Gui_EGL_LIBRARIES Qt5::Gui_EGL) +set(Qt5Gui_OPENGL_LIBRARIES Qt5::Gui_GLESv2) + +!!ELSE !!IF !isEmpty(CMAKE_GL_INCDIRS) @@ -17,4 +62,66 @@ unset(_qt5gui_OPENGL_INCLUDE_DIR CACHE) !!ENDIF +macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs) + set(Qt5Gui_${Name}_LIBRARIES) + set(Qt5Gui_EGL_INCLUDE_DIRS ${IncDirs}) + foreach(_lib ${Libs}) + string(REGEX REPLACE "[^_A-Za-z0-9]" "_" _cmake_lib_name ${_lib}) + if (NOT TARGET Qt5::Gui_${_cmake_lib_name}) + find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib} +!!IF !isEmpty(CROSS_COMPILE) + PATHS \"${LibDir}\" NO_DEFAULT_PATH +!!ENDIF + ) + if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY) + message(FATAL_ERROR \"Failed to find \\\"${_lib}\\\" in \\\"${LibDir}\\\", using the CMAKE_FIND_ROOT_PATH \\\"${CMAKE_FIND_ROOT_PATH}\\\".\") + endif() + add_library(Qt5::Gui_${_cmake_lib_name} SHARED IMPORTED) + set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${IncDirs}) + + set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_RELEASE \"${Qt5Gui_${_cmake_lib_name}_LIBRARY}\") +!!IF !isEmpty(CMAKE_WINDOWS_BUILD) + set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_IMPLIB_RELEASE \"${Qt5Gui_${_cmake_lib_name}_LIBRARY}\") +!!ENDIF + unset(Qt5Gui_${_cmake_lib_name}_LIBRARY CACHE) + + find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG ${_lib}d + PATHS \"${LibDir}\" NO_DEFAULT_PATH) + if (Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG) + set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_DEBUG \"${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}\") +!!IF !isEmpty(CMAKE_WINDOWS_BUILD) + set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_IMPLIB_DEBUG \"${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}\") +!!ENDIF + endif() + unset(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG CACHE) + endif() + list(APPEND Qt5Gui_${Name}_LIBRARIES Qt5::Gui_${_cmake_lib_name}) + endforeach() +endmacro() + + +!!IF !isEmpty(CMAKE_EGL_LIBS) +_qt5gui_find_extra_libs(EGL \"$$CMAKE_EGL_LIBS\" \"$$CMAKE_EGL_LIBDIR\" \"$$CMAKE_EGL_INCDIRS\") +!!ENDIF + +!!IF !isEmpty(CMAKE_OPENGL_LIBS) +_qt5gui_find_extra_libs(OPENGL \"$$CMAKE_OPENGL_LIBS\" \"$$CMAKE_OPENGL_LIBDIR\" \"$$CMAKE_OPENGL_INCDIRS\") + +!!ENDIF + +!!ENDIF + +set(Qt5Gui_OPENGL_IMPLEMENTATION $$CMAKE_QT_OPENGL_IMPLEMENTATION) + +get_target_property(_configs Qt5::Gui IMPORTED_CONFIGURATIONS) +foreach(_config ${_configs}) + set_property(TARGET Qt5::Gui APPEND PROPERTY + IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config} + ${Qt5Gui_EGL_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES} + ) +endforeach() +unset(_configs) + !!ENDIF diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 9238fd91a4..062f00c4c4 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -37,18 +37,49 @@ QMAKE_LIBS += $$QMAKE_LIBS_GUI load(cmake_functions) -!contains(QT_CONFIG, angle) { +win32: CMAKE_WINDOWS_BUILD = True + +contains(QT_CONFIG, angle) { + CMAKE_GL_INCDIRS = $$CMAKE_INCLUDE_DIR + CMAKE_ANGLE_EGL_DLL_RELEASE = libEGL.dll + CMAKE_ANGLE_EGL_IMPLIB_RELEASE = libEGL.lib + CMAKE_ANGLE_GLES2_DLL_RELEASE = libGLESv2.dll + CMAKE_ANGLE_GLES2_IMPLIB_RELEASE = libGLESv2.lib + CMAKE_ANGLE_EGL_DLL_DEBUG = libEGLd.dll + CMAKE_ANGLE_EGL_IMPLIB_DEBUG = libEGLd.lib + CMAKE_ANGLE_GLES2_DLL_DEBUG = libGLESv2d.dll + CMAKE_ANGLE_GLES2_IMPLIB_DEBUG = libGLESv2d.lib + + CMAKE_QT_OPENGL_IMPLEMENTATION = GLESv2 +} else { + CMAKE_EGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_EGL) + !isEmpty(QMAKE_LIBDIR_EGL): CMAKE_EGL_LIBDIR += $$cmakeTargetPath($$QMAKE_LIBDIR_EGL) + contains(QT_CONFIG, opengles1) { - CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES1) + !isEmpty(QMAKE_INCDIR_OPENGL_ES1): CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES1) + CMAKE_OPENGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_OPENGL_ES1) + CMAKE_OPENGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_OPENGL_ES1) + !isEmpty(QMAKE_LIBDIR_OPENGL_ES1): CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$QMAKE_LIBDIR_OPENGL_ES1) CMAKE_GL_HEADER_NAME = GLES/gl.h + CMAKE_QT_OPENGL_IMPLEMENTATION = GLES } else:contains(QT_CONFIG, opengles2) { - CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES2) + !isEmpty(QMAKE_INCDIR_OPENGL_ES2): CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES2) + CMAKE_OPENGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_OPENGL_ES2) + CMAKE_OPENGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_OPENGL_ES2) + !isEmpty(QMAKE_LIBDIR_OPENGL_ES2): CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$QMAKE_LIBDIR_OPENGL_ES2) CMAKE_GL_HEADER_NAME = GLES2/gl2.h + CMAKE_QT_OPENGL_IMPLEMENTATION = GLESv2 } else { - CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL) + !isEmpty(QMAKE_INCDIR_OPENGL): CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL) + CMAKE_OPENGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_OPENGL) + CMAKE_OPENGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_OPENGL) + !isEmpty(QMAKE_LIBDIR_OPENGL): CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$QMAKE_LIBDIR_OPENGL) CMAKE_GL_HEADER_NAME = GL/gl.h mac: CMAKE_GL_HEADER_NAME = gl.h + CMAKE_QT_OPENGL_IMPLEMENTATION = GL } } +CMAKE_EGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_EGL) + QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 77cf81989a..ea218f630f 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -121,6 +121,12 @@ test_module_includes( ) expect_pass(test_concurrent_module) expect_pass(test_openglextensions_module) +if (NOT APPLE) + if (QT_WITH_ANGLE OR NOT WIN32) + expect_pass(test_egl_lib) + endif() + expect_pass(test_opengl_lib) +endif() if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) expect_pass(test_interface) diff --git a/tests/auto/cmake/test_egl_lib/CMakeLists.txt b/tests/auto/cmake/test_egl_lib/CMakeLists.txt new file mode 100644 index 0000000000..87a598fa99 --- /dev/null +++ b/tests/auto/cmake/test_egl_lib/CMakeLists.txt @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 2.8) + +project(test_egl_lib) + +find_package(Qt5Gui REQUIRED) + +include_directories(${Qt5Gui_INCLUDE_DIRS} ${Qt5Gui_EGL_INCLUDE_DIRS} ) +add_definitions(${Qt5Gui_DEFINITIONS}) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}") + +add_executable(myobject main.cpp ) +target_link_libraries(myobject ${Qt5Gui_LIBRARIES} ${Qt5Gui_EGL_LIBRARIES}) diff --git a/tests/auto/cmake/test_egl_lib/main.cpp b/tests/auto/cmake/test_egl_lib/main.cpp new file mode 100644 index 0000000000..f3a9dc6cd1 --- /dev/null +++ b/tests/auto/cmake/test_egl_lib/main.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <EGL/egl.h> + +int main(int argc, char **argv) +{ + eglGetError(); + return 0; +} diff --git a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt new file mode 100644 index 0000000000..d602bcda9b --- /dev/null +++ b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 2.8) + +project(test_opengl_lib) + +find_package(Qt5Gui REQUIRED) + +include_directories(${Qt5Gui_INCLUDE_DIRS} ${Qt5Gui_OPENGL_INCLUDE_DIRS} ) +add_definitions(${Qt5Gui_DEFINITIONS}) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}") + +if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GLES) + add_definitions(-DGL_IMPLEMENTATION_GLES1) +elseif (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GLESv2) + add_definitions(-DGL_IMPLEMENTATION_GLES2) +elseif (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GL) + add_definitions(-DGL_IMPLEMENTATION_GL) +else() + message(SEND_ERROR "Qt5Gui_OPENGL_IMPLEMENTATION does not contain valid data.") +endif() + +add_executable(myobject main.cpp ) +target_link_libraries(myobject ${Qt5Gui_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES}) diff --git a/tests/auto/cmake/test_opengl_lib/main.cpp b/tests/auto/cmake/test_opengl_lib/main.cpp new file mode 100644 index 0000000000..450b759bc8 --- /dev/null +++ b/tests/auto/cmake/test_opengl_lib/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#if GL_IMPLEMENTATION_GLES1 +#include <GLES/gl.h> +#elif GL_IMPLEMENTATION_GLES2 +#include <GLES2/gl2.h> +#elif GL_IMPLEMENTATION_GL + +#include <qglobal.h> +#ifdef Q_OS_WIN +#include <qt_windows.h> +#endif + +#ifdef Q_OS_MAC +#include <OpenGL/gl.h> +#else +#include <GL/gl.h> +#endif +#endif + +int main(int argc, char **argv) +{ + glGetError(); + return 0; +} |