From bc88bb34caf1185a25eda77ee022843c0ca988b0 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 8 Aug 2023 18:30:57 +0000 Subject: Revert "CMake: Place resources into static libraries, not object libraries" This reverts commit ce8874fc3b0bab2066080315c8774b30c038862c. Reason for revert: Doesn't handle resource names that are invalid identifiers Change-Id: Idf24bd9797284ce9de382a8e233d56c799a09099 Reviewed-by: Amir Masoud Abdol Reviewed-by: Fabian Kosmale --- tests/auto/cmake/CMakeLists.txt | 1 - .../test_resource_without_obj_lib/CMakeLists.txt | 33 ---------------------- .../test_resource_without_obj_lib/helper_lib.cpp | 4 --- .../cmake/test_resource_without_obj_lib/main.cpp | 28 ------------------ .../test_resource_without_obj_lib/resource.txt | 1 - 5 files changed, 67 deletions(-) delete mode 100644 tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt delete mode 100644 tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp delete mode 100644 tests/auto/cmake/test_resource_without_obj_lib/main.cpp delete mode 100644 tests/auto/cmake/test_resource_without_obj_lib/resource.txt (limited to 'tests/auto/cmake') diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 1ce6f8a020..975cc6fc7d 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -222,7 +222,6 @@ _qt_internal_test_expect_pass(test_multiple_find_package) _qt_internal_test_expect_pass(test_add_resources_delayed_file) _qt_internal_test_expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file) _qt_internal_test_expect_pass(test_qt_add_resources_rebuild) -_qt_internal_test_expect_pass(test_resource_without_obj_lib BINARY test_resource_without_obj_lib) if(NOT NO_GUI) _qt_internal_test_expect_pass(test_private_includes) diff --git a/tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt b/tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt deleted file mode 100644 index 16563141f4..0000000000 --- a/tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2023 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) - -project(test_resource_without_obj_lib) - -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(helper_lib STATIC helper_lib.cpp) -qt6_add_resources(helper_lib "helper_res" FILES resource.txt PREFIX "/") - -# Link to Core, to ensure both the helper_lib and the main executable -# inherit the QT_NAMESPACE if it is set, otherwise we get undefined -# linker errors due to the mismatch in symbol names. -target_link_libraries(helper_lib PRIVATE Qt6::Core) - -set(CMAKE_AUTOMOC ON) - -qt6_add_executable(test_resource_without_obj_lib main.cpp) -target_link_libraries(test_resource_without_obj_lib PRIVATE Qt6::Core Qt6::Test) - -# Link against the library file and not the target, so that we can confirm -# the ability to manually initialize the resource via Q_INIT_RESOURCE. -target_link_libraries(test_resource_without_obj_lib PRIVATE $) - diff --git a/tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp b/tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp deleted file mode 100644 index 18371786a9..0000000000 --- a/tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2023 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -void nothing() {} diff --git a/tests/auto/cmake/test_resource_without_obj_lib/main.cpp b/tests/auto/cmake/test_resource_without_obj_lib/main.cpp deleted file mode 100644 index 29ea0f7272..0000000000 --- a/tests/auto/cmake/test_resource_without_obj_lib/main.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2023 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#include -#include - -class TestManualResourceInit : public QObject -{ - Q_OBJECT -private slots: - void initTestCase(); - void resourceExistsAfterManualInit(); -}; - -void TestManualResourceInit::initTestCase() -{ - // Manually initialize the resource like we used to do it in qt5 + qmake times. - Q_INIT_RESOURCE(helper_res); -} - -void TestManualResourceInit::resourceExistsAfterManualInit() -{ - QVERIFY(QFile::exists(":/resource.txt")); -} - -QTEST_MAIN(TestManualResourceInit) -#include "main.moc" - diff --git a/tests/auto/cmake/test_resource_without_obj_lib/resource.txt b/tests/auto/cmake/test_resource_without_obj_lib/resource.txt deleted file mode 100644 index 7804a324a4..0000000000 --- a/tests/auto/cmake/test_resource_without_obj_lib/resource.txt +++ /dev/null @@ -1 +0,0 @@ -Test resource -- cgit v1.2.3