Setting up a .pro file that works for wasm_singlethread and wasm_multithread
-
I'm trying to set up a .pro file that works for both wasm_singlethread and wasm_multithread. But right now it fails on "Qt += concurrent" when using wasm_singlthread, since that module is not available. How can I do this? E.g. is there a separate scope that distinguishes wasm single vs multi? Or a scope block that would otherwise explicitly check if the concurrent module is available?
Thanks
-
QtConcurrent relies on multiple threads. It cannot work with wasm_singlethread. If you want single-threaded code, you need to write single threaded code.
-
Yes, i know. The question is how to set up a project file for qmake so that it will only run the line "Qt += concurrent" if the concurrent module exists.
-
Now I understand a little better what you are asking. I am not sure if there is such a thing as querying if a module exists. I'm also not using wasm and don't know if you can actually distinguish between singlethreaded and multithreaded.
Here is the easiest workaround that comes to mind: Create a
CONFIGvariable likesinglethreaded. Then you can check for it:CONFIG(singlethreaded): { } else: { QT += concurrent }On the "command line" you just add
qmake CONFIG+=singlethreaded ...to your call toqmake. In QtCreator under "Projects" for the wasm_singlethreaded kit you just addCONFIG+=singlethreadedas "Additional arguments" under the qmake build step.