Repository: conan-io/conan-center-index

Issue:
[package] qt/all: generated pkg_config files incompatibles with meson
### Description

When used with the pkgconfig generator, the qt recipe generates qt.pc, qt-qtCore.pc, etc.
However, when used with meson build system, meson requires the pkg_config files to follow the usual naming: qt5.pc, Qt5Core.pc, etc.
It also requires some variables to be set, in order to find the associated executables: `host_bins` and `exec_prefix` for qt5, `bindir`, `libexecdir` and `exec_prefix` for qt6.

### Package and Environment Details

not relevant

### Conan profile

not relevant

### Steps to reproduce

- install qt package (version 5 or 6), generate pkgconfig and meson toolchain files.
- With meson:

```
qt5 = import('qt5')
qt5.has_tools(required: true)
```

### Logs

```
Detecting Qt5 tools
Pkg-config binary for 1 is cached.
Determining dependency 'Qt5Core' with pkg-config executable 'C:\\ProgramData\\chocolatey\\bin\\pkg-config.EXE'
env[PKG_CONFIG_PATH]: C:/env/***
Called `C:\ProgramData\chocolatey\bin\pkg-config.EXE --modversion Qt5Core` -> 1
stderr:
Package Qt5Core was not found in the pkg-config search path.
Perhaps you should add the directory containing `Qt5Core.pc'
to the PKG_CONFIG_PATH environment variable
No package 'Qt5Core' found
```


Discussion:

Resolving patch:
diff --git a/recipes/qt/5.x.x/conanfile.py b/recipes/qt/5.x.x/conanfile.py
--- a/recipes/qt/5.x.x/conanfile.py
+++ b/recipes/qt/5.x.x/conanfile.py
@@ -954,6 +954,7 @@ def _create_private_module(module, dependencies=[]):
 
     def package_info(self):
         self.cpp_info.set_property("cmake_file_name", "Qt5")
+        self.cpp_info.set_property("pkg_config_name", "qt5")
 
         self.cpp_info.names["cmake_find_package"] = "Qt5"
         self.cpp_info.names["cmake_find_package_multi"] = "Qt5"
@@ -992,6 +993,7 @@ def _create_module(module, requires=[], has_include_dir=True):
             componentname = f"qt{module}"
             assert componentname not in self.cpp_info.components, f"Module {module} already present in self.cpp_info.components"
             self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{module}")
+            self.cpp_info.components[componentname].set_property("pkg_config_name", f"Qt5{module}")
             self.cpp_info.components[componentname].names["cmake_find_package"] = module
             self.cpp_info.components[componentname].names["cmake_find_package_multi"] = module
             if module.endswith("Private"):
@@ -1033,6 +1035,12 @@ def _create_plugin(pluginname, libname, plugintype, requires):
             core_reqs.append("glib::glib-2.0")
 
         _create_module("Core", core_reqs)
+        pkg_config_vars = [
+            "host_bins=${prefix}/bin",
+            "exec_prefix=${prefix}",
+        ]
+        self.cpp_info.components["qtCore"].set_property("pkg_config_custom_content", "\n".join(pkg_config_vars))
+        
         if self.settings.os == "Windows":
             module = "WinMain"
             componentname = f"qt{module}"
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
@@ -954,6 +954,7 @@ def _has_positioning(self):
 
     def package_info(self):
         self.cpp_info.set_property("cmake_file_name", "Qt6")
+        self.cpp_info.set_property("pkg_config_name", "qt6")
 
         self.cpp_info.names["cmake_find_package"] = "Qt6"
         self.cpp_info.names["cmake_find_package_multi"] = "Qt6"
@@ -994,6 +995,7 @@ def _create_module(module, requires, has_include_dir=True):
             componentname = f"qt{module}"
             assert componentname not in self.cpp_info.components, f"Module {module} already present in self.cpp_info.components"
             self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt6::{module}")
+            self.cpp_info.components[componentname].set_property("pkg_config_name", f"Qt6{module}")
             self.cpp_info.components[componentname].names["cmake_find_package"] = module
             self.cpp_info.components[componentname].names["cmake_find_package_multi"] = module
             if module.endswith("Private"):
@@ -1035,6 +1037,13 @@ def _create_plugin(pluginname, libname, plugintype, requires):
             core_reqs.append("glib::glib")
 
         _create_module("Core", core_reqs)
+        pkg_config_vars = [
+            "bindir=${prefix}/bin",
+            "libexecdir=${prefix}/bin",
+            "exec_prefix=${prefix}",
+        ]
+        self.cpp_info.components["qtCore"].set_property("pkg_config_custom_content", "\n".join(pkg_config_vars))
+
         if self.settings.os == "Windows":
             if Version(self.version) >= "6.3.0":
                 self.cpp_info.components["qtCore"].system_libs.append("authz")


Test patch: