Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell Cmake about Qt installation dir without changing PATH?

Tags:

cmake

qt

qmake

In my CMakeLists.txt, I have a call like below

find_package(Qt5 COMPONENTS Gui)

But for above to work, Qt needs to be set in the PATH like below.

export PATH=$PATH:/Path/To/QtInstallationFolder/5.12.5/clang_64/bin

Having Qt in PATH of course works but I don't want to change PATH for every machine that my source code builds in. Is there way to tell Cmake about my Qt Installation Folder without changing PATH on the machine and without changing CMakeLists.txt of my project?

I have tried the following:

export CMAKE_PREFIX_PATH=/Path/To/QtInstallationFolder/5.12.5/clang_64/bin
export CMAKE_FRAMEWORK_PATH=/Path/To/QtInstallationFolder/5.12.5/clang_64/bin
export CMAKE_APPBUNDLE_PATH=/Path/To/QtInstallationFolder/5.12.5/clang_64/bin

But above didn't help.

Environment:.
macOS Catalina
Cmake version 3.18.2 Qt 5.12.5

like image 455
TheWaterProgrammer Avatar asked Sep 06 '25 03:09

TheWaterProgrammer


1 Answers

The reason your export CMAKE_PREFIX_PATH=... didn't work is that you passed the bin subdirectory instead of the installation prefix, as @vre already pointed out in the comments.

Alternatively, you can use -DQt5_ROOT=/Path/To/QtInstallationFolder/5.12.5/clang_64. I personally prefer to use these kind of package specific variables because in CI build scripts you can easily put them on separate lines which then don't become too long.

like image 79
Corristo Avatar answered Sep 09 '25 01:09

Corristo