Repository: conan-io/conan-center-index

Issue:
[question] how to use CCI qt recipe? 
<!-- What is your question? Please be as specific as possible! -->
I am currently using an old qt recipe qt/5.15.2@bincrafters/stable and I would like to switch to qt/5.15.2.
here is how I am going to use new recipe, based on what I have seen in test_package:
```
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Gui REQUIRED)
-find_package(Qt5Network REQUIRED)
-find_package(Qt5OpenGL REQUIRED)
-find_package(Qt5Concurrent REQUIRED)
+find_package(qt REQUIRED CONFIG)

 set(LIBS
-  ${Qt5Widgets_LIBRARIES}
-  ${Qt5Gui_LIBRARIES}
-  ${Qt5Network_LIBRARIES}
-  ${Qt5OpenGL_LIBRARIES}
-  ${Qt5Concurrent_LIBRARIES}
+  qt::qt
 )

target_link_libraries(${PROJECT_NAME} ${LIBS})
```

I am still getting an error:
```
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /home/andrei/sources/build_studio_clang_vulkan
-- Conan: Compiler Clang>=8, checking major version 10
-- Conan: Checking correct version: 10
CMake Error at CMakeLists.txt:96 (find_package):
  Could not find a package configuration file provided by "qt" with any of
  the following names:

    qtConfig.cmake
    qt-config.cmake

  Add the installation prefix of "qt" to CMAKE_PREFIX_PATH or set "qt_DIR" to
  a directory containing one of the above files.  If "qt" provides a separate
  development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/home/andrei/sources/build_studio_clang_vulkan/CMakeFiles/CMakeOutput.log".
```

What I am doing wrong here?


Discussion:
your conanfile is probably missing the `cmake_find_package_multi` generator ?
Yes, it is missing. But when I have added it, nothing changed... 
Wait. It helped, it fails somewhere else now. Thank you!
It is now failing while linking... maybe you have a hint for me?

```
...
[100%] Linking CXX executable bin/PictofitStudio
/usr/bin/ld: /home/andrei/.conan/data/qt/5.15.2/_/_/package/44c5573505e7976c7c5e4a0a2cfedf9f1678964c/lib/libQt5Gui.a(qopenglpaintengine.o): in function `QOpenGL2PaintEngineExPrivate::drawPixmapFragments(QPainter::PixmapFragment const*, int, QPixmap const&, QFlags<QPainter::PixmapFragmentHint>)':
qopenglpaintengine.cpp:(.text._ZN28QOpenGL2PaintEngineExPrivate19drawPixmapFragmentsEPKN8QPainter14PixmapFragmentEiRK7QPixmap6QFlagsINS0_18PixmapFragmentHintEE+0x129): undefined reference to `qt_sine_table'
/usr/bin/ld: /home/andrei/.conan/data/qt/5.15.2/_/_/package/44c5573505e7976c7c5e4a0a2cfedf9f1678964c/lib/libQt5Gui.a(qtriangulatingstroker.o): in function `QTriangulatingStroker::process(QVectorPath const&, QPen const&, QRectF const&, QFlags<QPainter::RenderHint>)':
qtriangulatingstroker.cpp:(.text._ZN21QTriangulatingStroker7processERK11QVectorPathRK4QPenRK6QRectF6QFlagsIN8QPainter10RenderHintEE+0x261): undefined reference to `qt_sine_table'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/PictofitStudio.dir/build.make:6359: bin/PictofitStudio] Error 1
make[1]: *** [CMakeFiles/Makefile2:77: CMakeFiles/PictofitStudio.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
```

as I understand, I should not include/link additional qt modules separately in CMake, right?
And here what I've got for Mac:
```
[100%] Linking CXX executable bin/PictofitStudio
Undefined symbols for architecture x86_64:
  "_SCDynamicStoreCopyProxies", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_SCNetworkReachabilityCreateWithAddress", referenced from:
      QNetworkConnectionMonitor::setTargets(QHostAddress const&, QHostAddress const&) in libQt5Network.a(qnetconmonitor_darwin.o)
  "_SCNetworkReachabilityCreateWithAddressPair", referenced from:
      QNetworkConnectionMonitor::setTargets(QHostAddress const&, QHostAddress const&) in libQt5Network.a(qnetconmonitor_darwin.o)
  "_SCNetworkReachabilityGetFlags", referenced from:
      QNetworkConnectionMonitor::setTargets(QHostAddress const&, QHostAddress const&) in libQt5Network.a(qnetconmonitor_darwin.o)
  "_SCNetworkReachabilitySetCallback", referenced from:
      QNetworkConnectionMonitor::~QNetworkConnectionMonitor() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkConnectionMonitor::stopMonitoring() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkConnectionMonitor::startMonitoring() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkStatusMonitor::~QNetworkStatusMonitor() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkStatusMonitor::stop() in libQt5Network.a(qnetconmonitor_darwin.o)
  "_SCNetworkReachabilitySetDispatchQueue", referenced from:
      QNetworkConnectionMonitor::~QNetworkConnectionMonitor() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkConnectionMonitor::stopMonitoring() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkConnectionMonitor::startMonitoring() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkStatusMonitor::~QNetworkStatusMonitor() in libQt5Network.a(qnetconmonitor_darwin.o)
      QNetworkStatusMonitor::stop() in libQt5Network.a(qnetconmonitor_darwin.o)
  "___gss_c_nt_hostbased_service_oid_desc", referenced from:
      qGSsapiGetServiceName(QString const&) in libQt5Network.a(qauthenticator.o)
  "_gss_acquire_cred", referenced from:
      QAuthenticatorPrivate::parseHttpResponse(QList<QPair<QByteArray, QByteArray> > const&, bool, QString const&) in libQt5Network.a(qauthenticator.o)
  "_gss_delete_sec_context", referenced from:
      qGssapiContinue(QAuthenticatorPrivate*, QByteArray const&) in libQt5Network.a(qauthenticator.o)
  "_gss_display_status", referenced from:
      q_GSSAPI_error_int(char const*, unsigned int, int) in libQt5Network.a(qauthenticator.o)
  "_gss_import_name", referenced from:
      qGSsapiGetServiceName(QString const&) in libQt5Network.a(qauthenticator.o)
  "_gss_init_sec_context", referenced from:
      qGssapiContinue(QAuthenticatorPrivate*, QByteArray const&) in libQt5Network.a(qauthenticator.o)
  "_gss_release_buffer", referenced from:
      qGssapiContinue(QAuthenticatorPrivate*, QByteArray const&) in libQt5Network.a(qauthenticator.o)
      q_GSSAPI_error_int(char const*, unsigned int, int) in libQt5Network.a(qauthenticator.o)
  "_gss_release_cred", referenced from:
      QAuthenticatorPrivate::parseHttpResponse(QList<QPair<QByteArray, QByteArray> > const&, bool, QString const&) in libQt5Network.a(qauthenticator.o)
  "_gss_release_name", referenced from:
      QAuthenticatorPrivate::parseHttpResponse(QList<QPair<QByteArray, QByteArray> > const&, bool, QString const&) in libQt5Network.a(qauthenticator.o)
      qGssapiContinue(QAuthenticatorPrivate*, QByteArray const&) in libQt5Network.a(qauthenticator.o)
  "_kSCPropNetProxiesExceptionsList", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesExcludeSimpleHostnames", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesFTPEnable", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesFTPPort", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesFTPProxy", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesHTTPEnable", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesHTTPPort", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesHTTPProxy", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesHTTPSEnable", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesHTTPSPort", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesHTTPSProxy", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesProxyAutoConfigEnable", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesProxyAutoConfigURLString", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesSOCKSEnable", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesSOCKSPort", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
  "_kSCPropNetProxiesSOCKSProxy", referenced from:
      macQueryInternal(QNetworkProxyQuery const&) in libQt5Network.a(qnetworkproxy_mac.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/PictofitStudio] Error 1
make[1]: *** [CMakeFiles/PictofitStudio.dir/all] Error 2
make: *** [all] Error 2
```
I am working through a similar use case (and problems). Today, I see that the test package uses a combination of cmake and cmake_find_package_multi generators with this sequence of cmake commands:

```
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_set_vs_runtime()
conan_set_libcxx()
conan_output_dirs_setup()

# Find the QtWidgets library
find_package(qt REQUIRED CONFIG)

# Tell CMake to create the helloworld executable
add_executable(helloworld main.cpp mainwindow.cpp mainwindow.ui resources.qrc)

target_link_libraries(helloworld PRIVATE qt::qt)
```

Notice there is no conan_basic_setup(), but there are three other conan commands. I am on Windows and it links properly, but I cannot get it to execute (well I can when not using conan ;). I think the problem is getting all the appropriate libraries "installed" into the same directory, but unfortunately [import] does not appear to work for the qt recipe. All I get is libEGL and libGLESv2 -- no qt DLLs.
I'll do some extensive tests to compile all qt examples on various platforms, and I'll fix what I can find.
Regarding the deployment, the recommended way is to use windeployqt (you will need to enable option qt:qttools=True)
I've been trying this recipe, I can compile and execute (very straightforward), but the result is unexpected: all leters together in labels and buttons. I get the same result in MacOS and Linux 😕 

![image](https://user-images.githubusercontent.com/1406456/118138815-09f8c080-b407-11eb-94f7-23f016c586e2.png)

Probably it is something I'm missing when using this recipe.


I can reproduce this on windows too. It seems to be a consequence of the desactivation of harfbuzz. I'll try to see if we can re-enable it

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
@@ -97,7 +97,7 @@ class QtConan(ConanFile):
         "with_freetype": True,
         "with_fontconfig": True,
         "with_icu": True,
-        "with_harfbuzz": False,
+        "with_harfbuzz": True,
         "with_libjpeg": False,
         "with_libpng": True,
         "with_sqlite3": True,
@@ -125,7 +125,7 @@ def export(self):
         self.copy("qtmodules%s.conf" % self.version)
 
     def build_requirements(self):
-        self.build_requires("cmake/3.20.0")
+        self.build_requires("cmake/3.20.2")
         self.build_requires("ninja/1.10.2")
         self.build_requires('pkgconf/1.7.3')
         if self.settings.compiler == "Visual Studio":
@@ -480,8 +480,12 @@ def _configure_cmake(self):
         try:
             self._cmake.configure(source_folder="qt6")
         except:
-            self.output.info(tools.load(os.path.join(self.build_folder, "CMakeFiles", "CMakeError.log")))
-            self.output.info(tools.load(os.path.join(self.build_folder, "CMakeFiles", "CMakeOutput.log")))
+            cmake_err_log = os.path.join(self.build_folder, "CMakeFiles", "CMakeError.log")
+            cmake_out_log = os.path.join(self.build_folder, "CMakeFiles", "CMakeOutput.log")
+            if (os.path.isfile(cmake_err_log)):
+                self.output.info(tools.load(cmake_err_log))
+            if (os.path.isfile(cmake_out_log)):
+                self.output.info(tools.load(cmake_out_log))
             raise
         return self._cmake
 
@@ -771,6 +775,7 @@ def _create_plugin(pluginname, libname, type, requires):
             _create_module("WaylandClient", ["Gui", "wayland::wayland-client"])
             _create_module("WaylandCompositor", ["Gui", "wayland::wayland-server"])
 
+        self.cpp_info.components["qtCore"].cxxflags.append("-fPIC")
 
         if not self.options.shared:
             if self.settings.os == "Windows":
@@ -786,6 +791,8 @@ def _create_plugin(pluginname, libname, type, requires):
                 self.cpp_info.components["qtCore"].frameworks.append("IOKit")     # qtcore requires "_IORegistryEntryCreateCFProperty", "_IOServiceGetMatchingService" and much more which are in "IOKit" framework
                 self.cpp_info.components["qtCore"].frameworks.append("Cocoa")     # qtcore requires "_OBJC_CLASS_$_NSApplication" and more, which are in "Cocoa" framework
                 self.cpp_info.components["qtCore"].frameworks.append("Security")  # qtcore requires "_SecRequirementCreateWithString" and more, which are in "Security" framework
+                self.cpp_info.components["qtNetwork"].frameworks.append("SystemConfiguration")
+                self.cpp_info.components["qtNetwork"].frameworks.append("GSS")
 
         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)


Test patch:
diff --git a/recipes/qt/6.x.x/test_package/CMakeLists.txt b/recipes/qt/6.x.x/test_package/CMakeLists.txt
--- a/recipes/qt/6.x.x/test_package/CMakeLists.txt
+++ b/recipes/qt/6.x.x/test_package/CMakeLists.txt
@@ -14,7 +14,5 @@ set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
 
 add_executable(${PROJECT_NAME} test_package.cpp greeter.h example.qrc)
-# Must compile with "-fPIC" since Qt was built with -reduce-relocations.
-target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
 
 target_link_libraries(${PROJECT_NAME} Qt6::Core)