Skip to content
Advertisement

CMAKE_PREFIX_PATH for Qt5

I want to compile this which requires Qt 5.14 and I have Qt 5.12 installed from my linux repository.I just compiled Qt from source and installed it in /usr/local/Qt-6.0.0/(default location).
But CMake prints the following error although I’ve added set(CMAKE_PREFIX_PATH "/usr/local/Qt-6.0.0/include") and/or set(CMAKE_PREFIX_PATH "/usr/local/Qt-6.0.0/") :

The following configuration files were considered but not accepted:

/usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake, version: 5.12.8
/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake, version: 5.12.8

Advertisement

Answer

Since it has solved your question, I am just going to put it as an answer here. I will improve this section more in detail later.

If you are using cmake use find_package to find the package and then link to your binary in later stage.

In order for find_package to be successful, Qt 5 must be found below the
CMAKE_PREFIX_PATH, or the Qt5_DIR must be set in the CMake cache to the 
location   of the Qt5Config.cmake file. The easiest way to use CMake is to set the
CMAKE_PREFIX_PATH environment variable to the install prefix of Qt 5.

If you just want to find the Qt modules then just set the Qt5_DIR
ex: Qt5_DIR="/Users/bob/Qt/5.12.7/clang_64/lib/cmake/Qt5"

when building with CMake you can use Qt5_DIR or CMAKE_PREFIX_PATH, both should work.

More explanation about building with CMake can be found here

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement