vscode-qt-tools icon indicating copy to clipboard operation
vscode-qt-tools copied to clipboard

[question] What is the mechanism of `"qttools.searchMode": "cmake"`?

Open hwhsu1231 opened this issue 2 years ago • 3 comments

Excuse me, I want to verify the mechanism of "qttools.searchMode": "cmake". Here is my opinion:

  1. If we use find_package(Qt6) or find_package(Qt5) in CMakeLists.txt, then the Cache Variable Qt6_DIR or Qt5_DIR will be written in the CMakeCache.txt after configuring the CMake project.

  2. Then qttools will use this Qt6_DIR or Qt5_DIR to locate some tools such as designer.exe relatively.

Am I correct?

hwhsu1231 avatar Mar 16 '22 05:03 hwhsu1231

Correct

tonka3000 avatar Mar 16 '22 23:03 tonka3000

@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

image

hwhsu1231 avatar Mar 17 '22 13:03 hwhsu1231

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.

hwhsu1231 avatar Mar 19 '22 13:03 hwhsu1231