Reputation: 9216
I am adding QT like this:
find_package(Qt5 COMPONENTS Core Quick REQUIRED)
...
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Quick ${OpenCV_LIBS})
but cmake finds some python artifacts instead of expected C:\QT...
How can I change this? Tried to find some examples, but didn't find any clear instruction, which subfolder of C:\QT\ I should specify (any where).
Upvotes: 11
Views: 20528
Reputation: 5675
find_package
search order is following:
CMAKE_PREFIX_PATH
, CMAKE_FRAMEWORK_PATH
, CMAKE_APPBUNDLE_PATH
<package>_DIR
, CMAKE_PREFIX_PATH
, CMAKE_FRAMEWORK_PATH
, CMAKE_APPBUNDLE_PATH
.HINTS
option.PATH
environment variable.With that in mind there are several ways to provide a proper version to QT:
QTDIR
). And use it in the CMake files:
set(CMAKE_PREFIX_PATH "$ENV{QTDIR}")
find_package(Qt5 HINTS "$ENV{QTDIR}" COMPONENTS Core Quick REQUIRED)
Qt5_DIR
pointing to the proper version of QT. Then no additional changes to CMake files are required.PATH
environment variable, for example, for windows C:\Qt\Qt5.10.1\5.10.1\msvc2017_64
Upvotes: 14
Reputation: 9216
My workaround was to put desired QT to the top of PATH variable. It has to be in PATH if you want CMAKE to find it.
Upvotes: 2
Reputation:
You can set click the Add Entry
button in CMake Gui and add a new variable called Qt5_DIR
, select its type as PATH
and its value to something like C:\Qt\5.11.0\msvc2017_64\lib\cmake\Qt5
where 5.11.0
is the Qt version. This folder must contain Qt5Config.cmake
that CMake needs to set things up correctly.
Upvotes: 5