Repository: conan-io/conan-center-index

Issue:
[package] qt/6.x.x: Missing QmlImportScanner component
The QmlImportScanner target (which looks like an alias to Qt6Qml to me) is missing, leading to failed builds if they rely on it.


Discussion:
we already declare [`qmlimportscanner`](https://github.com/conan-io/conan-center-index/blob/master/recipes/qt/6.x.x/conanfile.py#L555). Do we miss an alias with different casing ? Do you think it's the same for all the other targets declared in https://github.com/conan-io/conan-center-index/blob/master/recipes/qt/6.x.x/conanfile.py#L543-L556 ?
Will check I think it is casing indeed.

Resolving patch:
diff --git a/recipes/qt/6.x.x/conanfile.py b/recipes/qt/6.x.x/conanfile.py
--- a/recipes/qt/6.x.x/conanfile.py
+++ b/recipes/qt/6.x.x/conanfile.py
@@ -518,6 +518,9 @@ def build(self):
     def _cmake_executables_file(self):
         return os.path.join("lib", "cmake", "Qt6Core", "conan_qt_executables_variables.cmake")
 
+    def _cmake_qt6_private_file(self, module):
+        return os.path.join("lib", "cmake", "Qt6{0}".format(module), "conan_qt_qt6_{0}private.cmake".format(module.lower()))
+
     def package(self):
         cmake = self._configure_cmake()
         cmake.install()
@@ -569,7 +572,31 @@ def package(self):
                 endif()
                 """.format(target, extension))
         tools.save(os.path.join(self.package_folder, self._cmake_executables_file), filecontents)
-
+        
+        def _create_private_module(module, dependencies=[]):
+            dependencies_string = ';'.join('Qt6::%s' % dependency for dependency in dependencies)
+            contents = textwrap.dedent("""\
+            if(NOT TARGET Qt6::{0}Private)
+                add_library(Qt6::{0}Private INTERFACE IMPORTED)
+
+                set_target_properties(Qt6::{0}Private PROPERTIES
+                    INTERFACE_INCLUDE_DIRECTORIES "${{CMAKE_CURRENT_LIST_DIR}}/../../../include/Qt{0}/{1};${{CMAKE_CURRENT_LIST_DIR}}/../../../include/Qt{0}/{1}/Qt{0}"
+                    INTERFACE_LINK_LIBRARIES "{2}"
+                )
+                
+                add_library(Qt::{0}Private INTERFACE IMPORTED)
+                set_target_properties(Qt::{0}Private PROPERTIES
+                    INTERFACE_LINK_LIBRARIES "Qt6::{0}Private"
+                    _qt_is_versionless_target "TRUE"
+                )
+            endif()""".format(module, self.version, dependencies_string))
+            
+            tools.save(os.path.join(self.package_folder, self._cmake_qt6_private_file(module)), contents)
+
+        _create_private_module("Core", ["Core"])
+        
+        if self.options.qtdeclarative:
+            _create_private_module("Qml", ["CorePrivate", "Qml"])
 
     def package_id(self):
         del self.info.options.cross_compile
@@ -679,6 +706,8 @@ def _create_plugin(pluginname, libname, type, requires):
 
         if self.options.qtdeclarative:
             _create_module("Qml", ["Network"])
+            self.cpp_info.components["qtQml"].build_modules["cmake_find_package"].append(self._cmake_qt6_private_file("Qml"))
+            self.cpp_info.components["qtQml"].build_modules["cmake_find_package_multi"].append(self._cmake_qt6_private_file("Qml"))
             _create_module("QmlModels", ["Qml"])
             self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package"] = "QmlImportScanner" # this is an alias for Qml and there to integrate with existing consumers
             self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package_multi"] = "QmlImportScanner"
@@ -740,6 +769,8 @@ def _create_plugin(pluginname, libname, type, requires):
         self.cpp_info.components["qtCore"].builddirs.append(os.path.join("res","archdatadir","bin"))
         self.cpp_info.components["qtCore"].build_modules["cmake_find_package"].append(self._cmake_executables_file)
         self.cpp_info.components["qtCore"].build_modules["cmake_find_package_multi"].append(self._cmake_executables_file)
+        self.cpp_info.components["qtCore"].build_modules["cmake_find_package"].append(self._cmake_qt6_private_file("Core"))
+        self.cpp_info.components["qtCore"].build_modules["cmake_find_package_multi"].append(self._cmake_qt6_private_file("Core"))
 
         for m in os.listdir(os.path.join("lib", "cmake")):
             module = os.path.join("lib", "cmake", m, "%sMacros.cmake" % m)


Test patch: