linking Qt6::BundledZLIB breaks with Emscripten and Conan (Qt6 + cpr/libcurl + Zlib)
-
I am working on a project where I want to build a Qt6 + WebAssembly (Emscripten) application and link it together with a custom library that uses cpr/libcurl (installed via Conan).
my Setup
-
Host: Linux (gcc 13, CMake 3.31, Conan 2.4, CLion 2025.1)
-
Target: WebAssembly (Emscripten 3.1.56, wasm_singlethread)
-
Dependencies via Conan: cpr, libcurl, nlohmann_json, spdlog, zlib
-
GUI layer: Qt6.8.3 (prebuilt wasm_singlethread package from the Qt installer)
The issue
When configuring my project with CMake, Qt’s CMake files insist on looking for Qt6::BundledZLIB. Since my prebuilt Qt6/WASM installation doesn’t ship Qt6BundledZLIBConfig.cmake, I get:
Can't find Qt6::BundledZLIB.
Actually I don’t want to use Qt’s internal Zlib at all. Both cpr/libcurl and Qt’s network module should be able to use the system Zlib provided by Emscripten (
-sUSE_ZLIB=1
, or Conan’sZLIB::ZLIB
target).Linking it directly in my own executable/library causes conflicts: I’d end up with two Zlib implementations in the link (Qt’s bundled one and Emscripten’s system one).
I also set the CMake options:
-DCMAKE_DISABLE_FIND_PACKAGE_Qt6BundledZLIB=ON -DQT_FEATURE_system_zlib=ON -DQT_NO_ZLIB=OFF
Did not help at all.
Is there a recommended way to configure a prebuilt Qt WASM package so that it doesn’t try to pull in Qt6::BundledZLIB, but uses the system Zlib instead?
Thank you
-