diff options
author | Amir Masoud Abdol <amirmasoudabdol@icloud.com> | 2022-10-13 13:01:56 +0200 |
---|---|---|
committer | Amir Masoud Abdol <amirmasoudabdol@icloud.com> | 2022-10-25 16:39:25 +0200 |
commit | 2625e5f050b2bedb4aa9ff9307e90c1e3ba85e8e (patch) | |
tree | fbebb3066a1ebdfaf1f828547575fc8737be005a /tests/auto/cmake | |
parent | 30eac4a4f9df0b7402fe70499be9385e7ee8737e (diff) |
Make the `PREFIX` Parameter of the `qt_add_resources` Optional
The `rcc_PREFIX` will be set to `/` if it is not passed to the
function and it is not defined in `QT_RESOURCE_PREFIX`.
I also removed an unnecessary check of the `rcc_PREFIX`.
[ChangeLog][QtCore][CMake] The `PREFIX` parameter of the
`qt_add_resources` is now optional. If not passed, and
`QT_RESOURCE_PREFIX` is not defined, `/` will be used as the path
prefix.
Fixes: QTBUG-104938
Change-Id: I6524ab5dc54f035272e4c2e3154eb67591efb650
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt | 25 | ||||
-rw-r--r-- | tests/auto/cmake/test_add_resource_prefix/main.cpp | 26 | ||||
-rw-r--r-- | tests/auto/cmake/test_add_resource_prefix/resource_file.txt | 1 |
4 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index afc6002ff6..f86f2ac720 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -158,6 +158,7 @@ if (NOT NO_WIDGETS) _qt_internal_test_expect_pass(test_dependent_modules) _qt_internal_test_expect_pass("test(needsquoting)dirname") endif() +_qt_internal_test_expect_pass(test_add_resource_prefix BINARY test_add_resource_prefix) _qt_internal_test_expect_build_fail(test_add_resource_options) _qt_internal_test_expect_build_fail(test_wrap_cpp_options) _qt_internal_test_expect_pass(test_platform_defs_include) diff --git a/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt b/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt new file mode 100644 index 0000000000..65faa4cb09 --- /dev/null +++ b/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) + +project(test_add_resource_prefix) + +find_package(Qt6 REQUIRED + COMPONENTS Core Test +) + +set(CMAKE_AUTOMOC ON) + +add_executable(test_add_resource_prefix main.cpp) + +# Tests if "/" is being used when PREFIX is missing +qt_add_resources(test_add_resource_prefix "resources_without_prefix" + FILES resource_file.txt) + +# Tests if the PREFIX parameter is being respected +qt_add_resources(test_add_resource_prefix "resources_with_prefix" + PREFIX "/resources" + FILES resource_file.txt) + +target_link_libraries(test_add_resource_prefix PRIVATE Qt::Core Qt::Test) diff --git a/tests/auto/cmake/test_add_resource_prefix/main.cpp b/tests/auto/cmake/test_add_resource_prefix/main.cpp new file mode 100644 index 0000000000..cad519423f --- /dev/null +++ b/tests/auto/cmake/test_add_resource_prefix/main.cpp @@ -0,0 +1,26 @@ +// 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 <QFile> +#include <QtTest> + +class TestAddResourcePrefix : public QObject +{ + Q_OBJECT +private slots: + void resourceInDefaultPathExists(); + void resourceInGivenPathExists(); +}; + +void TestAddResourcePrefix::resourceInDefaultPathExists() +{ + QVERIFY(QFile::exists(":/resource_file.txt")); +} + +void TestAddResourcePrefix::resourceInGivenPathExists() +{ + QVERIFY(QFile::exists(":/resources/resource_file.txt")); +} + +QTEST_MAIN(TestAddResourcePrefix) +#include "main.moc" diff --git a/tests/auto/cmake/test_add_resource_prefix/resource_file.txt b/tests/auto/cmake/test_add_resource_prefix/resource_file.txt new file mode 100644 index 0000000000..2c604a4f18 --- /dev/null +++ b/tests/auto/cmake/test_add_resource_prefix/resource_file.txt @@ -0,0 +1 @@ +Ken sent me. |