diff options
-rw-r--r-- | src/corelib/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 42 | ||||
-rw-r--r-- | src/corelib/Qt6CoreResourceInit.in.cpp | 14 | ||||
-rw-r--r-- | src/corelib/global/qtsymbolmacros.h | 65 | ||||
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt | 33 | ||||
-rw-r--r-- | tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp | 4 | ||||
-rw-r--r-- | tests/auto/cmake/test_resource_without_obj_lib/main.cpp | 28 | ||||
-rw-r--r-- | tests/auto/cmake/test_resource_without_obj_lib/resource.txt | 1 |
9 files changed, 8 insertions, 192 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index e7545084c1..adfb67ffd6 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -87,7 +87,6 @@ qt_internal_add_module(Core global/qtpreprocessorsupport.h global/qtrace_p.h global/qtresource.h - global/qtsymbolmacros.h global/qttranslation.h global/qttypetraits.h global/qtversionchecks.h @@ -343,12 +342,11 @@ qt_internal_add_module(Core PUBLIC_LIBRARIES Qt::Platform EXTRA_CMAKE_FILES - "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CTestMacros.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreConfigureFileTemplate.in" - "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreResourceInit.in.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreDeploySupport.cmake" - "${config_build_dir}/QtInstallPaths.cmake" - ${corelib_extra_cmake_files} + "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CTestMacros.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreConfigureFileTemplate.in" + "${CMAKE_CURRENT_SOURCE_DIR}/Qt6CoreDeploySupport.cmake" + "${config_build_dir}/QtInstallPaths.cmake" + ${corelib_extra_cmake_files} POLICIES QTP0002 ) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index e2b49900f7..cb58bbef40 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1846,24 +1846,11 @@ function(__qt_propagate_generated_resource target resource_name generated_source math(EXPR resource_count "${resource_count} + 1") set_target_properties(${target} PROPERTIES _qt_generated_resource_target_count ${resource_count}) - __qt_internal_generate_init_resource_source_file( - resource_init_file ${target} ${resource_name}) - set(resource_target "${target}_resources_${resource_count}") - add_library("${resource_target}" OBJECT "${resource_init_file}") - # Needed so that qtsymbolmacros.h and its dependent headers are already created / syncqt'ed. - if(TARGET Core_sync_headers) - set(headers_available_target "Core_sync_headers") - else() - set(headers_available_target "${QT_CMAKE_EXPORT_NAMESPACE}::Core") - endif() - add_dependencies(${resource_target} ${headers_available_target}) + add_library("${resource_target}" OBJECT "${generated_source_code}") target_compile_definitions("${resource_target}" PRIVATE "$<TARGET_PROPERTY:${QT_CMAKE_EXPORT_NAMESPACE}::Core,INTERFACE_COMPILE_DEFINITIONS>" ) - target_include_directories("${resource_target}" PRIVATE - "$<TARGET_PROPERTY:${QT_CMAKE_EXPORT_NAMESPACE}::Core,INTERFACE_INCLUDE_DIRECTORIES>" - ) _qt_internal_set_up_static_runtime_library("${resource_target}") # Special handling is required for the Core library resources. The linking of the Core @@ -1882,7 +1869,7 @@ function(__qt_propagate_generated_resource target resource_name generated_source # .rcc/qrc_qprintdialog.cpp file(RELATIVE_PATH generated_cpp_file_relative_path "${CMAKE_CURRENT_BINARY_DIR}" - "${resource_init_file}") + "${generated_source_code}") set_property(TARGET ${resource_target} APPEND PROPERTY _qt_resource_generated_cpp_relative_path "${generated_cpp_file_relative_path}") @@ -1896,31 +1883,8 @@ function(__qt_propagate_generated_resource target resource_name generated_source set(${output_generated_target} "${resource_target}" PARENT_SCOPE) else() set(${output_generated_target} "" PARENT_SCOPE) + target_sources(${target} PRIVATE ${generated_source_code}) endif() - - target_sources(${target} PRIVATE ${generated_source_code}) -endfunction() - -function(__qt_internal_generate_init_resource_source_file out_var target resource_name) - set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreResourceInit.in.cpp") - - # Gets replaced in the template - set(RESOURCE_NAME "${resource_name}") - set(resource_init_path "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${resource_name}_init.cpp") - - configure_file("${template_file}" "${resource_init_path}" @ONLY) - - set(scope_args "") - if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18") - set(scope_args TARGET_DIRECTORY ${target}) - endif() - set_source_files_properties(${resource_init_path} ${scope_args} PROPERTIES - SKIP_AUTOGEN TRUE - SKIP_UNITY_BUILD_INCLUSION TRUE - SKIP_PRECOMPILE_HEADERS TRUE - ) - - set(${out_var} "${resource_init_path}" PARENT_SCOPE) endfunction() # Make file visible in IDEs. diff --git a/src/corelib/Qt6CoreResourceInit.in.cpp b/src/corelib/Qt6CoreResourceInit.in.cpp deleted file mode 100644 index 0234ec8232..0000000000 --- a/src/corelib/Qt6CoreResourceInit.in.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 The Qt Company Ltd. -// SPDX-License-Identifier: BSD-3-Clause - -// This file was generated by the qt_add_resources command. - -#include <QtCore/qtsymbolmacros.h> - -QT_DECLARE_EXTERN_RESOURCE(@RESOURCE_NAME@); - -namespace { - struct resourceReferenceKeeper { - resourceReferenceKeeper() { QT_KEEP_RESOURCE(@RESOURCE_NAME@); } - } resourceReferenceKeeperInstance; -} diff --git a/src/corelib/global/qtsymbolmacros.h b/src/corelib/global/qtsymbolmacros.h deleted file mode 100644 index 18cdc85f72..0000000000 --- a/src/corelib/global/qtsymbolmacros.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2023 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#ifndef QTSYMBOLMACROS_H -#define QTSYMBOLMACROS_H - -#if 0 -# pragma qt_sync_stop_processing -#endif - -// For GHS symbol keeping. -#include <QtCore/qcompilerdetection.h> -#include <QtCore/qtpreprocessorsupport.h> - -// For handling namespaced resources. -#ifdef QT_NAMESPACE -# define QT_RCC_MANGLE_NAMESPACE0(x) x -# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b -# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) -# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ - QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) -#else -# define QT_RCC_MANGLE_NAMESPACE(name) name -#endif - -// GHS needs special handling to keep a symbol around. -#if defined(Q_CC_GHS) -# define Q_GHS_KEEP_REFERENCE(S) QT_DO_PRAGMA(ghs reference S ##__Fv) -#else -# define Q_GHS_KEEP_REFERENCE(S) -#endif - -// Macros to ensure a symbol is not dropped by the linker even if it's not used. -#define QT_DECLARE_EXTERN_SYMBOL(NAME, RETURN_TYPE) \ - extern RETURN_TYPE NAME(); \ - Q_GHS_KEEP_REFERENCE(NAME) - -#define QT_DECLARE_EXTERN_SYMBOL_INT(NAME) \ - QT_DECLARE_EXTERN_SYMBOL(NAME, int) - -#define QT_DECLARE_EXTERN_SYMBOL_VOID(NAME) \ - QT_DECLARE_EXTERN_SYMBOL(NAME, void) - -#define QT_KEEP_SYMBOL_VAR_NAME(NAME) NAME ## _keep - -#define QT_KEEP_SYMBOL_HELPER(NAME, VAR_NAME) \ - volatile auto VAR_NAME = &NAME; \ - Q_UNUSED(VAR_NAME) - -#define QT_KEEP_SYMBOL(NAME) \ - QT_KEEP_SYMBOL_HELPER(NAME, QT_KEEP_SYMBOL_VAR_NAME(NAME)) - - -// Similar to the ones above, but for rcc resource symbols specifically. -#define QT_GET_RESOURCE_INIT_SYMBOL(NAME) \ - QT_RCC_MANGLE_NAMESPACE(qInitResources_ ## NAME) - -#define QT_DECLARE_EXTERN_RESOURCE(NAME) \ - QT_DECLARE_EXTERN_SYMBOL_INT(QT_GET_RESOURCE_INIT_SYMBOL(NAME)) - -#define QT_KEEP_RESOURCE(NAME) \ - QT_KEEP_SYMBOL(QT_GET_RESOURCE_INIT_SYMBOL(NAME)) - -#endif // QTSYMBOLMACROS_H - 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 $<TARGET_FILE:helper_lib>) - 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 <QtCore/qtresource.h> -#include <QtTest/QtTest> - -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 |