diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index d35254c48f..c94117dda7 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -272,27 +272,6 @@ function(extend_target target) list(APPEND dbus_sources "${sources}") endforeach() - foreach(dep ${arg_FEATURE_DEPENDENCIES} ${arg_LIBRARIES} ${arg_PUBLIC_LIBRARIES}) - if("${dep}" MATCHES "^Qt::((.+)(Private)|(.+))$") - if (${CMAKE_MATCH_COUNT} EQUAL 3) - set(depTarget ${CMAKE_MATCH_2}) - else() - set(depTarget ${CMAKE_MATCH_4}) - endif() - - # Fetch features from dependencies and make them available to the - # caller as well as to the local scope for configure.cmake evaluation. - if(NOT TARGET "${dep}") - find_package(Qt${PROJECT_VERSION_MAJOR}${depTarget} REQUIRED) - endif() - - if("x${CMAKE_MATCH_3}" STREQUAL "xPrivate") - qt_pull_features_into_current_scope(PRIVATE_FEATURES "Qt::${depTarget}") - endif() - qt_pull_features_into_current_scope(PUBLIC_FEATURES "Qt::${depTarget}") - endif() - endforeach() - set_target_properties("${target}" PROPERTIES AUTOMOC ON AUTOMOC_EXECUTABLE "$" @@ -309,8 +288,6 @@ function(extend_target target) target_include_directories("${target}" PUBLIC ${arg_PUBLIC_INCLUDE_DIRECTORIES} PRIVATE ${arg_INCLUDE_DIRECTORIES}) target_compile_definitions("${target}" PUBLIC ${arg_PUBLIC_DEFINES} PRIVATE ${arg_DEFINES}) target_link_libraries("${target}" PUBLIC ${arg_PUBLIC_LIBRARIES} PRIVATE ${arg_LIBRARIES}) - - qt_push_features_into_parent_scope() endif() endfunction() @@ -545,8 +522,6 @@ function(add_qt_module target) $ $ ) - - qt_push_features_into_parent_scope() endfunction() @@ -611,8 +586,6 @@ function(add_qt_plugin target) endif() qt_internal_add_linker_version_script(${target}) - - qt_push_features_into_parent_scope() endfunction() @@ -645,8 +618,6 @@ function(add_qt_executable name) WIN32_EXECUTABLE "${arg_GUI}" MACOSX_BUNDLE "${arg_GUI}" ) - - qt_push_features_into_parent_scope() endfunction() @@ -671,8 +642,6 @@ function(add_qt_test name) set_tests_properties("${name}" PROPERTIES RUN_SERIAL "${arg_RUN_SERIAL}") set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "PATH=${path}${QT_PATH_SEPARATOR}${CMAKE_CURRENT_BINARY_DIR}${QT_PATH_SEPARATOR}$ENV{PATH}") set_property(TEST "${name}" APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}") - - qt_push_features_into_parent_scope() endfunction() @@ -680,7 +649,6 @@ endfunction() # tests launch separate programs to test certainly input/output behavior. function(add_qt_test_helper name) add_qt_executable("${name}" OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ${ARGN}) - qt_push_features_into_parent_scope() endfunction() @@ -706,7 +674,6 @@ function(add_qt_tool name) qt_internal_add_target_aliases("${name}") install(TARGETS "${name}" EXPORT "Qt${PROJECT_VERSION_MAJOR}ToolsTargets" DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS}) - qt_push_features_into_parent_scope() endfunction() diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 7b8f11e896..aa18b380a6 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -180,7 +180,10 @@ macro(qt_feature_set_value feature cache emit_if condition label) message(SEND_ERROR "Feature \"${feature}\": Forcing to \"${cache}\" breaks its condition.") endif() - set(QT_FEATURE_${feature} "${result}" PARENT_SCOPE) + if (DEFINED "QT_FEATURE_${feature}") + message(FATAL_ERROR "Feature ${feature} is already defined when evaluating configure.cmake features for ${target}.") + endif() + set(QT_FEATURE_${feature} "${result}" CACHE INTERNAL "Qt feature: ${feature}") endmacro() function(qt_evaluate_feature feature) @@ -379,8 +382,6 @@ function(qt_feature_module_end target) unset(__QtFeature_private_extra PARENT_SCOPE) unset(__QtFeature_public_extra PARENT_SCOPE) - - qt_push_features_into_parent_scope() endfunction() function(qt_config_compile_test name) @@ -400,55 +401,35 @@ function(qt_config_compile_test_x86simd extension label) set(TEST_subarch_${extension} "${TEST_X86SIMD_${extension}}" CACHE INTERNAL "${label}" ) endfunction() -function(qt_pull_features_into_current_scope) - cmake_parse_arguments(arg "PUBLIC_FEATURES;PRIVATE_FEATURES" "" "" ${ARGN}) - foreach(target IN ITEMS ${arg_UNPARSED_ARGUMENTS}) - if(NOT "${target}" MATCHES "^Qt::[a-zA-z][a-zA-Z0-9_]*$") - message(FATAL_ERROR "${target} does not match Qt::[a-zA-z][a-zA-Z0-9_]*. INVALID NAME.") - endif() - if(NOT TARGET ${target}) - message(FATAL_ERROR "${target} not found.") - endif() +function(qt_make_features_available target) + if(NOT "${target}" MATCHES "^Qt::[a-zA-z][a-zA-Z0-9_]*$") + message(FATAL_ERROR "${target} does not match Qt::[a-zA-z][a-zA-Z0-9_]*. INVALID NAME.") + endif() + if(NOT TARGET ${target}) + message(FATAL_ERROR "${target} not found.") + endif() - get_target_property(target_type "${target}" TYPE) - if("${target_type}" STREQUAL "INTERFACE_LIBRARY") - set(property_prefix "INTERFACE_") - else() - set(property_prefix "") - endif() - foreach(visibility IN ITEMS PUBLIC PRIVATE) - if(NOT ${arg_${visibility}_FEATURES}) + get_target_property(target_type "${target}" TYPE) + if("${target_type}" STREQUAL "INTERFACE_LIBRARY") + set(property_prefix "INTERFACE_") + else() + set(property_prefix "") + endif() + foreach(visibility IN ITEMS PUBLIC PRIVATE) + set(value ON) + foreach(state IN ITEMS ENABLED DISABLED) + get_target_property(features "${target}" ${property_prefix}QT_${state}_${visibility}_FEATURES) + if("${features}" STREQUAL "features-NOTFOUND") continue() endif() - - set(value ON) - foreach(state IN ITEMS ENABLED DISABLED) - get_target_property(features "${target}" ${property_prefix}QT_${state}_${visibility}_FEATURES) - if("${features}" STREQUAL "features-NOTFOUND") - continue() + foreach(feature IN ITEMS ${features}) + if (DEFINED "QT_FEATURE_${feature}") + message(FATAL_ERROR "Feature ${feature} is already defined when importing features from ${target}.") endif() - foreach(feature IN ITEMS ${features}) - set(QT_FEATURE_${feature} ${value} PARENT_SCOPE) - endforeach() - set(value OFF) + set(QT_FEATURE_${feature} "${value}" CACHE INTERNAL "Qt feature: ${feature}") endforeach() + set(value OFF) endforeach() endforeach() endfunction() -macro(qt_push_features_into_parent_scope) - get_cmake_property(_variableNames VARIABLES) - - foreach(_var IN ITEMS ${_variableNames}) - if(_var MATCHES "^QT_FEATURE_[a-z][a-z0-9_]*$") - set("${_var}" "${${_var}}" PARENT_SCOPE) - endif() - endforeach() -endmacro() - -macro(qt_load_global_features) - if(NOT TARGET Qt::GlobalConfig) - find_package(Qt${PROJECT_VERSION_MAJOR}GlobalConfig QUIET) - endif() - qt_pull_features_into_current_scope(PUBLIC_FEATURES PRIVATE_FEATURES Qt::GlobalConfig) -endmacro() diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in index 32f30fed7e..e08c4ff87f 100644 --- a/cmake/QtModuleConfig.cmake.in +++ b/cmake/QtModuleConfig.cmake.in @@ -2,8 +2,12 @@ find_package(Qt@PROJECT_VERSION_MAJOR@ QUIET) -include("${CMAKE_CURRENT_LIST_DIR}/@versioned_module_name@Targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@module_versioned@Targets.cmake") -if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/@versioned_module_name@Macros.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/@versioned_module_name@Macros.cmake") +if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/@module_versioned@Macros.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/@module_versioned@Macros.cmake") endif() + +include QtFeature + +qt_make_features_available(Qt::@module@) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 375b102f58..503d7717fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,7 +58,6 @@ add_subdirectory(tools) if(QT_FEATURE_gui) add_subdirectory(gui) - qt_pull_features_into_current_scope(PUBLIC_FEATURES Qt::Gui) if(QT_FEATURE_widgets) add_subdirectory(widgets) if(QT_FEATURE_opengl) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index dd2b101689..81ef8b1b66 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -6,8 +6,6 @@ find_library(FWCoreGraphics CoreGraphics) ## Gui Module: ##################################################################### -qt_load_global_features() - if (QT_FEATURE_gui) if (WINRT) set(_default_platform "winrt") diff --git a/src/platformsupport/CMakeLists.txt b/src/platformsupport/CMakeLists.txt index c571f940c8..e298eb4bc5 100644 --- a/src/platformsupport/CMakeLists.txt +++ b/src/platformsupport/CMakeLists.txt @@ -1,6 +1,5 @@ # Generated from platformsupport.pro. -qt_pull_features_into_current_scope(PRIVATE_FEATURES Qt::Gui) add_subdirectory(themes) add_subdirectory(edid) add_subdirectory(eventdispatchers) diff --git a/src/plugins/platforms/CMakeLists.txt b/src/plugins/platforms/CMakeLists.txt index f0ac297d17..0a01b80bc8 100644 --- a/src/plugins/platforms/CMakeLists.txt +++ b/src/plugins/platforms/CMakeLists.txt @@ -1,5 +1,3 @@ -qt_pull_features_into_current_scope(PRIVATE_FEATURES Qt::Gui) - if(QT_FEATURE_xcb) add_subdirectory(xcb) endif() diff --git a/tests/auto/printsupport/CMakeLists.txt b/tests/auto/printsupport/CMakeLists.txt index 3908a297dd..791d6e4807 100644 --- a/tests/auto/printsupport/CMakeLists.txt +++ b/tests/auto/printsupport/CMakeLists.txt @@ -1,5 +1,2 @@ -# Generated from printsupport.pro. - -qt_pull_features_into_current_scope(PUBLIC_FEATURES Qt::PrintSupport) add_subdirectory(dialogs) add_subdirectory(kernel) diff --git a/tests/auto/widgets/widgets/qmdiarea/CMakeLists.txt b/tests/auto/widgets/widgets/qmdiarea/CMakeLists.txt index b14730c588..ca3bf2afa1 100644 --- a/tests/auto/widgets/widgets/qmdiarea/CMakeLists.txt +++ b/tests/auto/widgets/widgets/qmdiarea/CMakeLists.txt @@ -1,5 +1,3 @@ -qt_pull_features_into_current_scope(PUBLIC_FEATURES Qt::Gui) - add_qt_test("tst_qmdiarea" RUN_SERIAL SOURCES tst_qmdiarea.cpp DEFINES QT_NO_CAST_TO_ASCII @@ -10,5 +8,4 @@ add_qt_test("tst_qmdiarea" RUN_SERIAL SOURCES tst_qmdiarea.cpp ) extend_target("tst_qmdiarea" CONDITION TARGET Qt::OpenGL LIBRARIES Qt::OpenGL) - extend_target("tst_qmdiarea" CONDITION APPLE_OSX LIBRARIES FWSecurity) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index a1c73fcd5f..80a10bd944 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -823,23 +823,9 @@ def handle_app_or_lib(scope: Scope, cm_fh: typing.IO[str], *, scope.currentdir()))) -def handle_qt_for_config(scope: Scope, cm_fh: typing.IO[str], *, - indent: int = 0) -> None: - for config in scope.get("QT_FOR_CONFIG") or []: - lib = map_qt_library(config) - if lib.endswith("Private"): - cm_fh.write('{}qt_pull_features_into_current_scope' - '(PRIVATE_FEATURES {})\n' - .format(spaces(indent), lib[:-len("Private")])) - else: - cm_fh.write('{}qt_pull_features_into_current_scope' - '(PUBLIC_FEATURES {})\n'.format(spaces(indent), lib)) - - def cmakeify_scope(scope: Scope, cm_fh: typing.IO[str], *, indent: int = 0) -> None: template = scope.getTemplate() - handle_qt_for_config(scope, cm_fh) if template == 'subdirs': handle_subdir(scope, cm_fh, indent=indent) elif template in ('app', 'lib'):