Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMAKE_PREFIX_PATH does not work as expected

Tags:

ubuntu

cmake

qt5

I'm compiling the same Qt/QML application on Windows, Linux, MacOS, WebAssembly, iOS, and Android. So far, I found that detection of Qt's components only works on Windows, regardless whether I'm using it to compile a Windows version or cross-compiling to Android. It doesn't work neither on MacOS nor on Linux.

I tried pointing CMAKE_PREFIX_PATH to Qt's installation prefix (~/Qt/5.15.0/wasm_32/), but it keeps on complaining about QtConfig.cmake. The only alternative I found to work was passing -DQt5_DIR for QtConfig.cmake to be found, but then it would keep on asking for at least 10 more .cmake files which I need to pass their paths one by one using _DIR variables. This way I would always end with a huge command and it's a major source of annoyance.

Note that I do not want to install Qt using apt or any other package manager. I only want to use Qt's installer since it gives me the flexibility of having multiple versions targeting multiple frameworks.

Is it a problem in Qt? CMake? Ubuntu?

Qt: 5.15.0

CMake: 3.18.0

Ubuntu: 20.04

like image 934
Ahmed Avatar asked Sep 19 '25 00:09

Ahmed


1 Answers

Now I'm sure that I found it: The toolchains had this: set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

It doesn't look like setting CMAKE_PREFIX_PATH was enough. I had to do this also: list(APPEND CMAKE_FIND_ROOT_PATH "~/Qt/5.15.0/wasm_32")

like image 168
Ahmed Avatar answered Sep 21 '25 19:09

Ahmed