CMake: Move qml plugin auto inclusion code into a separate macro
The code is moved into a macro without any modifications aside from removing the escaping of variable evaluation and escaping of quotes. It's kept as a macro similar to __qt_internal_include_plugin_packages, because there might be calls to find_package() that set variables in the current scope. The reason for moving is easier maintenance (no more escaping). Pick-to: 6.8 6.9 Change-Id: Ie6ddc26fe4ff8db0134f3542c2886f8b5d68dc51 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
f7b8ff7177
commit
47006aca44
@ -497,67 +497,8 @@ function(qt_internal_create_plugins_auto_inclusion_files)
|
||||
|
||||
if(QT_MODULE STREQUAL "Qml")
|
||||
set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES}
|
||||
# Qml plugin targets might have dependencies on other qml plugin targets, but the Targets.cmake
|
||||
# files are included in the order that file(GLOB) returns, which means certain targets that are
|
||||
# referenced might not have been created yet, and \${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
|
||||
# might be set to a message saying those targets don't exist.
|
||||
#
|
||||
# Postpone checking of which targets don't exist until all Qml PluginConfig.cmake files have been
|
||||
# included, by including all the files one more time and checking for errors at each step.
|
||||
#
|
||||
# TODO: Find a better way to deal with this, perhaps by using find_package() instead of include
|
||||
# for the Qml PluginConfig.cmake files.
|
||||
|
||||
# Distributions should probably change this default.
|
||||
if(NOT DEFINED QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
|
||||
set(QT_SKIP_AUTO_QML_PLUGIN_INCLUSION OFF)
|
||||
endif()
|
||||
|
||||
set(__qt_qml_plugins_config_file_list \"\")
|
||||
set(__qt_qml_plugins_glob_prefixes \"\${CMAKE_CURRENT_LIST_DIR}\")
|
||||
|
||||
# Allow passing additional prefixes where we will glob for PluginConfig.cmake files.
|
||||
if(QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
|
||||
foreach(__qt_qml_plugin_glob_prefix IN LISTS QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
|
||||
if(__qt_qml_plugin_glob_prefix)
|
||||
list(APPEND __qt_qml_plugins_glob_prefixes \"\${__qt_qml_plugin_glob_prefix}\")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES __qt_qml_plugins_glob_prefixes)
|
||||
|
||||
foreach(__qt_qml_plugin_glob_prefix IN LISTS __qt_qml_plugins_glob_prefixes)
|
||||
file(GLOB __qt_qml_plugins_glob_config_file_list
|
||||
\"\${__qt_qml_plugin_glob_prefix}/QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake\")
|
||||
if(__qt_qml_plugins_glob_config_file_list)
|
||||
list(APPEND __qt_qml_plugins_config_file_list \${__qt_qml_plugins_glob_config_file_list})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (__qt_qml_plugins_config_file_list AND NOT QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
|
||||
# First round of inclusions ensure all qml plugin targets are brought into scope.
|
||||
foreach(__qt_qml_plugin_config_file \${__qt_qml_plugins_config_file_list})
|
||||
include(\${__qt_qml_plugin_config_file})
|
||||
|
||||
# Temporarily unset any failure markers and mark the Qml package as found.
|
||||
unset(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
|
||||
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE)
|
||||
endforeach()
|
||||
|
||||
# For the second round of inclusions, check and bail out early if there are errors.
|
||||
foreach(__qt_qml_plugin_config_file \${__qt_qml_plugins_config_file_list})
|
||||
include(\${__qt_qml_plugin_config_file})
|
||||
|
||||
if(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
|
||||
string(APPEND \${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
|
||||
\"\nThe message was set in \${__qt_qml_plugin_config_file} \")
|
||||
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endif()")
|
||||
__qt_internal_include_qml_plugin_packages()
|
||||
")
|
||||
endif()
|
||||
|
||||
get_target_property(module_plugin_types "${QT_MODULE}" MODULE_PLUGIN_TYPES)
|
||||
|
@ -621,3 +621,69 @@ macro(__qt_internal_include_plugin_packages target)
|
||||
set_target_properties(
|
||||
${__qt_${target}_plugin_module_target} PROPERTIES __qt_internal_plugins_added TRUE)
|
||||
endmacro()
|
||||
|
||||
# Include Qt Qml plugin CMake packages that are present under the Qml package directory.
|
||||
# TODO: Consider moving this to qtdeclarative somehow.
|
||||
macro(__qt_internal_include_qml_plugin_packages)
|
||||
# Qml plugin targets might have dependencies on other qml plugin targets, but the Targets.cmake
|
||||
# files are included in the order that file(GLOB) returns, which means certain targets that are
|
||||
# referenced might not have been created yet, and ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
|
||||
# might be set to a message saying those targets don't exist.
|
||||
#
|
||||
# Postpone checking of which targets don't exist until all Qml PluginConfig.cmake files have
|
||||
# been included, by including all the files one more time and checking for errors at each step.
|
||||
#
|
||||
# TODO: Find a better way to deal with this, perhaps by using find_package() instead of include
|
||||
# for the Qml PluginConfig.cmake files.
|
||||
|
||||
# Distributions should probably change this default.
|
||||
if(NOT DEFINED QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
|
||||
set(QT_SKIP_AUTO_QML_PLUGIN_INCLUSION OFF)
|
||||
endif()
|
||||
|
||||
set(__qt_qml_plugins_config_file_list "")
|
||||
set(__qt_qml_plugins_glob_prefixes "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
# Allow passing additional prefixes where we will glob for PluginConfig.cmake files.
|
||||
if(QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
|
||||
foreach(__qt_qml_plugin_glob_prefix IN LISTS QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
|
||||
if(__qt_qml_plugin_glob_prefix)
|
||||
list(APPEND __qt_qml_plugins_glob_prefixes "${__qt_qml_plugin_glob_prefix}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES __qt_qml_plugins_glob_prefixes)
|
||||
|
||||
foreach(__qt_qml_plugin_glob_prefix IN LISTS __qt_qml_plugins_glob_prefixes)
|
||||
file(GLOB __qt_qml_plugins_glob_config_file_list
|
||||
"${__qt_qml_plugin_glob_prefix}/QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake")
|
||||
if(__qt_qml_plugins_glob_config_file_list)
|
||||
list(APPEND __qt_qml_plugins_config_file_list ${__qt_qml_plugins_glob_config_file_list})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (__qt_qml_plugins_config_file_list AND NOT QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
|
||||
# First round of inclusions ensure all qml plugin targets are brought into scope.
|
||||
foreach(__qt_qml_plugin_config_file ${__qt_qml_plugins_config_file_list})
|
||||
include(${__qt_qml_plugin_config_file})
|
||||
|
||||
# Temporarily unset any failure markers and mark the Qml package as found.
|
||||
unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE)
|
||||
endforeach()
|
||||
|
||||
# For the second round of inclusions, check and bail out early if there are errors.
|
||||
foreach(__qt_qml_plugin_config_file ${__qt_qml_plugins_config_file_list})
|
||||
include(${__qt_qml_plugin_config_file})
|
||||
|
||||
if(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
|
||||
string(APPEND ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
|
||||
"\nThe message was set in ${__qt_qml_plugin_config_file} ")
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user