How to select qt location that needs to be used while compiling a project?
-
OS: ubuntu 22.04, qt6
I installed qt6.6.2 at /usr/local/Qt6 by following instructions at https://wiki.qt.io/Building_Qt_6_from_Git.
I also installed qt from synaptic: qt6-base-dev and qt6-base-dev-tools.
Now I try to compile a QT/C++ project which has a CMakelists.txt.
How do I set which qt installation to use for compiling?
cmake seems to be always picking up the custom installation at /usr/local/Qt6 than the one installed by synaptic
I tried the following, but It is still using custom install at /usr/local/Qt6.
- remove custom qt6 installation from cmake search path
list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6/lib/cmake/Qt6") list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6/lib/cmake") list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6")
The error message that I get is:
CMake Warning at /usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package): Could not find a configuration file for package "Qt6CoreTools" that is compatible with requested version "6.6.2". The following configuration files were considered but not accepted: /usr/lib/x86_64-linux-gnu/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake, version: 6.2.4 /lib/x86_64-linux-gnu/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake, version: 6.2.4 Call Stack (most recent call first): /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsDependencies.cmake:9 (find_dependency) /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake:33 (include) /usr/local/Qt6/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:65 (find_package) /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:34 (_qt_internal_find_tool_dependencies) /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include) /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package) CMakeLists.txt:22 (find_package) CMake Warning at /usr/local/Qt6/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:65 (find_package): Found package configuration file: /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake but it set Qt6WidgetsTools_FOUND to FALSE so package "Qt6WidgetsTools" is considered to be NOT FOUND. Reason given by package: Qt6WidgetsTools could not be found because dependency Qt6CoreTools could not be found. Call Stack (most recent call first): /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:34 (_qt_internal_find_tool_dependencies) /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include) /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package) CMakeLists.txt:22 (find_package) CMake Warning at /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package): Found package configuration file: /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered to be NOT FOUND. Reason given by package: Qt6Widgets could not be found because dependency Qt6WidgetsTools could not be found.
So all that cmake searches is the custom installation at /usr/local/Qt6
-
@shome said in How to select qt location that needs to be used while compiling a project?:
How do I set which qt installation to use for compiling?
By specifying the -prefix parameter, see https://doc.qt.io/qt-5/configure-options.html
-
@jsulm from the https://doc.qt.io/qt-5/configure-options.html:
In my understanding, configuring with the prefix option is setting the location for installation when compiling Qt from source.
How would I use it for compiling a QT based project that has a main.cpp and CMakelists.txt? I need to modify CMakeLists.txt to be able to the select the qt6 location. ie either the one installed by synaptic or the custom Qt installed at /usr/local/Qt6
-
@shome Ah, I misread your question.
You need to pass -DCMAKE_PREFIX_PATH=PATH_TO_QT_CMAKE_FOLDER to your cmake call. See https://github.com/KDAB/GammaRay/issues/213