summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_interface
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake/test_interface')
-rw-r--r--tests/auto/cmake/test_interface/CMakeLists.txt25
-rw-r--r--tests/auto/cmake/test_interface/main.cpp29
-rw-r--r--tests/auto/cmake/test_interface/mainwindow.cpp29
-rw-r--r--tests/auto/cmake/test_interface/mainwindow.h29
-rw-r--r--tests/auto/cmake/test_interface/widget_test/CMakeLists.txt15
-rw-r--r--tests/auto/cmake/test_interface/widget_test/main.cpp4
6 files changed, 35 insertions, 96 deletions
diff --git a/tests/auto/cmake/test_interface/CMakeLists.txt b/tests/auto/cmake/test_interface/CMakeLists.txt
index 0cae16668e..7028b41f7b 100644
--- a/tests/auto/cmake/test_interface/CMakeLists.txt
+++ b/tests/auto/cmake/test_interface/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_interface)
@@ -14,23 +17,15 @@ add_executable(test_interface_exe WIN32 main.cpp mainwindow.cpp)
# link explicitly to Qt::WinMain.
target_link_libraries(test_interface_exe Qt::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; }
-"
-)
-
# Fix try_compile to inherit the parent configuration.
set(CMAKE_TRY_COMPILE_CONFIGURATION "${CMAKE_BUILD_TYPE}")
-# The try_compile works because Qt::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 Qt::Widgets
+# Can't use source file based try_compile, because it doesn't handle object libraries
+# referenced in generator expressions properly.
+try_compile(_TRY_COMPILE_RES
+ "${CMAKE_CURRENT_BINARY_DIR}/widget_test"
+ "${CMAKE_CURRENT_SOURCE_DIR}/widget_test"
+ widget_test
OUTPUT_VARIABLE TC_OV
)
diff --git a/tests/auto/cmake/test_interface/main.cpp b/tests/auto/cmake/test_interface/main.cpp
index 491c7bf016..56b442a4ce 100644
--- a/tests/auto/cmake/test_interface/main.cpp
+++ b/tests/auto/cmake/test_interface/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QApplication>
diff --git a/tests/auto/cmake/test_interface/mainwindow.cpp b/tests/auto/cmake/test_interface/mainwindow.cpp
index 56bf81611a..2fec6400f6 100644
--- a/tests/auto/cmake/test_interface/mainwindow.cpp
+++ b/tests/auto/cmake/test_interface/mainwindow.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mainwindow.h"
diff --git a/tests/auto/cmake/test_interface/mainwindow.h b/tests/auto/cmake/test_interface/mainwindow.h
index 2dd52efd01..345c4f69e9 100644
--- a/tests/auto/cmake/test_interface/mainwindow.h
+++ b/tests/auto/cmake/test_interface/mainwindow.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt b/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt
new file mode 100644
index 0000000000..dd4c8fff28
--- /dev/null
+++ b/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_interface_try_compile)
+
+find_package(Qt6Widgets)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+add_executable(test_interface_try_compile_exe main.cpp)
+target_link_libraries(test_interface_try_compile_exe Qt::Widgets)
+
diff --git a/tests/auto/cmake/test_interface/widget_test/main.cpp b/tests/auto/cmake/test_interface/widget_test/main.cpp
new file mode 100644
index 0000000000..e6a8ab5fe9
--- /dev/null
+++ b/tests/auto/cmake/test_interface/widget_test/main.cpp
@@ -0,0 +1,4 @@
+#include <QString>
+#include <QWidget>
+
+int main(int, char**) { QWidget w; w.show(); return 0; }