diff options
-rw-r--r-- | mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 5 | ||||
-rw-r--r-- | src/corelib/Qt5CoreConfigExtras.cmake.in | 29 | ||||
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/auto/cmake/test_interface/CMakeLists.txt | 36 | ||||
-rw-r--r-- | tests/auto/cmake/test_interface/main.cpp | 58 | ||||
-rw-r--r-- | tests/auto/cmake/test_interface/mainwindow.cpp | 48 | ||||
-rw-r--r-- | tests/auto/cmake/test_interface/mainwindow.h | 57 |
7 files changed, 235 insertions, 2 deletions
diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index b5b670e9e8..e5bbc97161 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -123,6 +123,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1) !!ENDIF + set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${Qt5$${CMAKE_MODULE_NAME}_INCLUDE_DIRS}) + set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY + INTERFACE_COMPILE_DEFINITIONS $${MODULE_DEFINE}) + !!IF !isEmpty(CMAKE_RELEASE_TYPE) !!IF !isEmpty(CMAKE_STATIC_WINDOWS_BUILD) _populate_$${CMAKE_MODULE_NAME}_target_properties(RELEASE \"$${CMAKE_IMPLIB_FILE_LOCATION_RELEASE}\" \"\" ) diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 9b6cda11aa..bdafc85796 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -47,22 +47,28 @@ set_property(TARGET Qt5::Core APPEND PROPERTY ) !!IF isEmpty(CMAKE_ARCHDATA_DIR_IS_ABSOLUTE) -list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5Core_install_prefix}/$${CMAKE_ARCHDATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\") +set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_ARCHDATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\") !!ELSE -list(APPEND Qt5Core_INCLUDE_DIRS \"$${CMAKE_ARCHDATA_DIR}mkspecs/$${CMAKE_MKSPEC}\") +set(_qt5_corelib_extra_includes \"$${CMAKE_ARCHDATA_DIR}mkspecs/$${CMAKE_MKSPEC}\") !!ENDIF +list(APPEND Qt5Core_INCLUDE_DIRS ${_qt5_corelib_extra_includes}) +set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5_corelib_extra_includes}) +set(_qt5_corelib_extra_includes) + !!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS) # Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The # Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module # macro to add it. set(Qt5_POSITION_INDEPENDENT_CODE True) +set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\") set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIE\") !!ENDIF !!IF !isEmpty(QT_NAMESPACE) list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE) list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) +set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) !!ENDIF !!IF contains(QT_CONFIG, reduce_exports) @@ -100,6 +106,25 @@ if (NOT TARGET Qt5::WinMain) !!ENDIF ) !!ENDIF + + if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT Qt5_NO_LINK_QTMAIN) + set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>) + set(_isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>) + set(_isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>) + set(_isPolicyNEW $<TARGET_POLICY:CMP0020>) + get_target_property(_configs Qt5::Core IMPORTED_CONFIGURATIONS) + foreach(_config ${_configs}) + set_property(TARGET Qt5::Core APPEND PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} + $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt5::WinMain> + ) + endforeach() + unset(_configs) + unset(_isExe) + unset(_isWin32) + unset(_isNotExcluded) + unset(_isPolicyNEW) + endif() endif() !!ENDIF diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 8f97c0eb7a..ad31956f62 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -121,3 +121,7 @@ test_module_includes( ) expect_pass(test_concurrent_module) expect_pass(test_openglextensions_module) + +if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) + expect_pass(test_interface) +endif() diff --git a/tests/auto/cmake/test_interface/CMakeLists.txt b/tests/auto/cmake/test_interface/CMakeLists.txt new file mode 100644 index 0000000000..a8af92da63 --- /dev/null +++ b/tests/auto/cmake/test_interface/CMakeLists.txt @@ -0,0 +1,36 @@ + +cmake_minimum_required(VERSION 2.8.11) + +project(test_interface) + +find_package(Qt5Widgets) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_executable(test_interface_exe WIN32 main.cpp mainwindow.cpp) + +# No need to specify include directories, compile definitions, the PIC flag, or to +# link explicitly to Qt5::WinMain. +target_link_libraries(test_interface_exe Qt5::Widgets) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp" + " +#include <QString> +#include <QWidget> + +int main(int,char**) { QWidget w; w.show(); return 0; } +" +) + +# The try_compile works because Qt5::Widgets is listed in the LINK_LIBRARIES, +# which causes the includes, defines and appropriate PIC flag to be used. +try_compile(_TRY_COMPILE_RES "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test" + "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp" + LINK_LIBRARIES Qt5::Widgets + OUTPUT_VARIABLE TC_OV +) + +if (NOT _TRY_COMPILE_RES) + message(SEND_ERROR "The use of try_compile with Qt5::Widgets failed. The output was :\n${TC_OV}") +endif() diff --git a/tests/auto/cmake/test_interface/main.cpp b/tests/auto/cmake/test_interface/main.cpp new file mode 100644 index 0000000000..c1d699219b --- /dev/null +++ b/tests/auto/cmake/test_interface/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 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 <QApplication> + +#include "mainwindow.h" + +#if !defined(QT_CORE_LIB) || !defined(QT_GUI_LIB) || !defined(QT_WIDGETS_LIB) +#error Missing module definitions +#endif + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + MainWindow mw; + mw.show(); + + return app.exec(); +} diff --git a/tests/auto/cmake/test_interface/mainwindow.cpp b/tests/auto/cmake/test_interface/mainwindow.cpp new file mode 100644 index 0000000000..1f79bd4a1d --- /dev/null +++ b/tests/auto/cmake/test_interface/mainwindow.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 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 "mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QWidget(parent) +{ + +} diff --git a/tests/auto/cmake/test_interface/mainwindow.h b/tests/auto/cmake/test_interface/mainwindow.h new file mode 100644 index 0000000000..2037c59eab --- /dev/null +++ b/tests/auto/cmake/test_interface/mainwindow.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 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$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QWidget> + +class MainWindow : public QWidget +{ + Q_OBJECT +public: + MainWindow(QWidget *parent = 0); + +signals: + void somethingHappened(); +}; + +#endif |