summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2022-07-14 17:23:15 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2022-08-09 15:21:52 +0200
commit9ce5709fb1b4e5d563ea1d90a6cf1fc6e365d3d9 (patch)
tree282332f6641ed4230584e647353a021efbee03b3 /tests/auto/cmake
parent0ce5c0a9969bc8c763ab50b6271e203c2bcb90de (diff)
CMake: Support big resources in qt_add_resources
[ChangeLog][CMake] The target-based variant of qt6_add_resource gained the option BIG_RESOURCES. This can be used instead of qt6_add_big_resources, which is not target-based. Fixes: QTBUG-100268 Change-Id: Ib3fa783cbfbfd10f59c2f952bc88508a91f25e26 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r--tests/auto/cmake/CMakeLists.txt4
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt45
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp20
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h9
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp13
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h8
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/main.cpp35
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/resource1.txt1
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/resource2.txt1
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/resource3.txt1
10 files changed, 137 insertions, 0 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 3393fdac88..48cd4a4719 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -280,6 +280,10 @@ endif()
_qt_internal_test_expect_pass(test_add_resources_binary_generated
BINARY test_add_resources_binary_generated)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.17")
+ _qt_internal_test_expect_pass(test_add_resources_big_resources
+ BINARY test_add_resources_big_resources)
+endif()
include(test_plugin_shared_static_flavor.cmake)
_qt_internal_test_expect_pass(tst_qaddpreroutine
diff --git a/tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt b/tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt
new file mode 100644
index 0000000000..159bc71c8c
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt
@@ -0,0 +1,45 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_add_resources_big_resources)
+
+if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+endif()
+
+find_package(Qt6 REQUIRED
+ COMPONENTS Core Test
+ HINTS ${Qt6Tests_PREFIX_PATH}
+)
+
+qt6_add_library(leaf_lib STATIC leaf_lib.cpp)
+qt6_add_resources(leaf_lib resources2
+ FILES resource2.txt PREFIX "/" BIG_RESOURCES)
+target_link_libraries(leaf_lib PRIVATE Qt6::Core)
+
+if(NOT TARGET leaf_lib_resources2_obj)
+ message(FATAL_ERROR "Object library for resources2 was not created.")
+endif()
+
+qt6_add_library(intermediate_lib STATIC intermediate_lib.cpp)
+qt6_add_resources(intermediate_lib resources3
+ FILES resource3.txt PREFIX "/" BIG_RESOURCES
+)
+target_link_libraries(intermediate_lib PRIVATE Qt6::Core leaf_lib)
+
+if(NOT TARGET intermediate_lib_resources3_obj)
+ message(FATAL_ERROR "Object library for resources3 was not created.")
+endif()
+
+set(CMAKE_AUTOMOC ON)
+
+qt6_add_executable(test_add_resources_big_resources main.cpp)
+qt6_add_resources(test_add_resources_big_resources resources1
+ FILES resource1.txt PREFIX "/" BIG_RESOURCES)
+target_link_libraries(test_add_resources_big_resources PRIVATE Qt6::Test intermediate_lib)
+
+if(NOT TARGET test_add_resources_big_resources_resources1_obj)
+ message(FATAL_ERROR "Object library for resources1 was not created.")
+endif()
diff --git a/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp
new file mode 100644
index 0000000000..00817d496d
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp
@@ -0,0 +1,20 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "leaf_lib.h"
+
+#include <QtCore/qfile.h>
+
+namespace intermediate_lib {
+
+bool isLeafLibResourceAvailable()
+{
+ return leaf_lib::isResourceAvailable();
+}
+
+bool isResourceAvailable()
+{
+ return QFile::exists(u":/resource3.txt"_qs);
+}
+
+} // namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h
new file mode 100644
index 0000000000..614ebd1abc
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h
@@ -0,0 +1,9 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#pragma once
+
+namespace intermediate_lib {
+bool isLeafLibResourceAvailable();
+bool isResourceAvailable();
+} //namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp
new file mode 100644
index 0000000000..0dc07784e9
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp
@@ -0,0 +1,13 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <QtCore/qfile.h>
+
+namespace leaf_lib {
+
+bool isResourceAvailable()
+{
+ return QFile::exists(u":/resource2.txt"_qs);
+}
+
+} // namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h
new file mode 100644
index 0000000000..9a6c631c1d
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h
@@ -0,0 +1,8 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#pragma once
+
+namespace leaf_lib {
+bool isResourceAvailable();
+} // namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/main.cpp b/tests/auto/cmake/test_add_resources_big_resources/main.cpp
new file mode 100644
index 0000000000..5df2b0e5a7
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/main.cpp
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "intermediate_lib.h"
+
+#include <QtCore/qfile.h>
+#include <QtTest/QtTest>
+
+class TestAddResourcesBigResources : public QObject
+{
+ Q_OBJECT
+private slots:
+ void resourceInApplicationExists();
+ void resourceInIntermediateLibExists();
+ void resourceInLeafLibExists();
+};
+
+void TestAddResourcesBigResources::resourceInApplicationExists()
+{
+ QVERIFY(QFile::exists(":/resource1.txt"));
+}
+
+void TestAddResourcesBigResources::resourceInIntermediateLibExists()
+{
+ QVERIFY(intermediate_lib::isResourceAvailable());
+}
+
+void TestAddResourcesBigResources::resourceInLeafLibExists()
+{
+ QVERIFY(intermediate_lib::isLeafLibResourceAvailable());
+}
+
+QTEST_MAIN(TestAddResourcesBigResources)
+#include "main.moc"
+
diff --git a/tests/auto/cmake/test_add_resources_big_resources/resource1.txt b/tests/auto/cmake/test_add_resources_big_resources/resource1.txt
new file mode 100644
index 0000000000..bc06a6d721
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/resource1.txt
@@ -0,0 +1 @@
+Test resource1
diff --git a/tests/auto/cmake/test_add_resources_big_resources/resource2.txt b/tests/auto/cmake/test_add_resources_big_resources/resource2.txt
new file mode 100644
index 0000000000..b8f9e67458
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/resource2.txt
@@ -0,0 +1 @@
+Test resource2
diff --git a/tests/auto/cmake/test_add_resources_big_resources/resource3.txt b/tests/auto/cmake/test_add_resources_big_resources/resource3.txt
new file mode 100644
index 0000000000..0ed6318a85
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/resource3.txt
@@ -0,0 +1 @@
+Test resource3