vscode-qt-tools
vscode-qt-tools copied to clipboard
[question] What is the mechanism of `"qttools.searchMode": "cmake"`?
Excuse me, I want to verify the mechanism of "qttools.searchMode": "cmake"
. Here is my opinion:
-
If we use
find_package(Qt6)
orfind_package(Qt5)
inCMakeLists.txt
, then the Cache VariableQt6_DIR
orQt5_DIR
will be written in theCMakeCache.txt
after configuring the CMake project. -
Then qttools will use this
Qt6_DIR
orQt5_DIR
to locate some tools such asdesigner.exe
relatively.
Am I correct?
Correct
@tonka3000, here is a problem I encountered. What if the value of QtX_DIR
is not the traditional location?
Recently, I tried to find_package
the Qt installed by Conan from conan-center-index. The Conan generator I used is CMakeDeps
or cmake_find_package_multi
. The mechanism of these generators is to generate some *-config.cmake
files inside the build directory, and then we can use find_package
to load the configurations.
We can see that the Qt6_DIR
after configuring is the following (becuase the Qt6Config.cmake
is actually in this directory):
D:\TEST-qt-cmake_find_package\build\conan\
However, the directory of binary packages of Qt installed by Conan is here:
C:\.conan\b9fb5546\1\
Therefore, the bottom status bar shows "Qt not found". Do you have any idea to deal with this situation?
Example Code
TEST-qt-cmake_find_package.zip
Screenshots
I think the best solution (for now) is to use qttools.extraSearchDirectories
to add the bin
directory of Qt Kits manually. For example:
{
"qttools.extraSearchDirectories": [
"C:\\Qt\\6.2.0\\msvc2019_64\\bin",
]
}
In other words, I have to install Qt by Official Installer, anyway.
As for Qt installed by Conan, I don't need and had better not to add qt:tools=True
option in conanfile.txt
because it seems that there are only Binary Packages of Qt with default option of qt:tools=False
in conan-center-index. That is, it will take a lot of time to compile the Source Package for the first time if I add qt:tools=True
option in conanfile.txt
.