diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 915b0dd972..a24fd8dd29 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1781,7 +1781,7 @@ function(_qt_internal_process_resource target resourceName) if(NOT rcc_PREFIX) get_target_property(rcc_PREFIX ${target} QT_RESOURCE_PREFIX) if (NOT rcc_PREFIX) - message(FATAL_ERROR "_qt_internal_process_resource() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default.") + set(rcc_PREFIX "/") endif() endif() @@ -1797,9 +1797,8 @@ function(_qt_internal_process_resource target resourceName) # set(qrcContents "\n +#include + +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.